-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemory.v
More file actions
49 lines (44 loc) · 1.29 KB
/
Copy pathMemory.v
File metadata and controls
49 lines (44 loc) · 1.29 KB
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
module Memory (clk,rst_n,regwriteM,resultsrcM,memwriteM,aluresultM,writedataM,RDM,pcincr4M,pcincr4W,RDW,readdataW,
aluresultW,resultsrcW,regwriteW);
//declaring the ports
input clk,rst_n,regwriteM,resultsrcM,memwriteM;
input [31:0] aluresultM,writedataM,pcincr4M;
input [4:0] RDM;
output regwriteW,resultsrcW;
output [31:0] aluresultW,readdataW,pcincr4W;
output [4:0] RDW;
//declaring regs and wires
reg regwriteWr,resultsrcWr;
reg [31:0] aluresultWr,readdataWr,pcincr4Wr;
reg [4:0] RDWr;
wire [31:0] readdataM;
datamem datamemoryM (.RD(readdataM),.clk(clk),.rst_n(rst_n),.WE(memwriteM),.A(aluresultM),.WD(writedataM));
//the memory cycle
always @(posedge clk or negedge rst_n) begin
if(!rst_n)begin
readdataWr<=0;
resultsrcWr<=0;
aluresultWr<=0;
readdataWr<=0;
pcincr4Wr<=0;
RDWr<=0;
regwriteWr<=0;
end
else begin
readdataWr<=readdataM;
resultsrcWr<=resultsrcM;
aluresultWr<=aluresultM;
readdataWr<=readdataM;
pcincr4Wr<=pcincr4M;
RDWr<=RDM;
regwriteWr<=regwriteM;
end
end
assign readdataW=readdataWr;
assign resultsrcW=resultsrcWr;
assign aluresultW=aluresultWr;
assign readdataW=readdataWr;
assign pcincr4W=pcincr4Wr;
assign RDW=RDWr;
assign regwriteW=regwriteWr;
endmodule //Memory