1 |
13 |
wfjm |
-- $Id: ram_1swar_1ar_gen.vhd 422 2011-11-10 18:44:06Z mueller $
|
2 |
2 |
wfjm |
--
|
3 |
13 |
wfjm |
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
2 |
wfjm |
--
|
5 |
|
|
-- This program is free software; you may redistribute and/or modify it under
|
6 |
|
|
-- the terms of the GNU General Public License as published by the Free
|
7 |
|
|
-- Software Foundation, either version 2, or at your option any later version.
|
8 |
|
|
--
|
9 |
|
|
-- This program is distributed in the hope that it will be useful, but
|
10 |
|
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
11 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
12 |
|
|
-- for complete details.
|
13 |
|
|
--
|
14 |
|
|
------------------------------------------------------------------------------
|
15 |
|
|
-- Module Name: ram_1swar_1ar_gen - syn
|
16 |
|
|
-- Description: Dual-Port RAM with with one synchronous write and two
|
17 |
|
|
-- asynchronius read ports (as distributed RAM).
|
18 |
|
|
-- The code is inspired by Xilinx example rams_09.vhd. The
|
19 |
|
|
-- 'ram_style' attribute is set to 'distributed', this will
|
20 |
|
|
-- force in XST a synthesis as distributed RAM.
|
21 |
|
|
--
|
22 |
|
|
-- Dependencies: -
|
23 |
|
|
-- Test bench: -
|
24 |
|
|
-- Target Devices: generic Spartan, Virtex
|
25 |
13 |
wfjm |
-- Tool versions: xst 8.1, 8.2, 9.1, 9.2, 13.1; ghdl 0.18-0.29
|
26 |
2 |
wfjm |
-- Revision History:
|
27 |
|
|
-- Date Rev Version Comment
|
28 |
13 |
wfjm |
-- 2011-11-08 422 1.0.2 now numeric_std clean
|
29 |
|
|
-- 2008-03-08 123 1.0.1 use std_..._arith, not _unsigned; use unsigned()
|
30 |
2 |
wfjm |
-- 2007-06-03 45 1.0 Initial version
|
31 |
|
|
--
|
32 |
|
|
-- Some synthesis results:
|
33 |
|
|
-- - 2010-06-03 ise 11.4 for xc3s1000-ft256-4:
|
34 |
|
|
-- AWIDTH DWIDTH LUTl LUTm Comments
|
35 |
|
|
-- 4 16 - 32 16*RAM16X1D
|
36 |
|
|
-- 5 16 34 64 32*RAM16X1D
|
37 |
|
|
-- 6 16 68 128 64*RAM16X1D, 32*MUXF5
|
38 |
|
|
-- 7 16 136 256 128*RAM16X1D, 64*MUXF5, 32*MUXF6
|
39 |
|
|
-- 8 16 292 512 256*RAM16X1D,144*MUXF5, 64*MUXF6, 32*MUXF7
|
40 |
|
|
-- - 2007-12-31 ise 8.2.03 for xc3s1000-ft256-4:
|
41 |
|
|
-- {same results as above for AW=4 and 6}
|
42 |
|
|
------------------------------------------------------------------------------
|
43 |
|
|
|
44 |
|
|
library ieee;
|
45 |
|
|
use ieee.std_logic_1164.all;
|
46 |
13 |
wfjm |
use ieee.numeric_std.all;
|
47 |
2 |
wfjm |
|
48 |
|
|
use work.slvtypes.all;
|
49 |
|
|
|
50 |
|
|
entity ram_1swar_1ar_gen is -- RAM, 1 sync w asyn r + 1 asyn r port
|
51 |
|
|
generic (
|
52 |
|
|
AWIDTH : positive := 4; -- address port width
|
53 |
|
|
DWIDTH : positive := 16); -- data port width
|
54 |
|
|
port (
|
55 |
|
|
CLK : in slbit; -- clock
|
56 |
|
|
WE : in slbit; -- write enable (port A)
|
57 |
|
|
ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
|
58 |
|
|
ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
|
59 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- data in (port A)
|
60 |
|
|
DOA : out slv(DWIDTH-1 downto 0); -- data out port A
|
61 |
|
|
DOB : out slv(DWIDTH-1 downto 0) -- data out port B
|
62 |
|
|
);
|
63 |
|
|
end ram_1swar_1ar_gen;
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
architecture syn of ram_1swar_1ar_gen is
|
67 |
|
|
constant memsize : positive := 2**AWIDTH;
|
68 |
|
|
constant datzero : slv(DWIDTH-1 downto 0) := (others=>'0');
|
69 |
|
|
type ram_type is array (memsize-1 downto 0) of slv (DWIDTH-1 downto 0);
|
70 |
|
|
signal RAM : ram_type := (others=>datzero);
|
71 |
|
|
|
72 |
|
|
attribute ram_style : string;
|
73 |
|
|
attribute ram_style of RAM : signal is "distributed";
|
74 |
|
|
|
75 |
|
|
begin
|
76 |
|
|
|
77 |
|
|
proc_clk: process (CLK)
|
78 |
|
|
begin
|
79 |
13 |
wfjm |
if rising_edge(CLK) then
|
80 |
2 |
wfjm |
if WE = '1' then
|
81 |
13 |
wfjm |
RAM(to_integer(unsigned(ADDRA))) <= DI;
|
82 |
2 |
wfjm |
end if;
|
83 |
|
|
end if;
|
84 |
|
|
end process proc_clk;
|
85 |
|
|
|
86 |
13 |
wfjm |
DOA <= RAM(to_integer(unsigned(ADDRA)));
|
87 |
|
|
DOB <= RAM(to_integer(unsigned(ADDRB)));
|
88 |
2 |
wfjm |
|
89 |
|
|
end syn;
|