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

module instruction_decode_tb;

logic [15:0] tst_instruction, tst_result;
logic tst_destination_A, tst_destination_D, tst_destination_pA;
logic [15:0] tst_data_A, tst_data_D, tst_data_pA;
logic tst_should_jump;

instruction_decode uut (
  .instruction_in(tst_instruction),
  .dst_A_out(tst_destination_A),
  .dst_D_out(tst_destination_D),
  .dst_pA_out(tst_destination_pA),
  .A_in(tst_data_A),
  .D_in(tst_data_D),
  .pA_in(tst_data_pA),
  .result_out(tst_result),
  .do_jump_out(tst_should_jump)
);

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

`define TB_CHECK(result, expected) assert(result == expected) else $error("Expected %x, got %x", expected, result);

initial begin
  #1
  tst_instruction = 0;
  tst_data_A = 0;
  tst_data_D = 0;
  tst_data_pA = 0;

  #1
  `TB_CHECK(tst_result, 0);
  `TB_CHECK(tst_destination_A, 1);
  `TB_CHECK(tst_destination_D, 0);
  `TB_CHECK(tst_destination_pA, 0);
  `TB_CHECK(tst_should_jump, 0);
  #1
  $finish();
end

endmodule