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

Subversion Repositories spacewire_light

[/] [spacewire_light/] [trunk/] [rtl/] [vhdl/] [spwram.vhd] - Blame information for rev 10

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

Line No. Rev Author Line
1 2 jorisvr
--
2 7 jorisvr
--  Synchronous two-port RAM with separate clocks for read and write ports.
3 2 jorisvr
--  The synthesizer for Xilinx Spartan-3 will infer Block RAM for this entity.
4
--
5
 
6
library ieee;
7
use ieee.std_logic_1164.all;
8
use ieee.numeric_std.all;
9
 
10
entity spwram is
11
 
12
    generic (
13
        abits:      integer;
14
        dbits:      integer );
15
 
16
    port (
17
        rclk:       in  std_logic;
18
        wclk:       in  std_logic;
19
        ren:        in  std_logic;
20
        raddr:      in  std_logic_vector(abits-1 downto 0);
21
        rdata:      out std_logic_vector(dbits-1 downto 0);
22
        wen:        in  std_logic;
23
        waddr:      in  std_logic_vector(abits-1 downto 0);
24
        wdata:      in  std_logic_vector(dbits-1 downto 0) );
25
 
26
end entity spwram;
27
 
28
architecture spwram_arch of spwram is
29
 
30
    type mem_type is array(0 to (2**abits - 1)) of
31
                     std_logic_vector(dbits-1 downto 0);
32
 
33
    signal s_mem:   mem_type;
34
 
35
begin
36
 
37
    -- read process
38
    process (rclk) is
39
    begin
40
        if rising_edge(rclk) then
41
            if ren = '1' then
42
                rdata <= s_mem(to_integer(unsigned(raddr)));
43
            end if;
44
        end if;
45
    end process;
46
 
47
    -- write process
48
    process (wclk) is
49
    begin
50
        if rising_edge(wclk) then
51
            if wen = '1' then
52
                s_mem(to_integer(unsigned(waddr))) <= wdata;
53
            end if;
54
        end if;
55
    end process;
56
 
57
end architecture;
58
 

powered by: WebSVN 2.1.0

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