2013-07-02 22:15:26 +02:00
|
|
|
----------------------------------------------------------------------------------
|
|
|
|
-- Company:
|
|
|
|
-- Engineer:
|
|
|
|
--
|
|
|
|
-- Create Date: 16:05:19 05/10/2011
|
|
|
|
-- Design Name:
|
|
|
|
-- Module Name: RegFile - Behavioral
|
|
|
|
-- Project Name:
|
|
|
|
-- Target Devices:
|
|
|
|
-- Tool versions:
|
|
|
|
-- Description:
|
|
|
|
--
|
|
|
|
-- Dependencies:
|
|
|
|
--
|
|
|
|
-- Revision:
|
|
|
|
-- Revision 0.01 - File Created
|
|
|
|
-- Additional Comments:
|
|
|
|
--
|
|
|
|
----------------------------------------------------------------------------------
|
|
|
|
library IEEE;
|
|
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
|
|
|
|
|
|
library work;
|
|
|
|
use work.cpupkg.all;
|
2013-07-04 16:17:05 +02:00
|
|
|
use ieee.numeric_std.all;
|
2013-07-02 22:15:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
entity RegFile is
|
|
|
|
Port(
|
|
|
|
iClk : in std_logic;
|
2013-07-04 16:17:05 +02:00
|
|
|
iReset : in std_logic;
|
|
|
|
|
|
|
|
icRegAsel : in std_logic_vector(4 downto 0);
|
|
|
|
icRegBsel : in std_logic_vector(4 downto 0);
|
|
|
|
odRegA : out DATA;
|
|
|
|
odRegB : out DATA;
|
|
|
|
|
2013-07-26 12:33:01 +02:00
|
|
|
icPC : in std_logic; -- select PC as input to RegisterFile
|
|
|
|
idPC : in DATA;
|
2013-07-04 16:17:05 +02:00
|
|
|
|
|
|
|
icRegINsel : in std_logic_vector(4 downto 0);
|
|
|
|
|
2013-07-02 22:15:26 +02:00
|
|
|
idDataIn : in DATA;
|
|
|
|
idCarryIn : in std_logic;
|
|
|
|
idZeroIn : in std_logic;
|
|
|
|
|
|
|
|
icLoadEn : in std_logic;
|
|
|
|
|
|
|
|
odCarryOut : out std_logic;
|
|
|
|
odZeroOut : out std_logic
|
|
|
|
);
|
|
|
|
end RegFile;
|
|
|
|
|
|
|
|
architecture Behavioral of RegFile is
|
2013-07-04 16:17:05 +02:00
|
|
|
|
|
|
|
type registerFileType is array (0 to 31) of DATA;
|
|
|
|
signal registerFile : registerFileType;
|
|
|
|
|
2013-07-02 22:15:26 +02:00
|
|
|
signal sdData : DATA;
|
|
|
|
signal sdCarry : std_logic;
|
|
|
|
signal sdZero : std_logic;
|
|
|
|
begin
|
2013-07-04 16:17:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-02 22:15:26 +02:00
|
|
|
-- Execute Transition
|
|
|
|
process(iClk, iReset)
|
|
|
|
begin
|
|
|
|
if (iReset = '1') then
|
2013-07-04 16:17:05 +02:00
|
|
|
for i in 31 downto 0 loop
|
|
|
|
registerFile(i) <= (others=>'0');
|
|
|
|
end loop;
|
|
|
|
|
2013-07-02 22:15:26 +02:00
|
|
|
sdCarry <= '0';
|
|
|
|
sdZero <= '0';
|
|
|
|
|
|
|
|
elsif (rising_edge(iClk)) then
|
|
|
|
if (icLoadEn = '1') then
|
2013-07-26 12:33:01 +02:00
|
|
|
if (icPC = '0') then
|
|
|
|
registerFile(to_integer(unsigned(icRegINsel))) <= idDataIn;
|
|
|
|
else
|
|
|
|
registerFile(to_integer(unsigned(icRegINsel))) <= idPC;
|
|
|
|
end if;
|
2013-07-02 22:15:26 +02:00
|
|
|
sdCarry <= idCarryIn;
|
|
|
|
sdZero <= idZeroIn;
|
|
|
|
|
|
|
|
end if;
|
|
|
|
|
|
|
|
end if;
|
|
|
|
|
|
|
|
end process;
|
2013-07-04 16:17:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
odRegA <= registerFile(to_integer(unsigned(icRegAsel)));
|
|
|
|
odRegB <= registerFile(to_integer(unsigned(icRegBsel)));
|
2013-07-02 22:15:26 +02:00
|
|
|
odCarryOut <= sdCarry;
|
|
|
|
odZeroOut <= sdZero;
|
|
|
|
|
|
|
|
end Behavioral;
|
|
|
|
|