Академический Документы
Профессиональный Документы
Культура Документы
--**************************************************************************--
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
--**************************************************************************--
entity MIPS is
port( clk : in STD_LOGIC;
rst : in STD_LOGIC;
cs : in STD_LOGIC;
data : inout UNSIGNED(31 downto 0);
addr : out UNSIGNED(22 downto 0);
rd : out STD_LOGIC;
wr : out STD_LOGIC;
rdy : in STD_LOGIC;
hrq : in STD_LOGIC;
hlda : out STD_LOGIC );
end MIPS;
--**************************************************************************--
--
-- type declarations
--
subtype REG_TYPE is UNSIGNED(31 downto 0);
type REG_FILE_TYPE is array(0 to 31) of REG_TYPE;
type STATE_TYPE is ( RB_S, IF_S, IFNR_S, IF2_S, IF3_S, IDE_S, MEM_S,
MEM_READ1_S,
MEM_READ2_S, WB_S );
--
-- constant declarations
--
constant Z_32 : UNSIGNED(31 downto 0) :=
"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
--
-- signal declarations
--
signal state : STATE_TYPE;
signal reg_file : REG_FILE_TYPE;
signal pc_reg : UNSIGNED(22 downto 0);
signal inst_reg : REG_TYPE;
signal reg_write, mem_write, mem_read : STD_LOGIC;
signal reg_data, mem_data : UNSIGNED(31 downto 0);
signal mem_addr : UNSIGNED(22 downto 0);
signal reg_num : UNSIGNED(4 downto 0);
signal init, rb : STD_LOGIC;
begin
variable reg_data1,
reg_data2, add_result : UNSIGNED(31 downto 0);
begin
--
-- capture state
--
data <= Z_32;
addr <= Z_23;
rd <= '0';
wr <= '0';
init <= '0';
hlda <= '0';
rb <= '0';
--
-- steady state
--
case( state ) is
when LI =>
when GE =>
when EQ =>
add_result := reg_data1 +
reg_data2;
reg_data <= add_result;
--reg_file(
--
conv_integer(inst_reg(22 downto 18)))
-- +
reg_file(conv_integer
-- (inst_reg(17 downto
13)));
state <= MEM_S;
null;
end case;
reg_file(conv_integer(reg_num))
<= reg_data;
reg_write <= '0';
end if;
--**************************************************************************--
--**************************************************************************--
-- end of file --