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

Subversion Repositories bw_tiff_compression

[/] [bw_tiff_compression/] [trunk/] [DualClkRAM.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 amulder
----------------------------------------------------------------------------------
2
-- Company:        
3
-- Engineer:        Aart Mulder
4
-- 
5
-- Create Date:    11:42:02 12/28/2012 
6
-- Design Name: 
7
-- Module Name:    Dual clock RAM - Behavioral 
8
-- Project Name:         CCITT4
9
--
10
-- Revision: 
11
-- Revision 0.01 - File Created
12
--                           This RAM module can work with independent read
13
--                           and write clock.
14
--                 
15
----------------------------------------------------------------------------------
16
 
17
library IEEE;
18
use IEEE.STD_LOGIC_1164.ALL;
19
use IEEE.NUMERIC_STD.ALL;
20
 
21
entity DualClkRAM is
22
        Generic (
23
                DATA_WIDTH_G   : integer := 8;
24
                MEMORY_SIZE_G  : integer := 1024;
25
                MEMORY_ADDRESS_WIDTH_G : integer := 10
26
        );
27
        Port (
28
                wr_clk_i  : in  STD_LOGIC;
29
                rd_clk_i  : in  STD_LOGIC;
30
                wr_en_i   : in  STD_LOGIC;
31
                rd_en_i   : in  STD_LOGIC;
32
                rd_i      : in  STD_LOGIC;
33
                wr_i      : in  STD_LOGIC;
34
                rd_addr_i : in  UNSIGNED (MEMORY_ADDRESS_WIDTH_G-1 downto 0);
35
                wr_addr_i : in  UNSIGNED (MEMORY_ADDRESS_WIDTH_G-1 downto 0);
36
                d_i       : in  STD_LOGIC_VECTOR (DATA_WIDTH_G-1 downto 0);
37
                d_o       : out STD_LOGIC_VECTOR (DATA_WIDTH_G-1 downto 0)
38
        );
39
end DualClkRAM;
40
 
41
architecture Behavioral of DualClkRAM is
42
        type ram_type is array(MEMORY_SIZE_G-1 downto 0) of std_logic_vector(DATA_WIDTH_G-1 downto 0);
43
        signal mem : ram_type;
44
        attribute ram_style: string;
45
        attribute ram_style of mem : signal is "block";
46
 
47
begin
48
        write_RAM_process : process(wr_clk_i)
49
        begin
50
                if wr_clk_i'event and wr_clk_i = '1' then
51
                        if wr_en_i = '1' then
52
                                if wr_i = '1' then
53
                                        mem(TO_INTEGER(wr_addr_i)) <= d_i;
54
                                end if;
55
                        end if;
56
                end if;
57
        end process write_RAM_process;
58
 
59
        read_RAM_process : process(rd_clk_i)
60
        begin
61
                if rd_clk_i'event and rd_clk_i = '1' then
62
                        if rd_en_i = '1' then
63
                                if rd_i = '1' then
64
                                        d_o <= mem(TO_INTEGER(rd_addr_i));
65
                                end if;
66
                        end if;
67
                end if;
68
        end process read_RAM_process;
69
end Behavioral;
70
 

powered by: WebSVN 2.1.0

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