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

Subversion Repositories mipsr2000

[/] [mipsr2000/] [trunk/] [reg_file_block.vhd] - Blame information for rev 49

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jimi39
library IEEE;
2
use IEEE.std_logic_1164.all;
3
use IEEE.numeric_std.all;
4
--use IEEE.STD_LOGIC_ARITH.ALL;
5
use IEEE.STD_LOGIC_UNSIGNED.ALL;
6
 
7
entity Reg_file_block is
8
port(
9
                Clk : in std_logic;
10
                rst : in  STD_LOGIC;
11
                vector_on : in std_logic_vector(2 downto 0);
12
                Reg_Write : in std_logic;
13
                Reg_Imm_not : in std_logic;
14
                rs : in std_logic_vector(4 downto 0);
15
                rt : in std_logic_vector(4 downto 0);
16
                rd : in std_logic_vector(4 downto 0);
17
                Bus_W : in std_logic_vector(31 downto 0);
18
                Bus_A : out std_logic_vector(31 downto 0);
19
                Bus_B : out std_logic_vector(31 downto 0)
20
 
21
);
22
end entity Reg_file_block;
23
 
24
architecture Reg_file of Reg_file_block is  --Regfile_block
25
 
26
 
27
-- Declarations of Register File type & signal
28
type Regfile_type is array (natural range<>) of std_logic_vector(31 downto 0);
29
 
30
signal Regfile_Coff : Regfile_type(0 to 31):= ((others=> (others=>'0')));
31
signal Addr_in : std_logic_vector(4 downto 0);
32
signal Bus_A_reg,Bus_B_reg : std_logic_vector(31 downto 0);
33
begin
34
 
35
process(Clk,rst,Reg_Write,Reg_Imm_not,rs,rt,rd,Bus_W,Regfile_Coff,vector_on)
36
variable adr : std_logic_vector(4 downto 0):= "00000";
37
Constant A_vector : std_logic_vector(31 Downto 0) := "00001110000000000000000000011011";
38
Constant B_vector : std_logic_vector(31 Downto 0) := "00001100000000000000000000011011";
39
begin
40
-- Regfile_Read Assignments
41
if(FALLING_EDGE(Clk))then
42
        Bus_A_reg <= Regfile_Coff(conv_integer(rs));
43
        Bus_B_reg <= Regfile_Coff(conv_integer(rt));
44
end if;
45
 
46
-- Write Address Assignment
47
if (Reg_Imm_Not = '1') then
48
                Addr_in <= rd;
49
        elsif (Reg_Imm_Not = '0') then
50
                Addr_in <= rt;
51
end if;
52
-- Vector initialize
53
if (((vector_on or "110") = "111") and (rst = '0')) then
54
   if vector_on  = "001" then
55
     adr := "10010";
56
          Regfile_Coff(conv_integer(Adr)) <= A_vector;
57
   elsif vector_on  = "011" then
58
          adr := "10011";
59
          Regfile_Coff(conv_integer(Adr)) <= B_vector;
60
        elsif vector_on  = "101" then
61
          adr := "01010";
62
          Regfile_Coff(conv_integer(Adr)) <= A_vector;
63
   elsif vector_on  = "111" then
64
          adr := "10001";
65
          Regfile_Coff(conv_integer(Adr)) <= B_vector;
66
        end if;
67
end if;
68
-- Regfile_Write Assignments
69
if rst = '0' then
70
   Addr_in <= "00000";
71
elsif(RISING_EDGE(Clk))then
72
        if(Reg_Write = '1' and Addr_in /= "00000") then
73
                Regfile_Coff(conv_integer(Addr_in)) <= Bus_W;
74
        end if;
75
end if;
76
if rst = '0' then
77
Bus_A <= (others => '0');
78
Bus_B <= (others => '0');
79
elsif(RISING_EDGE(Clk))then
80
Bus_A<=Bus_A_reg;
81
Bus_B<=Bus_B_reg;
82
end if;
83
end process;
84
 
85
--------------------------------------------------------
86
end architecture Reg_file;

powered by: WebSVN 2.1.0

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