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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 13 wfjm
-- $Id: ram_2swsr_wfirst_gen.vhd 422 2011-11-10 18:44:06Z mueller $
2 10 wfjm
--
3 13 wfjm
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 10 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_wfirst_gen - syn
16
-- Description:    Dual-Port RAM with with two synchronous read/write ports
17
--                 and 'read-through' 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 10 wfjm
-- Revision History: 
27
-- Date         Rev Version  Comment
28 13 wfjm
-- 2011-11-08   422   1.0.4  now numeric_std clean
29 10 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 10 wfjm
-- 2008-03-02   122   1.0.1  change generic default for BRAM models
32
-- 2007-06-03    45   1.0    Initial version 
33
------------------------------------------------------------------------------
34
 
35
library ieee;
36
use ieee.std_logic_1164.all;
37 13 wfjm
use ieee.numeric_std.all;
38 10 wfjm
 
39
use work.slvtypes.all;
40
 
41
entity ram_2swsr_wfirst_gen is          -- RAM, 2 sync r/w ports, write first
42
  generic (
43
    AWIDTH : positive := 11;            -- address port width
44
    DWIDTH : positive :=  9);           -- data port width
45
  port(
46
    CLKA  : in slbit;                   -- clock port A
47
    CLKB  : in slbit;                   -- clock port B
48
    ENA   : in slbit;                   -- enable port A
49
    ENB   : in slbit;                   -- enable port B
50
    WEA   : in slbit;                   -- write enable port A
51
    WEB   : in slbit;                   -- write enable port B
52
    ADDRA : in slv(AWIDTH-1 downto 0);  -- address port A
53
    ADDRB : in slv(AWIDTH-1 downto 0);  -- address port B
54
    DIA   : in slv(DWIDTH-1 downto 0);  -- data in port A
55
    DIB   : in slv(DWIDTH-1 downto 0);  -- data in port B
56
    DOA   : out slv(DWIDTH-1 downto 0); -- data out port A
57
    DOB   : out slv(DWIDTH-1 downto 0)  -- data out port B
58
  );
59
end ram_2swsr_wfirst_gen;
60
 
61
 
62
architecture syn of ram_2swsr_wfirst_gen is
63
  constant memsize : positive := 2**AWIDTH;
64
  constant datzero : slv(DWIDTH-1 downto 0) := (others=>'0');
65
  type ram_type is array (0 to memsize-1) of slv(DWIDTH-1 downto 0);
66
  shared variable sv_ram : ram_type := (others=>datzero);
67
 
68
  attribute ram_style : string;
69
  attribute ram_style of sv_ram : variable is "block";
70
 
71
  signal R_DOA : slv(DWIDTH-1 downto 0) := datzero;
72
  signal R_DOB : slv(DWIDTH-1 downto 0) := datzero;
73
begin
74
 
75
  proc_clka: process (CLKA)
76
  begin
77 13 wfjm
    if rising_edge(CLKA) then
78 10 wfjm
      if ENA = '1' then
79
        if WEA = '1' then
80 13 wfjm
          sv_ram(to_integer(unsigned(ADDRA))) := DIA;
81 10 wfjm
        end if;
82 13 wfjm
        R_DOA <= sv_ram(to_integer(unsigned(ADDRA)));
83 10 wfjm
      end if;
84
    end if;
85
  end process proc_clka;
86
 
87
  proc_clkb: process (CLKB)
88
  begin
89 13 wfjm
    if rising_edge(CLKB) then
90 10 wfjm
      if ENB = '1' then
91
        if WEB = '1' then
92 13 wfjm
          sv_ram(to_integer(unsigned(ADDRB))) := DIB;
93 10 wfjm
        end if;
94 13 wfjm
        R_DOB <= sv_ram(to_integer(unsigned(ADDRB)));
95 10 wfjm
      end if;
96
    end if;
97
  end process proc_clkb;
98
 
99
  DOA <= R_DOA;
100
  DOB <= R_DOB;
101
 
102
end syn;

powered by: WebSVN 2.1.0

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