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

Subversion Repositories tinycpu

[/] [tinycpu/] [trunk/] [src/] [registerfile.vhd] - Diff between revs 6 and 12

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

Rev 6 Rev 12
Line 1... Line 1...
--registerfile module
--registerfile module
--16 registers, dual port for both read and write
--16 registers, read/write port for all registers. 
--8 bit registers
--8 bit registers
 
 
library IEEE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.NUMERIC_STD.ALL;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
 
use work.tinycpu.all;
 
 
entity registerfile is
entity registerfile is
 
 
  port(
  port(
    Write1:in std_logic_vector(7 downto 0); --what should be put into the write register
                WriteEnable: in regwritetype;
    Write2: in std_logic_vector(7 downto 0);
                DataIn: in regdatatype;
    SelRead1:in std_logic_vector(3 downto 0); --select which register to read
 
    SelRead2: in std_logic_vector(3 downto 0); --select second register to read
 
    SelWrite1:in std_logic_vector(3 downto 0); --select which register to write
 
    SelWrite2:in std_logic_vector(3 downto 0);
 
    UseWrite1:in std_logic; --if the register should actually be written to
 
    UseWrite2: in std_logic;
 
    Clock:in std_logic;
    Clock:in std_logic;
    Read1:out std_logic_vector(7 downto 0); --register to be read output
                DataOut: out regdatatype
    Read2:out std_logic_vector(7 downto 0) --register to be read on second output 
 
  );
  );
end registerfile;
end registerfile;
 
 
architecture Behavioral of registerfile is
architecture Behavioral of registerfile is
 
 
  type registerstype is array(0 to 15) of std_logic_vector(7 downto 0);
  type registerstype is array(0 to 15) of std_logic_vector(7 downto 0);
  signal registers: registerstype;
  signal registers: registerstype;
 
  --attribute ram_style : string;
 
  --attribute ram_style of registers: signal is "distributed";
begin
begin
  writereg: process(Write1, Write2, SelWrite1, SelWrite2, UseWrite1, UseWrite2, Clock)
  regs:
 
  for I in 0 to 15 generate
 
    process(WriteEnable(I), DataIn(I), Clock)
  begin
  begin
    if(UseWrite1='1') then
                                if rising_edge(Clock) then
      if(rising_edge(clock)) then
                if(WriteEnable(I) = '1') then
        registers(conv_integer(SelWrite1)) <= Write1;
                  registers(I) <= DataIn(I);
      end if;
 
    end if;
 
    if(UseWrite2='1') then
 
      if(rising_edge(clock) and conv_integer(SelWrite1)/=conv_integer(SelWrite2)) then
 
        registers(conv_integer(SelWrite2)) <= Write2;
 
      end if;
      end if;
    end if;
    end if;
  end process;
  end process;
  Read1 <= registers(conv_integer(SelRead1));
        DataOut(I) <= registers(I);
  Read2 <= registers(conv_integer(SelRead2));
  end generate regs;
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.