17 #ifndef __AXIMG_T_HOST__ 18 #define __AXIMG_T_HOST__ 21 #include <ac_reset_signal_is.h> 24 #include <nvhls_connections.h> 40 template <
typename Cfg>
43 sc_in<bool> reset_bar;
46 Connections::Out<WrRequest<Cfg> > wrRequestOut;
47 Connections::In<WrResp<Cfg> > wrRespIn;
48 Connections::Out<RdRequest<Cfg> > rdRequestOut;
49 Connections::In<RdResp<Cfg> > rdRespIn;
51 static const int bytesPerBeat = Cfg::dataWidth >> 3;
53 sc_out<bool> done_write;
54 sc_out<bool> done_read;
56 static const int write_count = 400;
57 static const int read_count = 50;
59 std::deque<unsigned int> read_ref;
60 std::queue<typename axi::axi4<Cfg>::Data> dataQ;
62 SC_CTOR(Host) : reset_bar(
"reset_bar"), clk(
"clk") {
63 SC_THREAD(run_wr_source);
64 sensitive << clk.pos();
65 async_reset_signal_is(reset_bar,
false);
67 SC_THREAD(run_wr_sink);
68 sensitive << clk.pos();
69 async_reset_signal_is(reset_bar,
false);
71 SC_THREAD(run_rd_source);
72 sensitive << clk.pos();
73 async_reset_signal_is(reset_bar,
false);
75 SC_THREAD(run_rd_sink);
76 sensitive << clk.pos();
77 async_reset_signal_is(reset_bar,
false);
81 static const int width = Cfg::dataWidth;
84 template <
unsigned int Size>
85 void Marshall(Marshaller<Size>& m) {
91 void run_wr_source() {
101 if (ctr < write_count) {
103 wrRequest.addr = addr;
105 int len = rand() % 6;
110 for (
int i = 0; i <= len; ++i) {
115 wrRequest.data = nvhls::gen_random_payload<Data>().d;
116 std::cout <<
"@" << sc_time_stamp()
117 <<
" write source initiated a request:" 118 <<
"\t addr = " << hex << wrRequest.addr
119 <<
"\t data = " << hex << wrRequest.data
120 <<
"\t len = " << dec << wrRequest.len
122 wrRequestOut.Push(wrRequest);
123 dataQ.push(wrRequest.data);
124 addr += bytesPerBeat;
139 std::cout <<
"@" << sc_time_stamp() <<
" write sink received response:" 140 <<
"\t resp = " << dec << wrResp.resp
142 if (++ctr == write_count) done_write = 1;
146 void run_rd_source() {
147 rdRequestOut.Reset();
156 if (ctr < read_count) {
157 if (rand() % 5 == 0) {
159 rdRequest.addr = addr;
160 int len = rand() % 3;
164 std::cout <<
"@" << sc_time_stamp() <<
" read source initiated a request:" 165 <<
"\t addr = " << hex << rdRequest.addr
166 <<
"\t len = " << dec << rdRequest.len
168 rdRequestOut.Push(rdRequest);
169 addr += (len+1)*bytesPerBeat;
186 std::cout <<
"@" << sc_time_stamp() <<
" read sink received response:" 187 <<
"\t last = " << rdResp.last
188 <<
"\t data = " << hex << rdResp.data
189 <<
"\t expected = " << hex << rd_data_expected
191 NVHLS_ASSERT_MSG(rdResp.data == rd_data_expected,
"Read response data did not match expected value");
193 if (rdResp.last == 1) ctr++;
194 if (ctr == read_count) done_read = 1;
The struct for read responses for AxiMasterGate.
The struct for read requests for AxiMasterGate.
The struct for write requests for AxiMasterGate.
NVUINTW(Wrapped< T >::width) TypeToNVUINT(T in)
Convert Type to NVUINT.
SC_MODULE(Host)
A testbench component to verify AxiMasterGate.
The base axi4 class parameterized according a valid config.
The struct for write responses for AxiMasterGate.
#define NVHLS_ASSERT_MSG(X, MSG)