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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [blockram.vhd] - Diff between revs 8 and 9

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 8 Rev 9
Line 13... Line 13...
 
 
 
 
 
 
entity blockram is
entity blockram is
  port(
  port(
    Address: in std_logic_vector(7 downto 0); --memory address
    Address: in std_logic_vector(11 downto 0); --memory address
    WriteEnable: in std_logic; --write or read
    WriteEnable: in std_logic_vector(1 downto 0); --write 1 byte at a time option
    Enable: in std_logic;
    Enable: in std_logic;
    Clock: in std_logic;
    Clock: in std_logic;
    DataIn: in std_logic_vector(15 downto 0);
    DataIn: in std_logic_vector(15 downto 0);
    DataOut: out std_logic_vector(15 downto 0)
    DataOut: out std_logic_vector(15 downto 0)
  );
  );
end blockram;
end blockram;
 
 
architecture Behavioral of blockram is
architecture Behavioral of blockram is
    type ram_type is array (255 downto 0) of std_logic_vector (15 downto 0);
    type ram_type is array (4095 downto 0) of std_logic_vector (15 downto 0);
    signal RAM: ram_type;
    signal RAM: ram_type;
 
    signal di0, di1, do0, do1: std_logic_vector(7 downto 0); --data inputs and outputs for byte-enable
begin
begin
 
  process (WriteEnable,DataIn)
 
  begin
 
    if WriteEnable(0) = '1' then
 
      di0 <= DataIn(7 downto 0);
 
    else
 
      di0 <= RAM(conv_integer(Address))(7 downto 0);
 
      do0 <= RAM(conv_integer(Address))(7 downto 0);
 
    end if;
 
    if WriteEnable(1)= '1' then
 
      di1 <= DataIn(15 downto 8);
 
    else
 
      di1 <= RAM(conv_integer(Address))(15 downto 8);
 
      do1 <= RAM(conv_integer(Address))(15 downto 8);
 
    end if;
 
  end process;
  process (Clock)
  process (Clock)
  begin
  begin
    if rising_edge(Clock) then
    if rising_edge(Clock) then
      if Enable = '1' then
      if Enable = '1' then
        if WriteEnable = '1' then
          DataOut <= do1 & do0;
            RAM(conv_integer(Address)) <= DataIn;
          RAM(conv_integer(Address)) <= di1 & di0;
        end if;
 
        DataOut <= RAM(conv_integer(Address)) ;
 
      end if;
      end if;
    end if;
    end if;
  end process;
  end process;
 
 
end Behavioral;
end Behavioral;
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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