Support for more realistic MemTracer step2 (DONE), make Verilog Blackbox DPI output data immediately and make .cc file maintain pointer when downstream is not ready
This commit is contained in:
@@ -64,7 +64,8 @@ void MemTraceReader::parse() {
|
||||
// given SIMD lane (= "thread"). In case no request happened at that point,
|
||||
// return an empty line with .valid = false.
|
||||
MemTraceLine MemTraceReader::read_trace_at(const long cycle,
|
||||
const int lane_id) {
|
||||
const int lane_id,
|
||||
unsigned char trace_read_ready) {
|
||||
MemTraceLine line;
|
||||
line.valid = false;
|
||||
|
||||
@@ -79,7 +80,9 @@ MemTraceLine MemTraceReader::read_trace_at(const long cycle,
|
||||
// the next line is in the future.
|
||||
if (line.cycle < cycle) {
|
||||
// fprintf(stderr, "line.cycle=%ld, cycle=%ld\n", line.cycle, cycle);
|
||||
printf("cycle=%ld, some lines are left in past Fatal", cycle);
|
||||
assert(false && "some trace lines are left unread in the past");
|
||||
return MemTraceLine{};
|
||||
}
|
||||
|
||||
if (line.lane_id != lane_id) {
|
||||
@@ -90,22 +93,29 @@ MemTraceLine MemTraceReader::read_trace_at(const long cycle,
|
||||
// read it right now.
|
||||
return MemTraceLine{};
|
||||
} else if (line.cycle == cycle && line.lane_id == lane_id) {
|
||||
printf("fire! cycle=%ld, valid=%d, %s addr=%lx, size=%d \n", cycle,
|
||||
line.valid, (line.is_store ? "STORE" : "LOAD"), line.address,
|
||||
line.log_data_size);
|
||||
|
||||
// FIXME! Currently lane_id is assumed to be in round-robin order, e.g.
|
||||
// 0->1->2->3->0->..., both in the trace file and the order the caller calls
|
||||
// this function. If this is not true, we cannot simply monotonically
|
||||
// increment read_pos.
|
||||
if (trace_read_ready){
|
||||
printf("Fire! cycle=%ld, valid=%d, %s addr=%lx, size=%d \n", cycle,
|
||||
line.valid, (line.is_store ? "STORE" : "LOAD"), line.address,
|
||||
line.log_data_size);
|
||||
|
||||
// Only advance pointer when cycle and threa_id both match
|
||||
// now increaseing sequence is fine (0, 1, 3), but unordered is not fine (0, 3, 1)
|
||||
++read_pos;
|
||||
// FIXME! Currently lane_id is assumed to be in round-robin order, e.g.
|
||||
// 0->1->2->3->0->..., both in the trace file and the order the caller calls
|
||||
// this function. If this is not true, we cannot simply monotonically
|
||||
// increment read_pos.
|
||||
// Only advance pointer when cycle and threa_id both match
|
||||
// now increaseing sequence is fine (0, 1, 3), but unordered is not fine (0, 3, 1)
|
||||
++read_pos;
|
||||
}
|
||||
else { // we do not want to advance read_pos
|
||||
printf("All Lanes Blocked on this cycle! cycle=%ld \n", cycle);
|
||||
}
|
||||
|
||||
return line;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
extern "C" void memtrace_init(const char *filename) {
|
||||
#ifndef NO_VPI
|
||||
@@ -145,11 +155,14 @@ extern "C" void memtrace_query(unsigned char trace_read_ready,
|
||||
// printf("memtrace_query(cycle=%ld, tid=%d)\n", trace_read_cycle,
|
||||
// trace_read_lane_id);
|
||||
|
||||
/* we can't return immediately, even if trace is ready, we still want to find out
|
||||
if we are suppose to generate valid req on this clock cycle
|
||||
if (!trace_read_ready) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
auto line = reader->read_trace_at(trace_read_cycle, trace_read_lane_id);
|
||||
auto line = reader->read_trace_at(trace_read_cycle, trace_read_lane_id, trace_read_ready);
|
||||
*trace_read_valid = line.valid;
|
||||
*trace_read_address = line.address;
|
||||
*trace_read_is_store = line.is_store;
|
||||
|
||||
Reference in New Issue
Block a user