summaryrefslogtreecommitdiff
path: root/nandgame/counter_tb.sv
blob: a7fab85e37caa2a24fb9c514bfb74179fc033b39 (plain)
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
`timescale 1us/1us

module counter_tb;

logic clk_i, store;
logic [15:0] in, res;

counter uut (
  .cl(clk_i),
  .X(in),
  .count(res),
  .st(store)
);

string filename;
initial begin
`ifdef DUMP_FILE_NAME
  filename=`DUMP_FILE_NAME;
`else
  filename="counter.lxt2";
`endif
  $dumpfile(filename); $dumpvars();
  clk_i = 0;
  store = 0;
  in = 0;
end

always #10 clk_i = ~clk_i;

initial begin
  #200
  @(posedge clk_i);
  store = 1;
  in = 16'd834;
  repeat(3) begin
    @(posedge clk_i);
    assert (res == 834)
    else   $error("Expected 834, got %d", res);
  end
  store = 0;
  @(posedge clk_i);
  assert (res == 835)
  else   $error("Expected 835, got %d", res);
  #30

  $finish();
end

endmodule