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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [rtl/] [lxp32_ram256x32.vhd] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 ring0_mipt
---------------------------------------------------------------------
2
-- Generic dual-port memory
3
--
4
-- Part of the LXP32 CPU
5
--
6
-- Copyright (c) 2016 by Alex I. Kuznetsov
7
--
8
-- Portable description of a dual-port memory block with one write
9
-- port. Major FPGA synthesis tools can infer on-chip block RAM
10
-- from this description. Can be replaced with a library component
11
-- wrapper if needed.
12
---------------------------------------------------------------------
13
 
14
library ieee;
15
use ieee.std_logic_1164.all;
16
use ieee.numeric_std.all;
17
 
18
entity lxp32_ram256x32 is
19
        port(
20
                wclk_i: in std_logic;
21
                we_i: in std_logic;
22
                waddr_i: in std_logic_vector(7 downto 0);
23
                wdata_i: in std_logic_vector(31 downto 0);
24
 
25
                rclk_i: in std_logic;
26
                re_i: in std_logic;
27
                raddr_i: in std_logic_vector(7 downto 0);
28
                rdata_o: out std_logic_vector(31 downto 0)
29
        );
30
end entity;
31
 
32
architecture rtl of lxp32_ram256x32 is
33
 
34
type ram_type is array(255 downto 0) of std_logic_vector(31 downto 0);
35
signal ram: ram_type:=(others=>(others=>'0')); -- zero-initialize for SRAM-based FPGAs
36
 
37
attribute syn_ramstyle: string;
38
attribute syn_ramstyle of ram: signal is "block_ram,no_rw_check";
39
attribute ram_style: string; -- for Xilinx
40
attribute ram_style of ram: signal is "block";
41
 
42
begin
43
 
44
-- Write port
45
 
46
process (wclk_i) is
47
begin
48
        if rising_edge(wclk_i) then
49
                if we_i='1' then
50
                        ram(to_integer(unsigned(waddr_i)))<=wdata_i;
51
                end if;
52
        end if;
53
end process;
54
 
55
-- Read port
56
 
57
process (rclk_i) is
58
begin
59
        if rising_edge(rclk_i) then
60
                if re_i='1' then
61
                        rdata_o<=ram(to_integer(to_01(unsigned(raddr_i))));
62
                end if;
63
        end if;
64
end process;
65
 
66
end architecture;

powered by: WebSVN 2.1.0

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