-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWB.v
60 lines (49 loc) · 1.38 KB
/
WB.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
`include "lib/defines.vh"
module WB(
input wire clk,
input wire rst,
// input wire flush,
input wire [`StallBus-1:0] stall,
input wire [`MEM_TO_WB_WD-1:0] mem_to_wb_bus,
output wire [`WB_TO_RF_WD-1:0] wb_to_rf_bus,
output wire [31:0] debug_wb_pc,
output wire [3:0] debug_wb_rf_wen,
output wire [4:0] debug_wb_rf_wnum,
output wire [31:0] debug_wb_rf_wdata
);
reg [`MEM_TO_WB_WD-1:0] mem_to_wb_bus_r;
always @ (posedge clk) begin
if (rst) begin
mem_to_wb_bus_r <= `MEM_TO_WB_WD'b0;
end
// else if (flush) begin
// mem_to_wb_bus_r <= `MEM_TO_WB_WD'b0;
// end
else if (stall[4]==`Stop && stall[5]==`NoStop) begin
mem_to_wb_bus_r <= `MEM_TO_WB_WD'b0;
end
else if (stall[4]==`NoStop) begin
mem_to_wb_bus_r <= mem_to_wb_bus;
end
end
wire [31:0] wb_pc;
wire rf_we;
wire [4:0] rf_waddr;
wire [31:0] rf_wdata;
assign {
wb_pc,
rf_we,
rf_waddr,
rf_wdata
} = mem_to_wb_bus_r;
// assign wb_to_rf_bus = mem_to_wb_bus_r[`WB_TO_RF_WD-1:0];
assign wb_to_rf_bus = {
rf_we,
rf_waddr,
rf_wdata
};
assign debug_wb_pc = wb_pc;
assign debug_wb_rf_wen = {4{rf_we}};
assign debug_wb_rf_wnum = rf_waddr;
assign debug_wb_rf_wdata = rf_wdata;
endmodule