-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_mem.v
50 lines (44 loc) · 1.25 KB
/
data_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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 24.03.2023 22:55:59
// Design Name:
// Module Name: data_mem
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module data_mem(mem_addr,write_data,read_data,memRead,memWrite,reset);
output reg [31:0]read_data;
input [31:0]write_data,mem_addr;
input memWrite,memRead,reset;
reg [7:0] mem [23:0];
always@(negedge reset)
begin
if(reset==0)
begin
mem[3] = 0; mem[2] = 0; mem[1] = 0; mem[0] = 35;
mem[7] = 0; mem[6] = 0; mem[5] = 0; mem[4] = 14;
mem[11] = 1; mem[10] = 1; mem[9] = 1; mem[8] = 1;
mem[15] = 1; mem[14] = 1; mem[13] = 1; mem[12] = 1;
mem[19] = 1; mem[18] = 1; mem[17] = 1; mem[16] = 1;
end
end
always@(mem_addr,memRead,memWrite)
begin
if (memRead == 1 && mem_addr[1:0]==2'b00)
read_data = {mem[mem_addr+3],mem[mem_addr+2],mem[mem_addr+1],mem[mem_addr]};
else if (memWrite == 1 && mem_addr[1:0]==2'b00)
{mem[mem_addr+3],mem[mem_addr+2],mem[mem_addr+1],mem[mem_addr]} = write_data;
end
endmodule