-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMEMORY.v
47 lines (43 loc) · 1.04 KB
/
MEMORY.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
/* MEMORY.v */
/* MEMORY.v */
module MEMORY(
input wire [1:0] wb_ctlout,
input wire branch, memread, memwrite,
input wire zero,
input wire [31:0] alu_result, rdata2out,
input wire [4:0] five_bit_muxout,
output wire MEM_PCSrc,
output wire MEM_WB_regwrite, MEM_WB_memtoreg,
output wire [31:0] read_data, mem_alu_result,
output wire [4:0] mem_write_reg
);
// signals
wire [31:0] read_data_in;
// instantiations
AND AND_4(
// inputs
.membranch(branch),
.zero(zero),
// output
.PCSrc(MEM_PCSrc));
data_memory data_memory4(
//inputs
.addr(alu_result),
.write_data(rdata2out),
.memwrite(memwrite),
.memread(memread),
// output
.read_data(read_data_in));
mem_wb mem_wb4(
//inputs
.control_wb_in(wb_ctlout),
.read_data_in(read_data_in),
.alu_result_in(alu_result),
.write_reg_in(five_bit_muxout),
// outputs
.regwrite(MEM_WB_regwrite),
.memtoreg(MEM_WB_memtoreg),
.read_data(read_data),
.mem_alu_result(mem_alu_result),
.mem_write_reg(mem_write_reg));
endmodule // MEMORY