summaryrefslogtreecommitdiff
path: root/regFile_tb.v
blob: 59c2eddc4b62e86de160a556ea9edf5e414fb8aa (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
71
72
73
74
75
76
77
78
79
80
81
82
83
`timescale 1 ns / 100 ps

module regFile_tb ();

	reg clk;
	reg [2:0] regA;
	reg [2:0] regB;
	reg [2:0] regDest;
	reg [15:0] dataIn;
	reg we, hb, lb;
	wire [15:0] dataA;
	wire [15:0] dataB;

	initial begin
		clk = 1'b0;

		regA = 3'h0;
		regB = 3'h0;
		regDest = 3'h0;
		we = 1'b0;
		hb = 1'b0;
		lb = 1'b0;
		dataIn = 16'h0;

		#2
		regA = 3'h1;
		regDest = 3'h1;
		dataIn = 16'hDEAD;
		we = 1'b1;
		hb = 1'b1;
		lb = 1'b1;

		#2
		regB = 3'h1;
		regA = 3'h2;
		dataIn = 16'hBEEF;
		lb = 1'b0;

		#2
		lb = 1'b1;

		#2
		regDest = 3'h2;
		hb = 1'b0;
		dataIn = 16'h9876;

		#2
		hb = 1'b1;
		lb = 1'b0;
		dataIn = 16'h2345;

		#2
		regB = 3'h7;
		regDest = 3'h7;
		lb = 1'b0;
		hb = 1'b0;
		we = 1'b1;
		dataIn = 16'hFFCC;

		#2
		lb = 1'b1;
		hb = 1'b1;
		we = 1'b0;

		#5
		$stop;
	end

	always #1 clk = !clk;

	regFile regFile_inst (
		.clk(clk),
		.regA(regA),
		.regB(regB),
		.regDest(regDest),
		.dataIn(dataIn),
		.we(we),
		.hb(hb),
		.lb(lb),
		.dataA(dataA),
		.dataB(dataB)
	);
endmodule