Skip to content

Commit

Permalink
Disable logging in drivers and only with DEBUG in driver.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
RootCubed committed Jul 3, 2024
1 parent be426f0 commit 27483a6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
22 changes: 15 additions & 7 deletions test/backend/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
#include <map>
#include <iostream>

// #define DEBUG

#ifdef DEBUG
#define DEBUG_PRINT(fmt, args...) printf("DEBUG: %s:%d: " fmt, \
__FILE__, __LINE__, ##args)
#else
#define DEBUG_PRINT(fmt, args...)
#endif

typedef Vtb_idma_backend_idma_req_t__struct__0 idma_req_t;

std::map<uint32_t, uint32_t> memory_accesses;
Expand All @@ -40,7 +49,7 @@ unsigned int num_reads = 0;
unsigned int num_writes = 0;

void idma_read(int addr, int *data, int *delay) {
printf("[DRIVER] Read from %08x: %08x\n", addr, curr_access_id);
DEBUG_PRINT("[DRIVER] Read from %08x: %08x\n", addr, curr_access_id);
*data = curr_access_id;
*delay = 5000;
memory_accesses.insert({addr, curr_access_id});
Expand All @@ -50,12 +59,12 @@ void idma_read(int addr, int *data, int *delay) {

void idma_write(int w_addr, int w_data) {
uint32_t orig_addr = w_addr + currentIdmaRequest().src_addr - currentIdmaRequest().dst_addr;
printf("[DRIVER] Write %08x to %08x (original address: %08x)\n", w_data, w_addr, orig_addr);
DEBUG_PRINT("[DRIVER] Write %08x to %08x (original address: %08x)\n", w_data, w_addr, orig_addr);
if (memory_accesses.count(orig_addr) == 0) {
printf("[DRIVER] Write is invalid (never read from there)\n");
DEBUG_PRINT("[DRIVER] Write is invalid (never read from there)\n");
invalid_writes++;
} else if (memory_accesses.at(orig_addr) != w_data) {
printf("[DRIVER] Write is invalid (wrong value)\n");
DEBUG_PRINT("[DRIVER] Write is invalid (wrong value)\n");
invalid_writes++;
} else {
memory_accesses.erase(orig_addr);
Expand All @@ -75,7 +84,7 @@ Vtb_idma_backend_idma_pkg::protocol_e strToProtocol(std::string str) {
}

int main(int argc, char **argv) {
Verilated::debug(1);
// Verilated::debug(1);

Verilated::commandArgs(argc, argv);
Vtb_idma_backend *idma = new Vtb_idma_backend();
Expand Down Expand Up @@ -124,8 +133,7 @@ int main(int argc, char **argv) {
idmaRequest.opt.beo.dst_reduce_len = 1;

idmaRequest.opt.last = (i == reqCount - 1);

// printf("Pushing request\n");

pendingIdmaRequests.push_back(idmaRequest);
idma->tb_idma_backend->trigger_request(idmaRequest.get());
}
Expand Down
8 changes: 2 additions & 6 deletions test/drivers/axi_read.sv
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ task automatic process_read(ax_beat_t beat);
assert(bytes_per_beat == DataWidth / 8) else $error("[AXI_R] Unsupported AXI data width");
assert(beat.ax_burst != axi_pkg::BURST_WRAP) else $error("[AXI_R] WRAP bursts are not supported");


$display("[AXI_R] Burst length: %0d", actual_burst_len);

for (int i = 0; i < actual_burst_len; i++) begin
int addr = (beat.ax_burst == axi_pkg::BURST_FIXED) ? beat.ax_addr : beat.ax_addr + i * bytes_per_beat;

Expand All @@ -70,18 +67,17 @@ task automatic process_read(ax_beat_t beat);
if (i == actual_burst_len - 1) begin
r_beat.r_last = 1;
end
$display("[AXI_R] Sending R (beat %0d/%0d): %08x", (i + 1), actual_burst_len, r_beat.r_data);
// $display("[AXI_R] Sending R (beat %0d/%0d): %08x", (i + 1), actual_burst_len, r_beat.r_data);
driver.send_r(r_beat);
end
$display("[AXI_R] Burst done");
endtask

task automatic axi_process();
forever begin
ax_beat_t ar_beat = new;

driver.recv_ar(ar_beat);
$display("[AXI_R] Received AR with addr=%08x", ar_beat.ax_addr);
// $display("[AXI_R] Received AR with addr=%08x", ar_beat.ax_addr);

// fork begin
process_read(ar_beat);
Expand Down
8 changes: 3 additions & 5 deletions test/drivers/axi_write.sv
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,27 @@ task automatic process_write(ax_beat_t beat);

assert(bytes_per_beat == DataWidth / 8) else $error("[AXI_W] Unsupported AXI data width");
assert(beat.ax_burst != axi_pkg::BURST_WRAP) else $error("[AXI_W] WRAP bursts are not supported");

$display("[AXI_W] Burst length: %0d", actual_burst_len);

for (int i = 0; i < actual_burst_len; i++) begin
int addr = (beat.ax_burst == axi_pkg::BURST_FIXED) ? beat.ax_addr : beat.ax_addr + i * bytes_per_beat;

driver.recv_w(w_beat);
$display("[AXI_W] Received W (beat %0d/%0d): %08x/%08x", (i + 1), actual_burst_len, addr, w_beat.w_data);
// $display("[AXI_W] Received W (beat %0d/%0d): %08x/%08x", (i + 1), actual_burst_len, addr, w_beat.w_data);
idma_write(addr, w_beat.w_data);
end

b_beat.b_id = beat.ax_id;
b_beat.b_resp = 0;
driver.send_b(b_beat);
$display("[AXI_W] Sent B");
// $display("[AXI_W] Sent B");
endtask

task automatic axi_process();
forever begin
ax_beat_t aw_beat = new;

driver.recv_aw(aw_beat);
$display("[AXI_W] Received AW, %08x", aw_beat.ax_addr);
// $display("[AXI_W] Received AW, %08x", aw_beat.ax_addr);

// fork begin
process_write(aw_beat);
Expand Down
5 changes: 2 additions & 3 deletions test/drivers/obi_read.sv
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ forever begin
int v;
int delay;

$display("[OBI] Waiting for read request...");
driver.recv_r_ar(a);
$display("[OBI] Received A, %08x", a.addr);
// $display("[OBI] Received A, %08x", a.addr);

idma_read(a.addr, v, delay);

r_resp.data = v;
driver.send_r_rsp(r_resp);
$display("[OBI] Sent R");
// $display("[OBI] Sent R");
end
endtask

Expand Down
2 changes: 1 addition & 1 deletion test/drivers/obi_write.sv
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ forever begin
obi_ar_beat a = new;

driver.recv_w_ar(a);
$display("[OBI_W] Received write request: %08x to %08x", a.wdata, a.addr);
// $display("[OBI_W] Received write request: %08x to %08x", a.wdata, a.addr);

idma_write(a.addr, a.wdata);

Expand Down

0 comments on commit 27483a6

Please sign in to comment.