OpenCores
URL https://opencores.org/ocsvn/mips_16/mips_16/trunk

Subversion Repositories mips_16

[/] [mips_16/] [trunk/] [rtl/] [data_mem.v] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 Doyya
/***************************************************
2
 * Module: data_mem
3
 * Project: mips_16
4
 * Author: fzy
5
 * Description:
6
 *     a ram implementation, 16bit word width, address width can be configured be user
7
 *              further will be able to read external memory
8
 *
9
 * Revise history:
10
 *
11
 ***************************************************/
12
`timescale 1ns/1ps
13
`include "mips_16_defs.v"
14
module data_mem
15
(
16
        input                                   clk,
17
 
18
        // address input, shared by read and write port
19
        input   [15:0]                   mem_access_addr,
20
 
21
        // write port
22
        input   [15:0]                   mem_write_data,
23
        input                                   mem_write_en,
24
        // read port
25
        output  [15:0]                   mem_read_data
26
 
27
);
28
 
29
 
30
        reg [15:0] ram [(2**`DATA_MEM_ADDR_WIDTH)-1:0];
31
 
32
        wire [`DATA_MEM_ADDR_WIDTH-1 : 0] ram_addr = mem_access_addr[`DATA_MEM_ADDR_WIDTH-1 : 0];
33
 
34
        always @(posedge clk)
35
                if (mem_write_en)
36
                        ram[ram_addr] <= mem_write_data;
37
 
38
        assign mem_read_data = ram[ram_addr];
39
 
40
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.