w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ram_1swar_1ar_gen_unisim.vhd
Go to the documentation of this file.
1-- $Id: ram_1swar_1ar_gen_unisim.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2008-2010 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ram_1swar_1ar_gen - syn
7-- Description: Dual-Port RAM with with one synchronous write and two
8-- asynchronius read ports (as distributed RAM).
9-- Direct instantiation of Xilinx UNISIM primitives
10--
11-- Dependencies: -
12-- Test bench: -
13-- Target Devices: generic Spartan, Virtex
14-- Tool versions: ise 8.1-14.7; viv 2014.4; ghdl 0.18-0.31
15-- Revision History:
16-- Date Rev Version Comment
17-- 2010-06-03 300 1.1 add hack for AW=5 for Spartan's
18-- 2008-03-08 123 1.0.1 use shorter label names
19-- 2008-03-02 122 1.0 Initial version
20------------------------------------------------------------------------------
21
22library ieee;
23use ieee.std_logic_1164.all;
24
25library unisim;
26use unisim.vcomponents.ALL;
27
28use work.slvtypes.all;
29
30entity ram_1swar_1ar_gen is -- RAM, 1 sync w asyn r + 1 asyn r port
31 generic (
32 AWIDTH : positive := 4; -- address port width
33 DWIDTH : positive := 16); -- data port width
34 port (
35 CLK : in slbit; -- clock
36 WE : in slbit; -- write enable (port A)
37 ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
38 ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
39 DI : in slv(DWIDTH-1 downto 0); -- data in (port A)
40 DOA : out slv(DWIDTH-1 downto 0); -- data out port A
41 DOB : out slv(DWIDTH-1 downto 0) -- data out port B
42 );
44
45
46architecture syn of ram_1swar_1ar_gen is
47
48begin
49
50 assert AWIDTH>=4 and AWIDTH<=5
51 report "assert(AWIDTH>=4 and AWIDTH<=5): only 4..5 bit AWIDTH supported"
52 severity failure;
53
54 AW_4: if AWIDTH = 4 generate
55 GL: for i in DWIDTH-1 downto 0 generate
56 MEM : RAM16X1D
57 generic map (
58 INIT => X"0000")
59 port map (
60 DPO => DOB(i),
61 SPO => DOA(i),
62 A0 => ADDRA(0),
63 A1 => ADDRA(1),
64 A2 => ADDRA(2),
65 A3 => ADDRA(3),
66 D => DI(i),
67 DPRA0 => ADDRB(0),
68 DPRA1 => ADDRB(1),
69 DPRA2 => ADDRB(2),
70 DPRA3 => ADDRB(3),
71 WCLK => CLK,
72 WE => WE
73 );
74 end generate GL;
75 end generate AW_4;
76
77 -- Note: Spartan-3 doesn't support RAM32X1D, therefore this kludge..
78 AW_5: if AWIDTH = 5 generate
79 signal WE0 : slbit := '0';
80 signal WE1 : slbit := '0';
81 signal DOA0 : slv(DWIDTH-1 downto 0) := (others=>'0');
82 signal DOA1 : slv(DWIDTH-1 downto 0) := (others=>'0');
83 signal DOB0 : slv(DWIDTH-1 downto 0) := (others=>'0');
84 signal DOB1 : slv(DWIDTH-1 downto 0) := (others=>'0');
85 begin
86 WE0 <= WE and not ADDRA(4);
87 WE1 <= WE and ADDRA(4);
88 GL: for i in DWIDTH-1 downto 0 generate
89 MEM0 : RAM16X1D
90 generic map (
91 INIT => X"0000")
92 port map (
93 DPO => DOB0(i),
94 SPO => DOA0(i),
95 A0 => ADDRA(0),
96 A1 => ADDRA(1),
97 A2 => ADDRA(2),
98 A3 => ADDRA(3),
99 D => DI(i),
100 DPRA0 => ADDRB(0),
101 DPRA1 => ADDRB(1),
102 DPRA2 => ADDRB(2),
103 DPRA3 => ADDRB(3),
104 WCLK => CLK,
105 WE => WE0
106 );
107 MEM1 : RAM16X1D
108 generic map (
109 INIT => X"0000")
110 port map (
111 DPO => DOB1(i),
112 SPO => DOA1(i),
113 A0 => ADDRA(0),
114 A1 => ADDRA(1),
115 A2 => ADDRA(2),
116 A3 => ADDRA(3),
117 D => DI(i),
118 DPRA0 => ADDRB(0),
119 DPRA1 => ADDRB(1),
120 DPRA2 => ADDRB(2),
121 DPRA3 => ADDRB(3),
122 WCLK => CLK,
123 WE => WE1
124 );
125 DOA <= DOA0 when ADDRA(4)='0' else DOA1;
126 DOB <= DOB0 when ADDRB(4)='0' else DOB1;
127 end generate GL;
128 end generate AW_5;
129
130-- AW_6: if AWIDTH = 6 generate
131-- GL: for i in DWIDTH-1 downto 0 generate
132-- MEM : RAM64X1D
133-- generic map (
134-- INIT => X"0000000000000000")
135-- port map (
136-- DPO => DOB(i),
137-- SPO => DOA(i),
138-- A0 => ADDRA(0),
139-- A1 => ADDRA(1),
140-- A2 => ADDRA(2),
141-- A3 => ADDRA(3),
142-- A4 => ADDRA(4),
143-- A5 => ADDRA(5),
144-- D => DI(i),
145-- DPRA0 => ADDRB(0),
146-- DPRA1 => ADDRB(1),
147-- DPRA2 => ADDRB(2),
148-- DPRA3 => ADDRB(3),
149-- DPRA4 => ADDRB(4),
150-- DPRA5 => ADDRB(5),
151-- WCLK => CLK,
152-- WE => WE
153-- );
154-- end generate GL;
155-- end generate AW_6;
156
157end syn;
158
159-- Note: The VHDL instantiation example in the 8.1i Librariers Guide is wrong.
160-- The annotation states that DPO is the port A output and SPO is port B
161-- output. The text before is correct, DPO is port B and SPO is port A.
slv( DWIDTH- 1 downto 0) :=( others => '0') DOA1
slv( DWIDTH- 1 downto 0) :=( others => '0') DOB1
slv( DWIDTH- 1 downto 0) :=( others => '0') DOB0
slv( DWIDTH- 1 downto 0) :=( others => '0') DOA0
AWIDTH positive := 4
in DI slv( DWIDTH- 1 downto 0)
in ADDRB slv( AWIDTH- 1 downto 0)
in ADDRA slv( AWIDTH- 1 downto 0)
out DOB slv( DWIDTH- 1 downto 0)
out DOA slv( DWIDTH- 1 downto 0)
DWIDTH positive := 16
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31