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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.74/] [rtl/] [vlib/] [memlib/] [ram_1swsr_wfirst_gen.vhd] - Blame information for rev 40

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

Line No. Rev Author Line
1 31 wfjm
-- $Id: ram_1swsr_wfirst_gen.vhd 686 2015-06-04 21:08:08Z mueller $
2
--
3
-- Copyright 2006-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
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_1swsr_rfirst_gen - syn
16
-- Description:    Single-Port RAM with with one synchronous read/write port
17
--                 and 'read-through' semantics (as block RAM).
18
--                 The 'ram_style' attribute is set to 'block', this will
19
--                 force in XST a synthesis as block RAM.
20
--
21
-- Notes:          For xst 8.1.03i: can be written with a signal or a shared
22
--                 variable declared at the architecture level. Use variable
23
--                 because this seemed better for simulation. Using a simple
24
--                 variable declared at process level leads to an array of
25
--                 registers and a big mux.
26
--
27
-- Dependencies:   -
28
-- Test bench:     -
29
-- Target Devices: generic Spartan, Virtex
30
-- Tool versions:  xst 8.2-14.7; ghdl 0.18-0.31
31
-- Revision History: 
32
-- Date         Rev Version  Comment
33
-- 2011-11-08   422   1.0.4  now numeric_std clean
34
-- 2010-06-03   299   1.0.3  use sv_ prefix for shared variables
35
-- 2008-03-08   123   1.0.2  use std_..._arith, not _unsigned; use unsigned();
36
-- 2008-03-02   122   1.0.1  change generic default for BRAM models
37
-- 2007-06-03    45   1.0    Initial version 
38
------------------------------------------------------------------------------
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.numeric_std.all;
43
 
44
use work.slvtypes.all;
45
 
46
entity ram_1swsr_wfirst_gen is          -- RAM, 1 sync r/w ports, write first
47
  generic (
48
    AWIDTH : positive := 11;            -- address port width
49
    DWIDTH : positive :=  9);           -- data port width
50
  port(
51
    CLK  : in slbit;                    -- clock
52
    EN   : in slbit;                    -- enable
53
    WE   : in slbit;                    -- write enable
54
    ADDR : in slv(AWIDTH-1 downto 0);   -- address port
55
    DI   : in slv(DWIDTH-1 downto 0);   -- data in port
56
    DO   : out slv(DWIDTH-1 downto 0)   -- data out port
57
  );
58
end ram_1swsr_wfirst_gen;
59
 
60
 
61
architecture syn of ram_1swsr_wfirst_gen is
62
 
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_DO : slv(DWIDTH-1 downto 0) := datzero;
72
 
73
begin
74
 
75
  proc_clk: process (CLK)
76
  begin
77
    if rising_edge(CLK) then
78
      if EN = '1' then
79
        if WE = '1' then
80
          sv_ram(to_integer(unsigned(ADDR))) := DI;
81
        end if;
82
        R_DO <= sv_ram(to_integer(unsigned(ADDR)));
83
      end if;
84
    end if;
85
  end process proc_clk;
86
 
87
  DO <= R_DO;
88
 
89
end syn;
90
 

powered by: WebSVN 2.1.0

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