Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21c1f2837a | ||
|
|
d4d1c5edbf |
@@ -7,9 +7,15 @@
|
|||||||
* the CPU and the external port, and acts as a crossbar (xbar) to route external
|
* the CPU and the external port, and acts as a crossbar (xbar) to route external
|
||||||
* access to ISRAM, DSRAM, and registers.
|
* access to ISRAM, DSRAM, and registers.
|
||||||
*/
|
*/
|
||||||
class cpu_driver #(int DataSize=32, int AddrSize=14);
|
class cpu_driver #(
|
||||||
|
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)) xbar_box;
|
mailbox #(cpu_xbar_item #(DataSize, AddrSize)) xbar_box;
|
||||||
|
|
||||||
@@ -36,7 +42,17 @@ class cpu_driver #(int DataSize=32, int AddrSize=14);
|
|||||||
// TODO: Drive all requests inactive, hold reset for several clock
|
// TODO: Drive all requests inactive, hold reset for several clock
|
||||||
// cycles, then release it and give the interface time to settle
|
// cycles, then release it and give the interface time to settle
|
||||||
|
|
||||||
$fatal(1, "implement cpu_driver.reset_task");
|
cpuVif.cb.en_cpu <= 0;
|
||||||
|
cpuVif.cb.halt_cpu <= 0;
|
||||||
|
cpuVif.cb.addr <= 0;
|
||||||
|
cpuVif.cb.wdata <= 0;
|
||||||
|
cpuVif.cb.w_en <= 0;
|
||||||
|
cpuVif.cb.r_en <= 0;
|
||||||
|
|
||||||
|
cpuVif.cb.reset <= 1;
|
||||||
|
repeat (4) @(cpuVif.cb);
|
||||||
|
cpuVif.cb.reset <= 0;
|
||||||
|
repeat (2) @(cpuVif.cb);
|
||||||
endtask : reset_task
|
endtask : reset_task
|
||||||
|
|
||||||
// Send one write through the DUT's external memory port
|
// Send one write through the DUT's external memory port
|
||||||
@@ -48,7 +64,12 @@ class cpu_driver #(int DataSize=32, int AddrSize=14);
|
|||||||
// TODO: Drive one external write through the clocking block for one request,
|
// TODO: Drive one external write through the clocking block for one request,
|
||||||
// then return the port to idle
|
// then return the port to idle
|
||||||
|
|
||||||
$fatal(1, "implement cpu_driver.xbar_write");
|
cpuVif.cb.addr <= addr;
|
||||||
|
cpuVif.cb.data <= data;
|
||||||
|
|
||||||
|
cpuVif.cb.w_en <= 1;
|
||||||
|
@(cpuVif.cb);
|
||||||
|
cpuVif.cb.w_en <= 0;
|
||||||
endtask : xbar_write
|
endtask : xbar_write
|
||||||
|
|
||||||
// Send one read through the external memory port and wait for its data
|
// Send one read through the external memory port and wait for its data
|
||||||
@@ -66,14 +87,32 @@ class cpu_driver #(int DataSize=32, int AddrSize=14);
|
|||||||
timed_out = 1'b0;
|
timed_out = 1'b0;
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
$fatal(1, "implement cpu_driver.xbar_read");
|
cpuVif.cb.addr <= addr;
|
||||||
|
cpuVif.cb.r_en <= 1;
|
||||||
|
|
||||||
|
timed_out = 1'b1;
|
||||||
|
repeat (xbar_timeout) begin
|
||||||
|
@(cpuVif.cb);
|
||||||
|
if (cpuVif.cb.rready) begin
|
||||||
|
timed_out = 1'b0;
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (timed_out) begin
|
||||||
|
timeouts++;
|
||||||
|
$error($stime, " Drv: read 0x%0x timed out\n", addr);
|
||||||
|
end
|
||||||
|
|
||||||
|
cpuVif.cb.r_en <= 0;
|
||||||
endtask : xbar_read
|
endtask : xbar_read
|
||||||
|
|
||||||
// Drive a start request for one CPU run
|
// Drive a start request for one CPU run
|
||||||
task start_cpu();
|
task start_cpu();
|
||||||
// TODO: Pulse en_cpu
|
// TODO: Pulse en_cpu
|
||||||
|
|
||||||
$fatal(1, "implement cpu_driver.start_cpu");
|
cpuVif.cb.en_cpu <= 1;
|
||||||
|
@(cpuVif.cb) cpuVif.cb.en_cpu <= 0;
|
||||||
endtask : start_cpu
|
endtask : start_cpu
|
||||||
|
|
||||||
// Wait for the CPU to halt, or fail after the allowed number of cycles
|
// Wait for the CPU to halt, or fail after the allowed number of cycles
|
||||||
@@ -87,9 +126,20 @@ class cpu_driver #(int DataSize=32, int AddrSize=14);
|
|||||||
// ran. Set last_run_completed only after a real halt. On a timeout, increment
|
// 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.
|
// timeouts and leave the flag low so the testbench can recover.
|
||||||
|
|
||||||
last_run_completed = 1'b0;
|
repeat (limit) begin
|
||||||
|
@(cpuVif.cb) cycles++;
|
||||||
|
if (cpuVif.cb.cpu_halted) begin
|
||||||
|
@(cpuVif.cb)
|
||||||
|
// real halt goes high then low after one pulse
|
||||||
|
if (!cpuVif.cb.cpu_halted) begin
|
||||||
|
last_run_completed = 1'b1;
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
$fatal(1, "implement cpu_driver.wait_for_halt");
|
timeouts++;
|
||||||
|
last_run_completed = 1'b0;
|
||||||
endtask : wait_for_halt
|
endtask : wait_for_halt
|
||||||
|
|
||||||
// Start CPU and wait for it to halt
|
// Start CPU and wait for it to halt
|
||||||
@@ -107,7 +157,16 @@ class cpu_driver #(int DataSize=32, int AddrSize=14);
|
|||||||
// TODO: Assert an external halt request and wait, with a bound,
|
// TODO: Assert an external halt request and wait, with a bound,
|
||||||
// until ownership returns to the external port
|
// until ownership returns to the external port
|
||||||
|
|
||||||
$fatal(1, "TODO: implement cpu_driver.halt_cpu_now");
|
cpuVif.cb.halt_cpu <= 1;
|
||||||
|
@(cpuVif.cb);
|
||||||
|
cpuVif.cb.halt_cpu <= 0;
|
||||||
|
|
||||||
|
repeat (xbar_timeout) begin
|
||||||
|
@(cpuVif.cb);
|
||||||
|
if (!cpuVif.cb.cpu_active) return;
|
||||||
|
end
|
||||||
|
|
||||||
|
timeouts++;
|
||||||
endtask : halt_cpu_now
|
endtask : halt_cpu_now
|
||||||
|
|
||||||
// Main driver loop. Keeps taking transactions from the mailbox and
|
// Main driver loop. Keeps taking transactions from the mailbox and
|
||||||
|
|||||||
+950
-54
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user