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

Subversion Repositories bw_tiff_compression

[/] [bw_tiff_compression/] [trunk/] [RAMs.vhd] - Blame information for rev 8

Go to most recent revision | 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:55:02 05/22/2011 
6
-- Design Name: 
7
-- Module Name:    RAM - Behavioral 
8
-- Project Name:   VHDL course
9
----------------------------------------------------------------------------------
10
 
11
library IEEE;
12
use IEEE.STD_LOGIC_1164.ALL;
13
use IEEE.NUMERIC_STD.ALL;
14
 
15
entity MyRAM is
16
        Generic (
17
                DATA_WIDTH_G   : integer;
18
                MEMORY_SIZE_G  : integer;
19
                MEMORY_ADDRESS_WIDTH_G : integer;
20
                BUFFER_OUTPUT_G : boolean := false
21
        );
22
        Port (
23
                clk : in  STD_LOGIC;
24
                en : in  STD_LOGIC;
25
                rd : in  STD_LOGIC;
26
                wr : in  STD_LOGIC;
27
                rd_addr : in  STD_LOGIC_VECTOR (MEMORY_ADDRESS_WIDTH_G-1 downto 0);
28
                wr_addr : in  STD_LOGIC_VECTOR (MEMORY_ADDRESS_WIDTH_G-1 downto 0);
29
                Data_in : in  STD_LOGIC_VECTOR (DATA_WIDTH_G-1 downto 0);
30
                Data_out : out  STD_LOGIC_VECTOR (DATA_WIDTH_G-1 downto 0) := (others => '0')
31
        );
32
end MyRAM;
33
 
34
architecture Behavioral of MyRAM is
35
        type ram_type is array(MEMORY_SIZE_G-1 downto 0) of std_logic_vector(DATA_WIDTH_G-1 downto 0);
36
        signal mem : ram_type;
37
--      attribute ram_style: string;
38
--      attribute ram_style of mem : signal is "block";
39
 
40
begin
41
        wrRAM : process(clk)
42
        begin
43
                if clk'event and clk = '1' then
44
                        if en = '1' then
45
                                if wr = '1' then
46
                                        mem(TO_INTEGER(unsigned(wr_addr))) <= Data_in;
47
                                end if;
48
                        end if;
49
                end if;
50
        end process wrRAM;
51
 
52
        rdRAM : process(clk)
53
        begin
54
                if clk'event and clk = '1' then
55
                        if en = '1' then
56
                                if BUFFER_OUTPUT_G then
57
                                        if rd = '1' then
58
                                                Data_out <= mem(TO_INTEGER(unsigned(rd_addr)));
59
                                        end if;
60
                                else
61
                                        Data_out <= mem(TO_INTEGER(unsigned(rd_addr)));
62
                                end if;
63
                        end if;
64
                end if;
65
        end process rdRAM;
66
end Behavioral;
67
 

powered by: WebSVN 2.1.0

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