1010#include " vendor/nlohmann/json.hpp"
1111
1212
13- namespace cxxrtl_design {
13+ namespace chipflow {
1414
1515using namespace cxxrtl ;
1616
@@ -30,9 +30,12 @@ void log_event(unsigned timestamp, const std::string &peripheral, const std::str
3030std::vector<action> get_pending_actions (const std::string &peripheral);
3131void close_event_log ();
3232
33- struct spiflash_model {
33+ namespace models {
34+
35+
36+ struct spiflash {
3437 std::string name;
35- spiflash_model (const std::string &name, const value<1 > &clk, const value<1 > &csn, const value<4 > &d_o, const value<4 > &d_oe, value<4 > &d_i) :
38+ spiflash (const std::string &name, const value<1 > &clk, const value<1 > &csn, const value<4 > &d_o, const value<4 > &d_oe, value<4 > &d_i) :
3639 name (name), clk(clk), csn(csn), d_o(d_o), d_oe(d_oe), d_i(d_i) {
3740 data.resize (16 *1024 *1024 );
3841 std::fill (data.begin (), data.end (), 0xFF ); // flash starting value
@@ -61,9 +64,9 @@ struct spiflash_model {
6164 } s;
6265};
6366
64- struct uart_model {
67+ struct uart {
6568 std::string name;
66- uart_model (const std::string &name, const value<1 > &tx, value<1 > &rx, unsigned baud_div = 25000000 /115200 ) : name(name), tx(tx), rx(rx), baud_div(baud_div) {};
69+ uart (const std::string &name, const value<1 > &tx, value<1 > &rx, unsigned baud_div = 25000000 /115200 ) : name(name), tx(tx), rx(rx), baud_div(baud_div) {};
6770
6871 void step (unsigned timestamp);
6972private:
@@ -83,10 +86,10 @@ struct uart_model {
8386};
8487
8588template <int pin_count>
86- struct gpio_model {
89+ struct gpio {
8790 std::string name;
8891
89- gpio_model (const std::string &name, const value<pin_count> &o, const value<pin_count> &oe, value<pin_count> &i) : name(name), o(o), oe(oe), i(i) {};
92+ gpio (const std::string &name, const value<pin_count> &o, const value<pin_count> &oe, value<pin_count> &i) : name(name), o(o), oe(oe), i(i) {};
9093
9194 void step (unsigned timestamp);
9295
@@ -104,7 +107,7 @@ struct gpio_model {
104107
105108// GPIO
106109template <int pin_count>
107- void gpio_model <pin_count>::step(unsigned timestamp) {
110+ void gpio <pin_count>::step(unsigned timestamp) {
108111 uint32_t o_value = o.template get <uint32_t >();
109112 uint32_t oe_value = oe.template get <uint32_t >();
110113
@@ -135,9 +138,9 @@ void gpio_model<pin_count>::step(unsigned timestamp) {
135138 s.oe_last = oe_value;
136139}
137140
138- struct spi_model {
141+ struct spi {
139142 std::string name;
140- spi_model (const std::string &name, const value<1 > &clk, const value<1 > &copi, value<1 > &cipo, const value<1 > &csn) :
143+ spi (const std::string &name, const value<1 > &clk, const value<1 > &copi, value<1 > &cipo, const value<1 > &csn) :
141144 name (name), clk(clk), csn(csn), copi(copi), cipo(cipo) {
142145 };
143146
@@ -159,9 +162,9 @@ struct spi_model {
159162 } s;
160163};
161164
162- struct i2c_model {
165+ struct i2c {
163166 std::string name;
164- i2c_model (const std::string &name, const value<1 > &scl_o, const value<1 > &scl_oe, value<1 > &scl_i, const value<1 > &sda_o, const value<1 > &sda_oe, value<1 > &sda_i) : name(name), sda_oe(sda_oe), sda_i(sda_i), scl_oe(scl_oe), scl_i(scl_i) {};
167+ i2c (const std::string &name, const value<1 > &scl_o, const value<1 > &scl_oe, value<1 > &scl_i, const value<1 > &sda_o, const value<1 > &sda_oe, value<1 > &sda_i) : name(name), sda_oe(sda_oe), sda_i(sda_i), scl_oe(scl_oe), scl_i(scl_i) {};
165168
166169 void step (unsigned timestamp);
167170private:
@@ -184,6 +187,7 @@ struct i2c_model {
184187};
185188
186189
187- }
190+ } // chipflow::simulation
191+ } // chipflow
188192
189193#endif
0 commit comments