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

Subversion Repositories lxp32

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 9 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
                clk_i: in std_logic;
21
 
22
                we_i: in std_logic;
23
                waddr_i: in std_logic_vector(7 downto 0);
24
                wdata_i: in std_logic_vector(31 downto 0);
25
 
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 "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 (clk_i) is
47
begin
48
        if rising_edge(clk_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 (clk_i) is
58
begin
59
        if rising_edge(clk_i) then
60
                if re_i='1' then
61
                        if is_x(raddr_i) then -- to avoid numeric_std warnings during simulation
62
                                rdata_o<=(others=>'X');
63
                        else
64
                                rdata_o<=ram(to_integer(unsigned(raddr_i)));
65
                        end if;
66
                end if;
67
        end if;
68
end process;
69
 
70
end architecture;

powered by: WebSVN 2.1.0

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