feat: complete Palladium Z2 demo for both SA and ICE emulation flows
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// tb_z2_demo_ice.v -- Local-only bench for the ICE top.
|
||||
// In real ICE mode there is no testbench at all: clk/rst come from the target
|
||||
// or emulator clock setup and the result is the PASS/FAIL LEDs. This bench
|
||||
// only supplies clock/reset locally and watches the LEDs, so the stimulus
|
||||
// FSM itself can be verified before an ICE compile.
|
||||
// -----------------------------------------------------------------------------
|
||||
`timescale 1ns/1ps
|
||||
|
||||
module tb_z2_demo_ice;
|
||||
reg clk;
|
||||
reg rst_n;
|
||||
wire [7:0] led_gpio;
|
||||
wire led_irq;
|
||||
wire led_done;
|
||||
wire led_pass;
|
||||
wire led_fail;
|
||||
integer cycles;
|
||||
integer errors;
|
||||
|
||||
z2_demo_ice_top top (
|
||||
.clk_in (clk),
|
||||
.rst_n_in (rst_n),
|
||||
.led_gpio (led_gpio),
|
||||
.led_irq (led_irq),
|
||||
.led_done (led_done),
|
||||
.led_pass (led_pass),
|
||||
.led_fail (led_fail)
|
||||
);
|
||||
|
||||
initial clk = 1'b0;
|
||||
always #5 clk = ~clk;
|
||||
|
||||
initial begin
|
||||
$dumpfile("ice/sim_local/z2_demo_ice.vcd");
|
||||
$dumpvars(0, tb_z2_demo_ice);
|
||||
errors = 0;
|
||||
rst_n = 1'b0;
|
||||
repeat (4) @(negedge clk);
|
||||
rst_n = 1'b1;
|
||||
|
||||
// wait for the hardware sequence to finish (guard: 1000 cycles)
|
||||
cycles = 0;
|
||||
while (!led_done && cycles < 1000) begin
|
||||
@(negedge clk);
|
||||
cycles = cycles + 1;
|
||||
end
|
||||
|
||||
if (!led_done) begin
|
||||
$display("CHECK FAIL : ICE sequence did not finish in 1000 cycles");
|
||||
errors = errors + 1;
|
||||
end else begin
|
||||
$display("CHECK OK : ICE sequence finished in %0d cycles", cycles);
|
||||
end
|
||||
if (led_pass && !led_fail)
|
||||
$display("CHECK OK : led_pass=1 led_fail=0");
|
||||
else begin
|
||||
$display("CHECK FAIL : led_pass=%b led_fail=%b", led_pass, led_fail);
|
||||
errors = errors + 1;
|
||||
end
|
||||
if (led_gpio === 8'h02)
|
||||
$display("CHECK OK : led_gpio pattern = 0x02 (rotated once)");
|
||||
else begin
|
||||
$display("CHECK FAIL : led_gpio = 0x%02h, expected 0x02", led_gpio);
|
||||
errors = errors + 1;
|
||||
end
|
||||
|
||||
if (errors == 0) $display("ICE LOCAL TEST PASSED");
|
||||
else $display("ICE LOCAL TEST FAILED (%0d)", errors);
|
||||
$finish;
|
||||
end
|
||||
endmodule
|
||||
Reference in New Issue
Block a user