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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [rtl/] [vlib/] [memlib/] [ram_2swsr_rfirst_gen.vhd] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: ram_2swsr_rfirst_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_2swsr_rfirst_gen - syn
16
-- Description:    Dual-Port RAM with with two synchronous read/write ports
17
--                 and 'read-before-write' semantics (as block RAM).
18
--                 The code is inspired by Xilinx example rams_16.vhd. The
19
--                 'ram_style' attribute is set to 'block', this will
20
--                 force in XST a synthesis as block RAM.
21
--
22
-- Dependencies:   -
23
-- Test bench:     -
24
-- Target Devices: generic Spartan, Virtex
25 13 wfjm
-- Tool versions:  xst 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.4  now numeric_std clean
29 2 wfjm
-- 2010-06-03   299   1.0.3  use sv_ prefix for shared variables
30 13 wfjm
-- 2008-03-08   123   1.0.2  use std_..._arith, not _unsigned; use unsigned();
31 2 wfjm
--                           now initialize DO to all '0' at start
32
-- 2008-03-02   122   1.0.1  change generic default for BRAM models
33
-- 2007-06-03    45   1.0    Initial version 
34
------------------------------------------------------------------------------
35
 
36
library ieee;
37
use ieee.std_logic_1164.all;
38 13 wfjm
use ieee.numeric_std.all;
39 2 wfjm
 
40
use work.slvtypes.all;
41
 
42
entity ram_2swsr_rfirst_gen is          -- RAM, 2 sync r/w ports, read first
43
  generic (
44
    AWIDTH : positive := 11;            -- address port width
45
    DWIDTH : positive :=  9);           -- data port width
46
  port(
47
    CLKA  : in slbit;                   -- clock port A
48
    CLKB  : in slbit;                   -- clock port B
49
    ENA   : in slbit;                   -- enable port A
50
    ENB   : in slbit;                   -- enable port B
51
    WEA   : in slbit;                   -- write enable port A
52
    WEB   : in slbit;                   -- write enable port B
53
    ADDRA : in slv(AWIDTH-1 downto 0);  -- address port A
54
    ADDRB : in slv(AWIDTH-1 downto 0);  -- address port B
55
    DIA   : in slv(DWIDTH-1 downto 0);  -- data in port A
56
    DIB   : in slv(DWIDTH-1 downto 0);  -- data in port B
57
    DOA   : out slv(DWIDTH-1 downto 0); -- data out port A
58
    DOB   : out slv(DWIDTH-1 downto 0)  -- data out port B
59
  );
60
end ram_2swsr_rfirst_gen;
61
 
62
 
63
architecture syn of ram_2swsr_rfirst_gen is
64
  constant memsize : positive := 2**AWIDTH;
65
  constant datzero : slv(DWIDTH-1 downto 0) := (others=>'0');
66
  type ram_type is array (0 to memsize-1) of slv(DWIDTH-1 downto 0);
67
  shared variable sv_ram : ram_type := (others=>datzero);
68
 
69
  attribute ram_style : string;
70
  attribute ram_style of sv_ram : variable is "block";
71
 
72
  signal R_DOA : slv(DWIDTH-1 downto 0) := datzero;
73
  signal R_DOB : slv(DWIDTH-1 downto 0) := datzero;
74
 
75
begin
76
 
77
  proc_clka: process (CLKA)
78
  begin
79 13 wfjm
    if rising_edge(CLKA) then
80 2 wfjm
      if ENA = '1' then
81 13 wfjm
        R_DOA <= sv_ram(to_integer(unsigned(ADDRA)));
82 2 wfjm
        if WEA = '1' then
83 13 wfjm
          sv_ram(to_integer(unsigned(ADDRA))) := DIA;
84 2 wfjm
        end if;
85
      end if;
86
    end if;
87
  end process proc_clka;
88
 
89
  proc_clkb: process (CLKB)
90
  begin
91 13 wfjm
    if rising_edge(CLKB) then
92 2 wfjm
      if ENB = '1' then
93 13 wfjm
        R_DOB <= sv_ram(to_integer(unsigned(ADDRB)));
94 2 wfjm
        if WEB = '1' then
95 13 wfjm
          sv_ram(to_integer(unsigned(ADDRB))) := DIB;
96 2 wfjm
        end if;
97
      end if;
98
    end if;
99
  end process proc_clkb;
100
 
101
  DOA <= R_DOA;
102
  DOB <= R_DOB;
103
 
104
end syn;

powered by: WebSVN 2.1.0

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