-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmem.v
68 lines (59 loc) · 1.83 KB
/
mem.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
`include "defines.v"
module mem(input wire rst,
input wire [`RegAddrBus] wd_i,
input wire wreg_i,
input wire [`RegBus] wdata_i,
input wire [`AluOpBus] aluop_i,
input wire [`RegBus] mem_addr_i,
input wire [`RegBus] reg2_i,
input wire [`RegBus] mem_data_i,
output reg [`RegAddrBus] wd_o,
output reg wreg_o,
output reg [`RegBus] wdata_o,
output reg [`RegBus] mem_addr_o,
output wire mem_we_o,
output reg [3:0] mem_sel_o,
output reg [`RegBus] mem_data_o,
output reg mem_ce_o);
reg mem_we;
assign mem_we_o = mem_we;
always @(*) begin
if (rst == `RstEnable) begin
wd_o <= `NOPRegAddr;
wreg_o <= `WriteDisable;
wdata_o <= `ZeroWord;
mem_addr_o <= `ZeroWord;
mem_we <= `WriteDisable;
mem_sel_o <= 4'b0000;
mem_data_o <= `ZeroWord;
mem_ce_o <= `ChipDisable;
end
else begin
wd_o <= wd_i;
wreg_o <= wreg_i;
wdata_o <= wdata_i;
mem_we <= `WriteDisable;
mem_addr_o <= `ZeroWord;
mem_sel_o <= 4'b1111;
mem_ce_o <= `ChipDisable;
case (aluop_i)
`EXE_LW_OP: begin
mem_addr_o <= mem_addr_i;
mem_we <= `WriteDisable;
wdata_o <= mem_data_i;
mem_sel_o <= 4'b1111;
mem_ce_o <= `ChipEnable;
end
`EXE_SW_OP: begin
mem_addr_o <= mem_addr_i;
mem_we <= `WriteEnable;
mem_data_o <= reg2_i;
mem_sel_o <= 4'b1111;
mem_ce_o <= `ChipEnable;
end
default: begin
end
endcase
end //if
end //always
endmodule