-
Notifications
You must be signed in to change notification settings - Fork 0
/
j_br_control.v
55 lines (51 loc) · 1.16 KB
/
j_br_control.v
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
module j_br_control(out_pc, enable, pc4, mem_out, reg_s, j_diraddr, status0, status1, status2, n, z, v);
input [31:0] mem_out, pc4, reg_s;
input[25:0] j_diraddr;
input status0, status1, status2, n, z, v;
output [31:0] out_pc;
output enable;
reg [31:0] out_pc;
reg enable;
wire [2:0] status_check;
assign status_check = {status2, status1, status0};
always @ (*)
begin
case(status_check)
3'b000:
begin
out_pc = pc4;
end
3'b001: // bmn instruction is active
begin
out_pc = n ? mem_out : pc4;
enable = 1;
end
3'b010: // brz instruction is active
begin
out_pc = z ? reg_s : pc4;
enable = 1;
end
3'b011: // bz instruction is active
begin
out_pc= z ? j_diraddr : pc4;
enable = 1;
end
3'b100: // jmor instruction is active
begin
out_pc = mem_out;
enable = 1;
end
3'b101: // jalm instruction is active
begin
out_pc = mem_out;
enable = 1;
end
3'b110: // jspal instruction is active
begin
out_pc = mem_out;
enable = 1;
end
default: out_pc = pc4;
endcase
end
endmodule