~ruther/verilog-riscv-semestral-project

ref: 79c7be5c1c8ae2aea07f48d32abca650d24e8045 verilog-riscv-semestral-project/testbench/tb_register_file.sv -rw-r--r-- 837 bytes
79c7be5c — Rutherther chore: remove unnecessary executable flags 1 year, 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module tb_register_file();

  reg clk;
  reg [4:0] a1, a2, a3;

  wire [31:0] rd1, rd2;

  reg         we3;
  reg [31:0]  wd3;

  register_file uut(
    .clk(clk),
    .a1(a1),
    .a2(a2),
    .a3(a3),
    .we3(we3),
    .wd3(wd3),
    .rd1(rd1),
    .rd2(rd2)
  );

  initial begin
    clk = 0;
    forever #5 clk = ~clk;
  end

  initial begin
    $dumpfile("waves/tb_register_file.vcd");
    $dumpvars;
    a1 = 0;
    a2 = 0;
    a3 = 0;

    #10 // r0 is always 0, even on write
      a3 = 0;
    wd3 = 200;
    we3 = 1;

    #10 // r1 is writable
      a3 = 1;
    a1 = 1;

    #10 // r2 is writable
      a3 = 2;
    a2 = 2;

    #10 // r1 is overridable
      a3 = 1;
    wd3 = 100;

    #10 // r1 is not overriden if not we
      wd3 = 150;
      we3 = 0;

    #10
      a2 = 1;
    a1 = 2;

    #10 $finish;
  end


endmodule