-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnp_selb.v
65 lines (56 loc) · 994 Bytes
/
np_selb.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
56
57
58
59
60
61
62
63
64
///*
`include "mux.v"
`include "and_gate.v"
`include "nand_gate.v"
`include "nor_gate.v"
`include "xor_gate.v"
`include "or_gate.v"
//*/
module np_sel(zero, res_msb, branch, sel);
input zero,res_msb;//zero signal and MSB of the result from the ALU
input [2:0] branch;//take the 3 LSB of the opcode
output sel;//PC+4 or Branch Immediate + PC + 4
wire b1,b2,b3;
wire zerohigh, zerolow, greater_than;
mux zero_highr(
.sel(zero),
.src0(1'b0),
.src1(1'b1),
.z(zerohigh)
);
mux zero_lowr(
.sel(zero),
.src0(1'b1),
.src1(1'b0),
.z(zerolow)
);
mux greater_thanr(
.sel(res_msb),
.src0(1'b1),
.src1(1'b0),
.z(greater_than)
);
mux beq_bne(
.sel(branch[0]),
.src0(zerohigh),//beq
.src1(zerolow),//bne
.z(b1)
);
and_gate bgtz_gtr(
.x(b1),
.y(greater_than),
.z(b2)
);
mux bgt(
.sel(branch[1]),
.src0(b1),//bne/beq
.src1(b2),//bgtz
.z(b3)
);
mux selc(
.sel(branch[2]),
.src0(1'b0),
.src1(b3),
.z(sel)
);
endmodule