-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcondlogic.v
53 lines (53 loc) · 895 Bytes
/
condlogic.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
`include "flopenr.v"
`include "condcheck.v"
module condlogic (
clk,
reset,
Cond,
ALUFlags,
FlagW,
PCS,
RegW,
MemW,
PCSrc,
RegWrite,
MemWrite
);
input wire clk;
input wire reset;
input wire [3:0] Cond;
input wire [3:0] ALUFlags;
input wire [1:0] FlagW;
input wire PCS;
input wire RegW;
input wire MemW;
output wire PCSrc;
output wire RegWrite;
output wire MemWrite;
wire [1:0] FlagWrite;
wire [3:0] Flags;
wire CondEx;
flopenr #(2) flagreg1(
.clk(clk),
.reset(reset),
.en(FlagWrite[1]),
.d(ALUFlags[3:2]),
.q(Flags[3:2])
);
flopenr #(2) flagreg0(
.clk(clk),
.reset(reset),
.en(FlagWrite[0]),
.d(ALUFlags[1:0]),
.q(Flags[1:0])
);
condcheck cc(
.Cond(Cond),
.Flags(Flags),
.CondEx(CondEx)
);
assign FlagWrite = FlagW & {2 {CondEx}};
assign RegWrite = RegW & CondEx;
assign MemWrite = MemW & CondEx;
assign PCSrc = PCS & CondEx;
endmodule