first attempt at cpu monitor
This commit is contained in:
@@ -61,9 +61,6 @@ class cpu_driver #(
|
||||
$error($stime, " Drv: external write address 0x%0x is not word aligned\n", addr);
|
||||
end
|
||||
|
||||
// TODO: Drive one external write through the clocking block for one request,
|
||||
// then return the port to idle
|
||||
|
||||
cpuVif.cb.addr <= addr;
|
||||
cpuVif.cb.wdata <= data;
|
||||
|
||||
@@ -81,9 +78,6 @@ class cpu_driver #(
|
||||
$error($stime, " Drv: external read address 0x%0x is not word aligned\n", addr);
|
||||
end
|
||||
|
||||
// TODO: Keep the request stable until rready, capture the returned
|
||||
// data, and set a timeout for the response
|
||||
|
||||
timed_out = 1'b0;
|
||||
count = 0;
|
||||
|
||||
@@ -109,7 +103,6 @@ class cpu_driver #(
|
||||
|
||||
// Drive a start request for one CPU run
|
||||
task start_cpu();
|
||||
// TODO: Pulse en_cpu
|
||||
|
||||
cpuVif.cb.en_cpu <= 1;
|
||||
@(cpuVif.cb) cpuVif.cb.en_cpu <= 0;
|
||||
@@ -122,10 +115,6 @@ class cpu_driver #(
|
||||
limit = (max_cycles == 0) ? run_timeout : max_cycles;
|
||||
cycles = 0;
|
||||
|
||||
// TODO: Check cpu_halted on each cycle and report how many cycles
|
||||
// ran. Set last_run_completed only after a real halt. On a timeout, increment
|
||||
// timeouts and leave the flag low so the testbench can recover.
|
||||
|
||||
repeat (limit) begin
|
||||
@(cpuVif.cb) cycles++;
|
||||
if (cpuVif.cb.cpu_halted) begin
|
||||
@@ -154,8 +143,6 @@ class cpu_driver #(
|
||||
// Stop a program through an external halt and wait for memory ownership
|
||||
// to return to the external port
|
||||
task halt_cpu_now();
|
||||
// TODO: Assert an external halt request and wait, with a bound,
|
||||
// until ownership returns to the external port
|
||||
|
||||
cpuVif.cb.halt_cpu <= 1;
|
||||
@(cpuVif.cb);
|
||||
|
||||
@@ -3,9 +3,15 @@
|
||||
* keeps enough state to match requests with responses, including responses
|
||||
* that take more than one cycle.
|
||||
*/
|
||||
class cpu_monitor #(int DataSize=32, int AddrSize=14);
|
||||
class cpu_monitor #(
|
||||
int DataSize = 32,
|
||||
int AddrSize = 14
|
||||
);
|
||||
|
||||
virtual interface cpu_if #(.DataSize(DataSize), .AddrSize(AddrSize)) cpuVif;
|
||||
virtual interface cpu_if #(
|
||||
.DataSize(DataSize),
|
||||
.AddrSize(AddrSize)
|
||||
) cpuVif;
|
||||
|
||||
mailbox #(cpu_xbar_item #(DataSize, AddrSize)) mon_box;
|
||||
|
||||
@@ -43,17 +49,21 @@ class cpu_monitor #(int DataSize=32, int AddrSize=14);
|
||||
this.prev_reset = 1'b0;
|
||||
this.log_transactions = 1'b1;
|
||||
this.errors = 0;
|
||||
endfunction: new
|
||||
endfunction : new
|
||||
|
||||
// Create a transaction for an observed event and send it to the scoreboard
|
||||
task send(input trans_kind_e kind,
|
||||
input logic [AddrSize-1:0] addr, input logic [DataSize-1:0] data,
|
||||
input logic is_write=1'b0);
|
||||
task send(input trans_kind_e kind, input logic [AddrSize-1:0] addr,
|
||||
input logic [DataSize-1:0] data, input logic is_write = 1'b0);
|
||||
|
||||
// TODO: Create and send an xbar transaction through the mailbox
|
||||
|
||||
$fatal(1, "TODO: Implement cpu_monitor.send");
|
||||
endtask: send
|
||||
cpu_xbar_item #(DataSize, AddrSize) txn = new();
|
||||
txn.kind = kind;
|
||||
txn.addr = addr;
|
||||
txn.is_write = is_write;
|
||||
|
||||
mon_box.put(txn);
|
||||
endtask : send
|
||||
|
||||
// Match each external read request with its response
|
||||
task observe_external_read();
|
||||
@@ -62,8 +72,16 @@ class cpu_monitor #(int DataSize=32, int AddrSize=14);
|
||||
// shows that rdata is valid. How should you handle register file vs SRAM
|
||||
// reads?
|
||||
|
||||
$fatal(1, "Implement cpu_monitor.observe_external_read");
|
||||
endtask: observe_external_read
|
||||
if (!pending_read) begin
|
||||
pending_read = 1'b1;
|
||||
pending_read_addr = cpuVif.cb.addr;
|
||||
end
|
||||
|
||||
if (cpuVif.cb.rready) begin
|
||||
send(XBAR_READ, pending_read_addr, cpuVif.cb.rdata);
|
||||
pending_read = 1'b0;
|
||||
end
|
||||
endtask : observe_external_read
|
||||
|
||||
// Report each CPU data-memory request once
|
||||
task observe_cpu_memory();
|
||||
@@ -72,8 +90,9 @@ class cpu_monitor #(int DataSize=32, int AddrSize=14);
|
||||
// even if the request stays active during an SRAM wait. Clear saved state
|
||||
// after the request ends.
|
||||
|
||||
|
||||
$fatal(1, "Implement cpu_monitor.observe_cpu_memory");
|
||||
endtask: observe_cpu_memory
|
||||
endtask : observe_cpu_memory
|
||||
|
||||
// Monitor the DUT once per clock and pass new events to the scoreboard
|
||||
task run();
|
||||
@@ -102,8 +121,8 @@ class cpu_monitor #(int DataSize=32, int AddrSize=14);
|
||||
|
||||
if (cpuVif.cb.w_en && !cpuVif.cb.cpu_active) begin
|
||||
if (log_transactions) begin
|
||||
$display($stime, " Mon: External write Addr: 0x%04x, Data: 0x%08x\n",
|
||||
cpuVif.cb.addr, cpuVif.cb.wdata);
|
||||
$display($stime, " Mon: External write Addr: 0x%04x, Data: 0x%08x\n", cpuVif.cb.addr,
|
||||
cpuVif.cb.wdata);
|
||||
end
|
||||
|
||||
send(XBAR_WRITE, cpuVif.cb.addr, cpuVif.cb.wdata, 1'b1);
|
||||
@@ -121,6 +140,7 @@ class cpu_monitor #(int DataSize=32, int AddrSize=14);
|
||||
prev_cpu_active = cpuVif.cb.cpu_active;
|
||||
prev_cpu_halted = cpuVif.cb.cpu_halted;
|
||||
end
|
||||
endtask: run
|
||||
endtask : run
|
||||
|
||||
endclass : cpu_monitor
|
||||
|
||||
endclass: cpu_monitor
|
||||
Reference in New Issue
Block a user