1 |
7 |
nuxi1209 |
-------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- Copyright (C) 2013 Author and VariStream Studio --
|
4 |
|
|
-- Author : Yu Peng --
|
5 |
|
|
-- --
|
6 |
|
|
-- This source file may be used and distributed without --
|
7 |
|
|
-- restriction provided that this copyright statement is not --
|
8 |
|
|
-- removed from the file and that any derivative work contains --
|
9 |
|
|
-- the original copyright notice and the associated disclaimer. --
|
10 |
|
|
-- --
|
11 |
|
|
-- This source file is free software; you can redistribute it --
|
12 |
|
|
-- and/or modify it under the terms of the GNU Lesser General --
|
13 |
|
|
-- Public License as published by the Free Software Foundation; --
|
14 |
|
|
-- either version 2.1 of the License, or (at your option) any --
|
15 |
|
|
-- later version. --
|
16 |
|
|
-- --
|
17 |
|
|
-- This source is distributed in the hope that it will be --
|
18 |
|
|
-- useful, but WITHOUT ANY WARRANTY; without even the implied --
|
19 |
|
|
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR --
|
20 |
|
|
-- PURPOSE. See the GNU Lesser General Public License for more --
|
21 |
|
|
-- details. --
|
22 |
|
|
-- --
|
23 |
|
|
-- You should have received a copy of the GNU Lesser General --
|
24 |
|
|
-- Public License along with this source; if not, download it --
|
25 |
|
|
-- from http://www.opencores.org/lgpl.shtml --
|
26 |
|
|
-- --
|
27 |
|
|
-------------------------------------------------------------------
|
28 |
|
|
-- Simple dual-port RAM in read-first mode without output
|
29 |
|
|
-- register.
|
30 |
|
|
--
|
31 |
|
|
-- It only infers distribute RAM. So do not set big value to
|
32 |
|
|
-- gADDRESS_WIDTH Best value of gADDRESS_WIDTH for xilinx FPGA
|
33 |
|
|
-- is 5
|
34 |
|
|
-------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
library ieee;
|
37 |
|
|
use ieee.std_logic_1164.all;
|
38 |
|
|
use ieee.std_logic_unsigned.all;
|
39 |
|
|
|
40 |
|
|
entity sdpram_infer_read_first is
|
41 |
|
|
generic (
|
42 |
|
|
gADDRESS_WIDTH : integer := 5;
|
43 |
|
|
gDATA_WIDTH : integer := 24
|
44 |
|
|
);
|
45 |
|
|
port (
|
46 |
|
|
iClk : in std_logic;
|
47 |
|
|
iReset_sync : in std_logic;
|
48 |
|
|
iWe : in std_logic;
|
49 |
|
|
ivWrAddr : in std_logic_vector(gADDRESS_WIDTH-1 downto 0);
|
50 |
|
|
ivRdAddr : in std_logic_vector(gADDRESS_WIDTH-1 downto 0);
|
51 |
|
|
ivDataIn : in std_logic_vector(gDATA_WIDTH-1 downto 0);
|
52 |
|
|
ovDataOut : out std_logic_vector(gDATA_WIDTH-1 downto 0)
|
53 |
|
|
);
|
54 |
|
|
end sdpram_infer_read_first;
|
55 |
|
|
|
56 |
|
|
architecture behavioral of sdpram_infer_read_first is
|
57 |
|
|
-- Output register
|
58 |
|
|
signal svDataOut : std_logic_vector (gDATA_WIDTH-1 downto 0) := (others => '0');
|
59 |
|
|
|
60 |
|
|
-- RAM addressable data array
|
61 |
|
|
type tRAM is array (2**gADDRESS_WIDTH-1 downto 0) of std_logic_vector (gDATA_WIDTH-1 downto 0);
|
62 |
|
|
signal svRAM : tRAM := (others => (others => '0'));
|
63 |
|
|
|
64 |
|
|
begin
|
65 |
|
|
ovDataOut <= svDataOut;
|
66 |
|
|
process (iClk)
|
67 |
|
|
begin
|
68 |
|
|
if iClk'event and iClk = '1' then
|
69 |
|
|
if iWE = '1' then
|
70 |
|
|
svRAM(conv_integer(ivWrAddr)) <= ivDataIn;
|
71 |
|
|
end if;
|
72 |
|
|
end if;
|
73 |
|
|
end process;
|
74 |
|
|
|
75 |
|
|
svDataOut <= svRAM(conv_integer(ivRdAddr));
|
76 |
|
|
end behavioral;
|