1- #undef NDEBUG
2-
3- #include < cxxrtl/cxxrtl.h>
4- #include < cxxrtl/cxxrtl_server.h>
5- #include " sim_soc.h"
6- #include " models.h"
7-
8- #include < fstream>
9- #include < filesystem>
10-
11- using namespace cxxrtl ::time_literals;
12- using namespace cxxrtl_design ;
13-
14- int main (int argc, char **argv) {
15- p_sim__top top;
16-
17- spiflash_model flash (" flash" , top.p_flash____clk__o , top.p_flash____csn__o ,
18- top.p_flash____d__o , top.p_flash____d__oe , top.p_flash____d__i );
19-
20- uart_model uart_0 (" uart_0" , top.p_uart__0____tx__o , top.p_uart__0____rx__i );
21- uart_model uart_1 (" uart_1" , top.p_uart__1____tx__o , top.p_uart__1____rx__i );
22-
23- gpio_model gpio_0 (" gpio_0" , top.p_gpio__0____o , top.p_gpio__0____oe , top.p_gpio__0____i );
24- gpio_model gpio_1 (" gpio_1" , top.p_gpio__1____o , top.p_gpio__1____oe , top.p_gpio__1____i );
25-
26- spi_model spi_0 (" spi_0" , top.p_user__spi__0____sck__o , top.p_user__spi__0____csn__o , top.p_user__spi__0____mosi__o , top.p_user__spi__0____miso__i );
27- spi_model spi_1 (" spi_1" , top.p_user__spi__1____sck__o , top.p_user__spi__1____csn__o , top.p_user__spi__1____mosi__o , top.p_user__spi__1____miso__i );
28- spi_model spi_2 (" spi_2" , top.p_user__spi__2____sck__o , top.p_user__spi__2____csn__o , top.p_user__spi__2____mosi__o , top.p_user__spi__2____miso__i );
29-
30- i2c_model i2c_0 (" i2c_0" , top.p_i2c__0____sda__oe , top.p_i2c__0____sda__i , top.p_i2c__0____scl__oe , top.p_i2c__0____scl__i );
31- i2c_model i2c_1 (" i2c_1" , top.p_i2c__1____sda__oe , top.p_i2c__1____sda__i , top.p_i2c__1____scl__oe , top.p_i2c__1____scl__i );
32-
33- cxxrtl::agent agent (cxxrtl::spool (" spool.bin" ), top);
34- if (getenv (" DEBUG" )) // can also be done when a condition is violated, etc
35- std::cerr << " Waiting for debugger on " << agent.start_debugging () << std::endl;
36-
37- open_event_log (" events.json" );
38- open_input_commands (" ../../my_design/tests/input.json" );
39-
40- unsigned timestamp = 0 ;
41- auto tick = [&]() {
42- // agent.print(stringf("timestamp %d\n", timestamp), CXXRTL_LOCATION);
43-
44- flash.step (timestamp);
45- uart_0.step (timestamp);
46- uart_1.step (timestamp);
47-
48- gpio_0.step (timestamp);
49- gpio_1.step (timestamp);
50-
51- spi_0.step (timestamp);
52- spi_1.step (timestamp);
53- spi_2.step (timestamp);
54-
55- i2c_0.step (timestamp);
56- i2c_1.step (timestamp);
57-
58- top.p_clk .set (false );
59- agent.step ();
60- agent.advance (1_us);
61- ++timestamp;
62-
63- top.p_clk .set (true );
64- agent.step ();
65- agent.advance (1_us);
66- ++timestamp;
67-
68- // if (timestamp == 10)
69- // agent.breakpoint(CXXRTL_LOCATION);
70- };
71-
72- flash.load_data (" ../software/software.bin" , 0x00100000U );
73- agent.step ();
74- agent.advance (1_us);
75-
76- top.p_rst .set (true );
77- tick ();
78-
79- top.p_rst .set (false );
80- for (int i = 0 ; i < 2000000 ; i++)
81- tick ();
82-
83- close_event_log ();
84- return 0 ;
85- }
1+ #undef NDEBUG
2+
3+ #include < cxxrtl/cxxrtl.h>
4+ #include < cxxrtl/cxxrtl_server.h>
5+ #include " sim_soc.h"
6+ #include " models.h"
7+
8+ #include < fstream>
9+ #include < filesystem>
10+
11+ using namespace cxxrtl ::time_literals;
12+ using namespace cxxrtl_design ;
13+
14+ int main (int argc, char **argv) {
15+ p_sim__top top;
16+
17+ spiflash_model flash (" flash" , top.p_flash____clk__o , top.p_flash____csn__o ,
18+ top.p_flash____d__o , top.p_flash____d__oe , top.p_flash____d__i );
19+
20+ uart_model uart_0 (" uart_0" , top.p_uart__0____tx__o , top.p_uart__0____rx__i );
21+ uart_model uart_1 (" uart_1" , top.p_uart__1____tx__o , top.p_uart__1____rx__i );
22+
23+ gpio_model gpio_0 (" gpio_0" , top.p_gpio__0____o , top.p_gpio__0____oe , top.p_gpio__0____i );
24+ gpio_model gpio_1 (" gpio_1" , top.p_gpio__1____o , top.p_gpio__1____oe , top.p_gpio__1____i );
25+
26+ spi_model spi_0 (" spi_0" , top.p_user__spi__0____sck__o , top.p_user__spi__0____csn__o , top.p_user__spi__0____mosi__o , top.p_user__spi__0____miso__i );
27+ spi_model spi_1 (" spi_1" , top.p_user__spi__1____sck__o , top.p_user__spi__1____csn__o , top.p_user__spi__1____mosi__o , top.p_user__spi__1____miso__i );
28+ spi_model spi_2 (" spi_2" , top.p_user__spi__2____sck__o , top.p_user__spi__2____csn__o , top.p_user__spi__2____mosi__o , top.p_user__spi__2____miso__i );
29+
30+ i2c_model i2c_0 (" i2c_0" , top.p_i2c__0____sda__oe , top.p_i2c__0____sda__i , top.p_i2c__0____scl__oe , top.p_i2c__0____scl__i );
31+ i2c_model i2c_1 (" i2c_1" , top.p_i2c__1____sda__oe , top.p_i2c__1____sda__i , top.p_i2c__1____scl__oe , top.p_i2c__1____scl__i );
32+
33+ cxxrtl::agent agent (cxxrtl::spool (" spool.bin" ), top);
34+ if (getenv (" DEBUG" )) // can also be done when a condition is violated, etc
35+ std::cerr << " Waiting for debugger on " << agent.start_debugging () << std::endl;
36+
37+ open_event_log (" events.json" );
38+ open_input_commands (" ../../my_design/tests/input.json" );
39+
40+ unsigned timestamp = 0 ;
41+ auto tick = [&]() {
42+ // agent.print(stringf("timestamp %d\n", timestamp), CXXRTL_LOCATION);
43+
44+ flash.step (timestamp);
45+ uart_0.step (timestamp);
46+ uart_1.step (timestamp);
47+
48+ gpio_0.step (timestamp);
49+ gpio_1.step (timestamp);
50+
51+ spi_0.step (timestamp);
52+ spi_1.step (timestamp);
53+ spi_2.step (timestamp);
54+
55+ i2c_0.step (timestamp);
56+ i2c_1.step (timestamp);
57+
58+ top.p_clk .set (false );
59+ agent.step ();
60+ agent.advance (1_us);
61+ ++timestamp;
62+
63+ top.p_clk .set (true );
64+ agent.step ();
65+ agent.advance (1_us);
66+ ++timestamp;
67+
68+ // if (timestamp == 10)
69+ // agent.breakpoint(CXXRTL_LOCATION);
70+ };
71+
72+ flash.load_data (" ../software/software.bin" , 0x00100000U );
73+ agent.step ();
74+ agent.advance (1_us);
75+
76+ top.p_rst .set (true );
77+ tick ();
78+
79+ top.p_rst .set (false );
80+ for (int i = 0 ; i < 2000000 ; i++)
81+ tick ();
82+
83+ close_event_log ();
84+ return 0 ;
85+ }
0 commit comments