Skip to content

Commit a759b7b

Browse files
committed
Adding documentation for VGA module and testbench
1 parent f729171 commit a759b7b

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

modules/vga/src/vga_tb.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
#include "vga.hpp"
44

5-
// 120 MHz
5+
6+
// Main clock frequency in Hz - 120 MHz
67
#define CLK_FREQ 120000000
8+
// VGA settings
79
#define H_ACTIVE 640
810
#define H_FP 16
911
#define H_SYNC_PULSE 96
@@ -12,41 +14,46 @@
1214
#define V_FP 10
1315
#define V_SYNC_PULSE 2
1416
#define V_BP 33
17+
// Compute the total number of pixels
1518
#define TOTAL_PIXELES ((H_ACTIVE + H_FP + H_SYNC_PULSE + H_BP) *\
1619
(V_ACTIVE + V_FP + V_SYNC_PULSE + V_BP))
1720

1821

1922
int sc_main(int, char*[])
2023
{
24+
// Compute the clock time in seconds
2125
const double CLK_TIME = 1.0 / static_cast<double>(CLK_FREQ);
26+
// Compute the total simulation based on the total amount of pixels in the
27+
// screen
2228
const double SIM_TIME = CLK_TIME * static_cast<double>(TOTAL_PIXELES);
2329

24-
sc_time total_sim_time = sc_time(SIM_TIME, SC_SEC);
25-
26-
sc_core::sc_clock s_clk("clk", CLK_TIME, sc_core::SC_SEC);
30+
// Signals to use
31+
sc_core::sc_clock clk("clk", CLK_TIME, sc_core::SC_SEC);
2732
sc_core::sc_signal<bool> s_hsync;
2833
sc_core::sc_signal<bool> s_vsync;
29-
3034
#ifdef IPS_DEBUG_EN
3135
sc_core::sc_signal<int> s_h_count;
3236
sc_core::sc_signal<int> s_v_count;
3337
#endif // IPS_DEBUG_EN
3438

39+
// VGA module instanciation and connections
3540
vga<
3641
H_ACTIVE, H_FP, H_SYNC_PULSE, H_BP,
3742
V_ACTIVE, V_FP, V_SYNC_PULSE, V_BP
3843
> ips_vga("ips_vga");
39-
ips_vga.clk(s_clk);
44+
ips_vga.clk(clk);
4045
ips_vga.o_hsync(s_hsync);
4146
ips_vga.o_vsync(s_vsync);
4247
#ifdef IPS_DEBUG_EN
4348
ips_vga.o_h_count(s_h_count);
4449
ips_vga.o_v_count(s_v_count);
4550
#endif // IPS_DEBUG_EN
4651

52+
// Signals to dump
4753
#ifdef IPS_DUMP_EN
4854
sca_util::sca_trace_file* tf = sca_util::sca_create_vcd_trace_file("ips_vga");
49-
sca_trace(tf, s_clk, "clk");
55+
56+
sca_trace(tf, clk, "clk");
5057
sca_trace(tf, s_hsync, "hsync");
5158
sca_trace(tf, s_vsync, "vsync");
5259
#ifdef IPS_DEBUG_EN
@@ -55,11 +62,12 @@ int sc_main(int, char*[])
5562
#endif // IPS_DEBUG_EN
5663
#endif // IPS_DUMP_EN
5764

65+
// Start time
5866
std::cout << "@" << sc_time_stamp() << std::endl;
59-
std::cout << "Expected total sim time: " << total_sim_time << std::endl;
6067

6168
sc_start(SIM_TIME, sc_core::SC_SEC);
6269

70+
// End time
6371
std::cout << "@" << sc_time_stamp() << std::endl;
6472

6573
#ifdef IPS_DUMP_EN

0 commit comments

Comments
 (0)