File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ // src/branch.veryl
2+
3+ module Branch (
4+ i_a : input logic<32>,
5+ i_b : input logic<32>,
6+ o_eq: output logic ,
7+ ) {
8+ assign o_eq = i_a == i_b;
9+ }
Original file line number Diff line number Diff line change 1+ // src/pc_plus4.veryl
2+
3+ module Pc (
4+ i_clk : input clock ,
5+ i_reset: input reset_async_high ,
6+ i_pc : input logic <32>,
7+ o_pc : output logic <32>,
8+ ) {
9+ var pc: logic<32>;
10+
11+ always_ff (i_clk, i_reset) {
12+ if_reset {
13+ pc = 0;
14+ } else {
15+ pc = i_pc;
16+ }
17+
18+ }
19+ assign o_pc = pc;
20+ }
21+
22+ #[test(pc)]
23+ embed (inline) sv{{{
24+ module test;
25+ logic clk;
26+ logic reset;
27+ logic [31:0] i_pc;
28+ logic [31:0] o_pc;
29+
30+ assign i_pc = o_pc + 4; // native System Verilog adder
31+
32+ vips_Pc pc (clk, reset, i_pc, o_pc);
33+
34+ initial begin
35+ reset = 1;
36+ assert (o_pc == 0) else $error("reset");
37+
38+ clk = 0; #10 clk = 1; #10;
39+ assert (o_pc == 0) else $error("0");
40+
41+ reset = 0;
42+ clk = 0; #10 clk = 1; #10;
43+ assert (o_pc == 4) else $error("4");
44+
45+ clk = 0; #10 clk = 1; #10;
46+ assert (o_pc == 8) else $error("8");
47+
48+ clk = 0; #10 clk = 1; #10;
49+ assert (o_pc == 12) else $error("12");
50+
51+ $finish;
52+ end
53+ endmodule
54+ }}}
You can’t perform that action at this time.
0 commit comments