Skip to content

Commit da9d700

Browse files
RMorales25ErickOF
authored andcommitted
Fix target to respond using a thread method
1 parent 60b0970 commit da9d700

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

modules/router/src/img_target.cpp

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ struct img_target: sc_module
3535
sc_time response_delay;
3636
sc_time receive_delay;
3737

38+
//SC_EVENT
39+
sc_event send_response_e;
40+
3841
//Constructor
3942
SC_CTOR(img_target)
4043
: socket("socket"), response_transaction(0), m_peq(this, &img_target::peq_cb) // Construct and name socket
4144
{
4245
// Register callbacks for incoming interface method calls
4346
socket.register_nb_transport_fw(this, &img_target::nb_transport_fw);
47+
48+
SC_THREAD(send_response);
4449
}
4550

4651
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& trans,
@@ -99,34 +104,35 @@ struct img_target: sc_module
99104
}
100105
}
101106

102-
//Resposne function
103-
void send_response(tlm::tlm_generic_payload& trans)
107+
//Response function
108+
void send_response()
104109
{
105-
tlm::tlm_sync_enum status;
106-
tlm::tlm_phase response_phase;
107-
img_generic_extension* img_ext;
108-
109-
response_phase = tlm::BEGIN_RESP;
110-
status = socket->nb_transport_bw(trans, response_phase, response_delay);
111-
dbgmodprint("HERE");
112-
113-
//Check Initiator response
114-
switch(status) {
115-
case tlm::TLM_ACCEPTED: {
116-
// Target only care about acknowledge of the succesful response
117-
trans.release();
118-
trans.get_extension(img_ext);
119-
dbgmodprint("TLM_ACCEPTED RECEIVED TRANS ID %0d", img_ext->transaction_number);
120-
break;
121-
}
110+
while(true){
111+
wait(send_response_e);
112+
tlm::tlm_sync_enum status;
113+
tlm::tlm_phase response_phase;
114+
img_generic_extension* img_ext;
115+
116+
response_phase = tlm::BEGIN_RESP;
117+
status = socket->nb_transport_bw(*response_transaction, response_phase, response_delay);
118+
119+
//Check Initiator response
120+
switch(status) {
121+
case tlm::TLM_ACCEPTED: {
122+
// Target only care about acknowledge of the succesful response
123+
(*response_transaction).release();
124+
(*response_transaction).get_extension(img_ext);
125+
dbgmodprint("TLM_ACCEPTED RECEIVED TRANS ID %0d", img_ext->transaction_number);
126+
break;
127+
}
122128

123-
//Not implementing Updated and Completed Status
124-
default: {
125-
dbgmodprint("[ERROR] Invalid status received at target");
126-
break;
129+
//Not implementing Updated and Completed Status
130+
default: {
131+
dbgmodprint("[ERROR] Invalid status received at target");
132+
break;
133+
}
127134
}
128135
}
129-
130136
}
131137

132138
virtual void do_when_read_transaction(unsigned char*& data, unsigned int data_length, sc_dt::uint64 address){
@@ -190,7 +196,9 @@ struct img_target: sc_module
190196

191197
//Send response
192198
dbgmodprint("BEGIN_RESP SENT TRANS ID %0d", img_ext->transaction_number);
193-
send_response(trans);
199+
response_transaction = &trans;
200+
//send_response(trans);
201+
send_response_e.notify();
194202
}
195203

196204
void set_delays(sc_time resp_delay, sc_time rec_delay)

0 commit comments

Comments
 (0)