summaryrefslogtreecommitdiff
path: root/nandgame/logic_unit_tb.sv
blob: be5366ef78760b58561eadaa113dc22630aa2e03 (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
`timescale 1us/1us

//`include "nandgame_types.v"
module logic_unit_tb (
);

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

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

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

end

initial begin
  in1 = 16'b1010;
  in2 = 16'b1100;
  opcode = LOGIC_AND;
  #1
  assert(result == 16'b1000);
  #1
  in1 = 16'b1010;
  in2 = 16'b1100;
  opcode = LOGIC_OR;
  #1
  assert(result == 16'b1110);
  #1
  in1 = 16'b1010;
  in2 = 16'b1100;
  opcode = LOGIC_XOR;
  #1
  assert(result == 16'b0110);
  #1
  in1 = 16'b1010101010101010;
  opcode = LOGIC_NEGT;
  #1
  assert(result == 16'b0101010101010101);
  #1
  $finish();
end

endmodule