-
Notifications
You must be signed in to change notification settings - Fork 1
/
dataPath.sv
47 lines (37 loc) · 1.44 KB
/
dataPath.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
module dataPath (input logic clk, reset,
input logic [2:0] ImmSrc,
input logic [3:0] ALUControl,
input logic [1:0] ResultSrc,
input logic IRWrite,
input logic RegWrite,
input logic [1:0] ALUSrcA, ALUSrcB,
input logic AdrSrc,
input logic PCWrite,
input logic [31:0] ReadData,
output logic Zero, cout, overflow, sign,
output logic [31:0] Adr,
output logic [31:0] WriteData,
output logic [31:0] instr);
logic [31:0] Result , ALUOut, ALUResult;
logic [31:0] RD1, RD2, A , SrcA, SrcB, Data;
logic [31:0] ImmExt;
logic [31:0] PC, OldPC;
//pc
flopenr #(32) pcFlop(clk, reset, PCWrite, Result, PC);
//regFile
regFile rf(clk, RegWrite, instr[19:15], instr[24:20], instr[11:7], Result, RD1, RD2);
extend ext(instr[31:7], ImmSrc, ImmExt);
flopr #(32) regF( clk, reset, RD1, A);
flopr #(32) regF_2( clk, reset, RD2, WriteData);
//alu
mux3 #(32) srcAmux(PC, OldPC, A, ALUSrcA, SrcA);
mux3 #(32) srcBmux(WriteData, ImmExt, 32'd4, ALUSrcB, SrcB);
alu alu(SrcA, SrcB, ALUControl, ALUResult, Zero, cout, overflow, sign);
flopr #(32) aluReg (clk, reset, ALUResult, ALUOut);
mux4 #(32) resultMux(ALUOut, Data, ALUResult, ImmExt, ResultSrc, Result );
//mem
mux2 #(32) adrMux(PC, Result, AdrSrc, Adr);
flopenr #(32) memFlop1(clk, reset, IRWrite, PC, OldPC);
flopenr #(32) memFlop2(clk, reset, IRWrite, ReadData, instr);
flopr #(32) memDataFlop(clk, reset, ReadData, Data);
endmodule