-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCtrlSgnl.sv
75 lines (54 loc) · 1.86 KB
/
CtrlSgnl.sv
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
/*
Takes in instruction OP code from instruction memory and determines
the control signals. 0-9 in binary represents the 10 instructions in order
*/
`timescale 1ns/10ps
module CtrlSgnl (instruction, OPOut);
input logic [31:0] instruction;
output logic [3:0] OPOut;
logic [10:0] OpCode;
assign OpCode = instruction[31:21];
always_comb begin
casex(OpCode)
// ADDI Instruction
11'b1001000100x : OPOut = 4'b0000;
// ADDS Instruction
11'b10101011000 : OPOut = 4'b0001;
// B. LT Instruction
11'b01010100xxx : OPOut = 4'b0010;
// B Instruction
11'b000101xxxxx : OPOut = 4'b0011;
// BL Instruction
11'b100101xxxxx : OPOut = 4'b0100;
// BR Instruction
11'b11010110000 : OPOut = 4'b0101;
// CBZ Instruction
11'b10110100xxx : OPOut = 4'b0110;
// LDUR Instruction
11'b11111000010 : OPOut = 4'b0111;
// STUR Instruction
11'b11111000000 : OPOut = 4'b1000;
// SUBS Instruction
11'b11101011000 : OPOut = 4'b1001;
default : OPOut = 4'bXXXX;
endcase
end
endmodule
module CtrlSgnl_testbench();
logic [31:0] instruction;
logic [3:0] OPOut;
CtrlSgnl dut (instruction, OPOut);
initial begin
instruction <= 32'b10010001000000000000000000000000; #10
instruction <= 32'b10101011000000000000000000000000; #10
instruction <= 32'b01010100000000000000000000000000; #10
instruction <= 32'b00010100000000000000000000000000; #10
instruction <= 32'b10010100000000000000000000000000; #10
instruction <= 32'b11010110000000000000000000000000; #10
instruction <= 32'b10110100000000000000000000000000; #10
instruction <= 32'b11111000010000000000000000000000; #10
instruction <= 32'b11111000000000000000000000000000; #10
instruction <= 32'b11101011000000000000000000000000; #10
$Stop;
end
endmodule