summaryrefslogtreecommitdiff
path: root/nandgame/arith_unit_tb.sv
blob: 917a113d6c1a1b34c82f61eb65d12e77d2e0625c (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
`timescale 1us/1us

`include "nandgame_types.v"

module  arith_unit_tb;

logic [15:0] in1;
logic [15:0] in2;
ArithCode opcode;
logic [15:0] result;

 arith_unit uut (
  .X(in1),
  .Y(in2),
  .operation(opcode),
  .RES(result)
);

string filename;
initial begin
`ifdef DUMP_FILE_NAME
  filename=`DUMP_FILE_NAME;
`else
  filename=" arith_unit.lxt2";
`endif
  $dumpfile(filename); $dumpvars();

end

initial begin
  in1 = 13;
  in2 = 17;
  opcode = ARITH_PLUS;
  #1
  assert(result == 30);
  #1
  in1 = 12;
  in2 = 4;
  opcode = ARITH_MINUS;
  #1
  assert(result == 8);
  #1
  in1 = 12;
  in2 = 13;
  opcode = ARITH_MINUS;
  #1
  assert(result == 16'hffff);
  #1
  in1 = 13;
  in2 = 17;
  opcode = ARITH_INC;
  #1
  assert(result == 14);
  #1
  in1 = 13;
  in2 = 17;
  opcode = ARITH_DEC;
  #1
  assert(result == 12);
  #1
  in1 = 0;
  in2 = 17;
  opcode = ARITH_DEC;
  #1
  assert(result == 16'hffff);
  #1
  $finish();
end

endmodule