w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ram_2swsr_wfirst_gen.vhd
Go to the documentation of this file.
1-- $Id: ram_2swsr_wfirst_gen.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ram_2swsr_wfirst_gen - syn
7-- Description: Dual-Port RAM with with two synchronous read/write ports
8-- and 'read-through' semantics (as block RAM).
9-- The code is inspired by Xilinx example rams_16.vhd. The
10-- 'ram_style' attribute is set to 'block', this will
11-- force in XST a synthesis as block RAM.
12--
13-- Dependencies: -
14-- Test bench: -
15-- Target Devices: generic Spartan, Virtex
16-- Tool versions: xst 8.2-14.7; ghdl 0.18-0.31
17-- Revision History:
18-- Date Rev Version Comment
19-- 2011-11-08 422 1.0.4 now numeric_std clean
20-- 2010-06-03 299 1.0.3 use sv_ prefix for shared variables
21-- 2008-03-08 123 1.0.2 use std_..._arith, not _unsigned; use unsigned();
22-- 2008-03-02 122 1.0.1 change generic default for BRAM models
23-- 2007-06-03 45 1.0 Initial version
24------------------------------------------------------------------------------
25
26library ieee;
27use ieee.std_logic_1164.all;
28use ieee.numeric_std.all;
29
30use work.slvtypes.all;
31
32entity ram_2swsr_wfirst_gen is -- RAM, 2 sync r/w ports, write first
33 generic (
34 AWIDTH : positive := 11; -- address port width
35 DWIDTH : positive := 9); -- data port width
36 port(
37 CLKA : in slbit; -- clock port A
38 CLKB : in slbit; -- clock port B
39 ENA : in slbit; -- enable port A
40 ENB : in slbit; -- enable port B
41 WEA : in slbit; -- write enable port A
42 WEB : in slbit; -- write enable port B
43 ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
44 ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
45 DIA : in slv(DWIDTH-1 downto 0); -- data in port A
46 DIB : in slv(DWIDTH-1 downto 0); -- data in port B
47 DOA : out slv(DWIDTH-1 downto 0); -- data out port A
48 DOB : out slv(DWIDTH-1 downto 0) -- data out port B
49 );
51
52
53architecture syn of ram_2swsr_wfirst_gen is
54 constant memsize : positive := 2**AWIDTH;
55 constant datzero : slv(DWIDTH-1 downto 0) := (others=>'0');
56 type ram_type is array (0 to memsize-1) of slv(DWIDTH-1 downto 0);
57 shared variable sv_ram : ram_type := (others=>datzero);
58
59 attribute ram_style : string;
60 attribute ram_style of sv_ram : variable is "block";
61
62 signal R_DOA : slv(DWIDTH-1 downto 0) := datzero;
63 signal R_DOB : slv(DWIDTH-1 downto 0) := datzero;
64begin
65
66 proc_clka: process (CLKA)
67 begin
68 if rising_edge(CLKA) then
69 if ENA = '1' then
70 if WEA = '1' then
71 sv_ram(to_integer(unsigned(ADDRA))) := DIA;
72 end if;
73 R_DOA <= sv_ram(to_integer(unsigned(ADDRA)));
74 end if;
75 end if;
76 end process proc_clka;
77
78 proc_clkb: process (CLKB)
79 begin
80 if rising_edge(CLKB) then
81 if ENB = '1' then
82 if WEB = '1' then
83 sv_ram(to_integer(unsigned(ADDRB))) := DIB;
84 end if;
85 R_DOB <= sv_ram(to_integer(unsigned(ADDRB)));
86 end if;
87 end if;
88 end process proc_clkb;
89
90 DOA <= R_DOA;
91 DOB <= R_DOB;
92
93end syn;
slv( DWIDTH- 1 downto 0) := datzero R_DOB
( 0 to memsize- 1) slv( DWIDTH- 1 downto 0) ram_type
shared ram_type :=:=( others => datzero) sv_ram
slv( DWIDTH- 1 downto 0) := datzero R_DOA
positive := 2** AWIDTH memsize
slv( DWIDTH- 1 downto 0) :=( others => '0') datzero
in DIA 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)
in DIB slv( DWIDTH- 1 downto 0)
out DOA slv( DWIDTH- 1 downto 0)
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31