43 static const int kDebugLevel = 1;
44 sc_in<bool> reset_bar;
47 Connections::Out<WrRequest<Cfg> > wrRequestOut;
48 Connections::In<WrResp<Cfg> > wrRespIn;
49 Connections::Out<RdRequest<Cfg> > rdRequestOut;
50 Connections::In<RdResp<Cfg> > rdRespIn;
52 static const int bytesPerBeat = Cfg::dataWidth >> 3;
54 sc_out<bool> done_write;
55 sc_out<bool> done_read;
57 static const int write_count = 400;
58 static const int read_count = 50;
60 std::deque<unsigned int> read_ref;
61 std::queue<typename axi::axi4<Cfg>::Data> dataQ;
63 SC_CTOR(Host) : reset_bar(
"reset_bar"), clk(
"clk") {
64 SC_THREAD(run_wr_source);
65 sensitive << clk.pos();
66 async_reset_signal_is(reset_bar,
false);
68 SC_THREAD(run_wr_sink);
69 sensitive << clk.pos();
70 async_reset_signal_is(reset_bar,
false);
72 SC_THREAD(run_rd_source);
73 sensitive << clk.pos();
74 async_reset_signal_is(reset_bar,
false);
76 SC_THREAD(run_rd_sink);
77 sensitive << clk.pos();
78 async_reset_signal_is(reset_bar,
false);
82 static const int width = Cfg::dataWidth;
85 template <
unsigned int Size>
86 void Marshall(Marshaller<Size>& m) {
92 void run_wr_source() {
102 if (ctr < write_count) {
104 wrRequest.addr = addr;
106 int len = rand() % 6;
111 for (
int i = 0; i <= len; ++i) {
117 CDCOUT(
"@" << sc_time_stamp()
118 <<
" write source initiated a request:"
119 <<
"\t addr = " << hex << wrRequest.addr
120 <<
"\t data = " << hex << wrRequest.data
121 <<
"\t len = " << dec << wrRequest.len
122 << std::endl, kDebugLevel);
123 wrRequestOut.Push(wrRequest);
124 dataQ.push(wrRequest.data);
125 addr += bytesPerBeat;
140 CDCOUT(
"@" << sc_time_stamp() <<
" write sink received response:"
141 <<
"\t resp = " << dec << wrResp.resp
142 << std::endl, kDebugLevel);
143 if (++ctr == write_count) done_write = 1;
147 void run_rd_source() {
148 rdRequestOut.Reset();
157 if (ctr < read_count) {
158 if (rand() % 5 == 0) {
160 rdRequest.addr = addr;
161 int len = rand() % 3;
165 CDCOUT(
"@" << sc_time_stamp() <<
" read source initiated a request:"
166 <<
"\t addr = " << hex << rdRequest.addr
167 <<
"\t len = " << dec << rdRequest.len
168 << std::endl, kDebugLevel);
169 rdRequestOut.Push(rdRequest);
170 addr += (len+1)*bytesPerBeat;
187 CDCOUT(
"@" << sc_time_stamp() <<
" read sink received response:"
188 <<
"\t last = " << rdResp.last
189 <<
"\t data = " << hex << rdResp.data
190 <<
"\t expected = " << hex << rd_data_expected
191 << std::endl, kDebugLevel);
192 CMOD_ASSERT_MSG(rdResp.data == rd_data_expected,
"Read response data did not match expected value");
194 if (rdResp.last == 1) ctr++;
195 if (ctr == read_count) done_read = 1;