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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [blockram.vhd] - Blame information for rev 8

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

Line No. Rev Author Line
1 8 earlz
--RAM module
2
--4096*8 bit file
3
--simultaneous write/read support
4
--16 bit or 8 bit data bus
5
--16 bit address bus
6
--On Reset, will load a "default" RAM image
7
 
8
library IEEE;
9
use IEEE.STD_LOGIC_1164.ALL;
10
use ieee.std_logic_arith.all;
11
use IEEE.NUMERIC_STD.ALL;
12
use ieee.std_logic_unsigned.all;
13
 
14
 
15
 
16
entity blockram is
17
  port(
18
    Address: in std_logic_vector(7 downto 0); --memory address
19
    WriteEnable: in std_logic; --write or read
20
    Enable: in std_logic;
21
    Clock: in std_logic;
22
    DataIn: in std_logic_vector(15 downto 0);
23
    DataOut: out std_logic_vector(15 downto 0)
24
  );
25
end blockram;
26
 
27
architecture Behavioral of blockram is
28
    type ram_type is array (255 downto 0) of std_logic_vector (15 downto 0);
29
    signal RAM: ram_type;
30
begin
31
 
32
  process (Clock)
33
  begin
34
    if rising_edge(Clock) then
35
      if Enable = '1' then
36
        if WriteEnable = '1' then
37
            RAM(conv_integer(Address)) <= DataIn;
38
        end if;
39
        DataOut <= RAM(conv_integer(Address)) ;
40
      end if;
41
    end if;
42
  end process;
43
 
44
end Behavioral;

powered by: WebSVN 2.1.0

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