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

Subversion Repositories tinycpu

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

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 10 earlz
            --if WriteEnable(0) = '1' then
15
              --          di0 <= DataIn(7 downto 0);
16
               -- else
17
                        --di0 := RAM(conv_integer(Address))(7 downto 0);
18
               --         di0 <= do(7 downto 0);
19
                --end if;
20
                --if WriteEnable(1) = '1' then
21
                    --    di1 <= DataIn(15 downto 8);
22
                --else
23
                        --di1 <= RAM(conv_integer(Address))(15 downto 8);
24
                  --      di1 <= do(15 downto 8);
25
                --end if;
26 8 earlz
 
27
entity blockram is
28
  port(
29 10 earlz
    Address: in std_logic_vector(7 downto 0); --memory address
30 9 earlz
    WriteEnable: in std_logic_vector(1 downto 0); --write 1 byte at a time option
31 8 earlz
    Enable: in std_logic;
32
    Clock: in std_logic;
33
    DataIn: in std_logic_vector(15 downto 0);
34
    DataOut: out std_logic_vector(15 downto 0)
35
  );
36
end blockram;
37
 
38
architecture Behavioral of blockram is
39 10 earlz
    type ram_type is array (255 downto 0) of std_logic_vector (15 downto 0);
40 8 earlz
    signal RAM: ram_type;
41 10 earlz
    signal di0, di1: std_logic_vector(7 downto 0);
42
    signal do : std_logic_vector(15 downto 0);
43 8 earlz
begin
44 10 earlz
  di0 <= DataIn(7 downto 0) when WriteEnable(0)='1' else do(7 downto 0);
45
    di1 <= DataIn(15 downto 8) when WriteEnable(1)='1' else do(15 downto 8);
46 8 earlz
  process (Clock)
47
  begin
48
    if rising_edge(Clock) then
49
      if Enable = '1' then
50 10 earlz
        if WriteEnable(0)='1' or WriteEnable(1)='1' then
51 9 earlz
          RAM(conv_integer(Address)) <= di1 & di0;
52 10 earlz
        else
53
          do <= RAM(conv_integer(Address)) ;
54
        end if;
55 8 earlz
      end if;
56
    end if;
57
  end process;
58 10 earlz
  DataOut <= do;
59 8 earlz
end Behavioral;

powered by: WebSVN 2.1.0

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