-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmem.v
49 lines (43 loc) · 1.18 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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 21:40:49 12/08/2018
// Design Name:
// Module Name: mem
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mem(
input clk,reset,
input [31:0] instrm,pcm,
input [31:0] aluoutm, tempwritedatam,
//forward
input frtm,
input [31:0] resultw,
output [31:0] readdatam,pcplus8m
);
wire memreadm,memwritem;
wire swm, shm, sbm;
wire [31:0] writedatam;
assign pcplus8m = pcm + 8;
ctrl ctrlm( .instr(instrm),
.memread(memreadm), .memwrite(memwritem),
.sw(swm), .sh(shm), .sb(sbm));
mux2 mfrtm(.a(tempwritedatam), .b(resultw), .s(frtm), .result(writedatam));
dmem dmem( .clk(clk), .reset(reset),
.memread(memreadm), .memwrite(memwritem),
.sw(swm), .sh(shm), .sb(sbm),
.addr(aluoutm), .writedata(writedatam), .pc(pcm),
.readdata(readdatam));
endmodule