-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpr_id_ex.v
74 lines (67 loc) · 1.72 KB
/
pr_id_ex.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
65
66
67
68
69
70
71
72
73
74
// pipelined register for ID/EX stage
`timescale 1ns / 1ps
module pr_id_ex(
input clk,
// this can be modified to one 11-bit control signal, but I'm running out of time...
input RegDst_in, // EX
input Jump_in, // MEM
input Branch_in, // MEM
input Bne_in, // MEM
input MemRead_in, // MEM
input MemtoReg_in, // WB
input [1:0] ALUOp_in, // EX
input MemWrite_in, // MEM
input ALUSrc_in, // EX
input RegWrite_in, // WB
output reg RegDst,
output reg Jump,
output reg Branch,
output reg Bne, // 1 indicates bne
output reg MemRead,
output reg MemtoReg,
output reg [1:0] ALUOp,
output reg MemWrite,
output reg ALUSrc,
output reg RegWrite,
input [31:0] nextPc_in, // from pc
output reg [31:0] nextPc,
input [31:0] ReadData1_in, // from reg
input [31:0] ReadData2_in,
input [5:0] funcode_in,
output reg [31:0] ReadData1,
output reg [31:0] ReadData2,
output reg [5:0] funcode,
input [31:0] instru_in, // raw instruction from IF/ID-reg
output reg [31:0] instru
);
initial begin
RegDst = 0;
Jump = 0;
Branch = 0;
Bne = 0;
MemRead = 0;
MemtoReg = 0;
ALUOp = 2'b00;
MemWrite = 0;
ALUSrc = 0;
RegWrite = 0;
end
always @(posedge clk) begin
RegDst = RegDst_in;
Jump = Jump_in;
Branch = Branch_in;
Bne = Bne_in;
MemRead = MemRead_in;
MemtoReg = MemtoReg_in;
ALUOp = ALUOp_in;
MemWrite = MemWrite_in;
ALUSrc = ALUSrc_in;
RegWrite = RegWrite_in;
nextPc = nextPc_in;
ReadData1 = ReadData1_in;
ReadData2 = ReadData2_in;
funcode = funcode_in;
instru = instru_in;
// $display("funcode @ id/ex: 0x%H",funcode);
end
endmodule