-
Notifications
You must be signed in to change notification settings - Fork 0
/
Memory8.v
50 lines (44 loc) · 1.05 KB
/
Memory8.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 18:09:10 11/09/2017
// Design Name:
// Module Name: Memory8
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
(*ram_style ="block"*)
module Memory8 (input clk, input rst, input[7:0] data_in,input[4:0] addr,
input memWrite,input memRead, output reg[7:0] out);
reg [7:0] dataMem [31:0];
integer i;
always@(posedge clk, posedge rst)
begin
if(rst)
begin
for(i = 0; i< 32 ; i = i + 1)
dataMem[i] <= 8'd0;
end
else if(memWrite)
dataMem[addr] <= data_in;
end
always@ (memRead, addr)
begin
if(memRead) begin
out <= dataMem[addr];
end
else
begin end
end
endmodule