-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.sv
More file actions
38 lines (33 loc) · 1.61 KB
/
controller.sv
File metadata and controls
38 lines (33 loc) · 1.61 KB
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
module controller(input clk, reset,
input logic [6:0] op,
input logic [2:0] funct3,
input logic funct7b5,
input logic Zero,
output logic [1:0] ImSrc,
output logic [2:0] ALUControl,
output logic RegWrite,
output logic MemWrite,
output logic IRWrite,
output logic [1:0] ALUSrcA,
output logic [1:0] ALUSrcB,
output logic AdrSrc,
output logic [1:0] ResultSrc,
output logic PCWrite,
input logic branch_lesser
);
logic [1:0] ALUOp;
logic Branch;
logic PCUpdate;
ImmSrc immsource(.op(op), .ImmSrc(ImSrc));
aludec ad(.opb5(op[5]), .funct3(funct3), .funct7b5(funct7b5), .ALUOp(ALUOp), .ALUControl(ALUControl));
mainfsm md(.clk(clk), .reset(reset), .op(op), .RegWrite(RegWrite), .MemWrite(MemWrite), .IRWrite(IRWrite), .Branch(Branch), .PCUpdate(PCUpdate),
.ALUSrcA(ALUSrcA), .ALUSrcB(ALUSrcB), .AdrSrc(AdrSrc), .ResultSrc(ResultSrc), .ALUOp(ALUOp));
assign PCWrite = (Branch & (funct3 == 3'b000) & Zero) | // BEQ
(Branch & (funct3 == 3'b100) & branch_lesser) | // BLT
(Branch & (funct3 == 3'b101) & ~branch_lesser) | // BGE
PCUpdate;
// assign PCWrite = (Branch & (Zero ^ funct3[0])) | PCUpdate;
// initial begin
// $monitor("Controller: At time %t, PCWrite = %0b, PCUpdate = %0b", $time, PCWrite, PCUpdate);
// end
endmodule