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

Subversion Repositories loadbalancer

[/] [loadbalancer/] [trunk/] [TABLE/] [ram_256x48.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 atalla
-- Quartus II VHDL Template
2
-- Simple Dual-Port RAM with different read/write addresses but
3
-- single read/write clock
4
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
 
8
entity ram_256x48 is
9
 
10
        generic
11
        (
12
                DATA_WIDTH : natural := 48;
13
                ADDR_WIDTH : natural := 12
14
        );
15
 
16
        port
17
        (
18
                clk             : in std_logic;
19
                raddr   : in natural range 0 to 2**ADDR_WIDTH - 1;
20
                waddr   : in natural range 0 to 2**ADDR_WIDTH - 1;
21
                data    : in std_logic_vector((DATA_WIDTH-1) downto 0);
22
                we              : in std_logic := '1';
23
                q               : out std_logic_vector((DATA_WIDTH -1) downto 0)
24
        );
25
 
26
end ram_256x48;
27
 
28
architecture rtl of ram_256x48 is
29
 
30
        -- Build a 2-D array type for the RAM
31
        subtype word_t is std_logic_vector((DATA_WIDTH-1) downto 0);
32
        type memory_t is array(2**ADDR_WIDTH - 1 downto 0) of word_t;
33
 
34
        -- Declare the RAM signal.      
35
        signal ram : memory_t;
36
 
37
begin
38
 
39
        process(clk)
40
        begin
41
        if(rising_edge(clk)) then
42
                if(we = '1') then
43
                        ram(waddr) <= data;
44
                end if;
45
 
46
                -- On a read during a write to the same address, the read will
47
                -- return the OLD data at the address
48
                q <= ram(raddr);
49
        end if;
50
 
51
        end process;
52
 
53
end rtl;

powered by: WebSVN 2.1.0

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