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

Subversion Repositories layer2

[/] [layer2/] [trunk/] [vhdl/] [cpu/] [rtl/] [gpr.vhd] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 idiolatrie
--------------------------------------------------------------------------------
2
-- MIPS™ I CPU - General Purpose Register                                     --
3
--------------------------------------------------------------------------------
4
-- Copyright (C)2011  Mathias Hörtnagl <mathias.hoertnagl@gmail.comt>         --
5
--                                                                            --
6
-- This program is free software: you can redistribute it and/or modify       --
7
-- it under the terms of the GNU General Public License as published by       --
8
-- the Free Software Foundation, either version 3 of the License, or          --
9
-- (at your option) any later version.                                        --
10
--                                                                            --
11
-- This program is distributed in the hope that it will be useful,            --
12
-- but WITHOUT ANY WARRANTY; without even the implied warranty of             --
13
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              --
14
-- GNU General Public License for more details.                               --
15
--                                                                            --
16
-- You should have received a copy of the GNU General Public License          --
17
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.      --
18
--------------------------------------------------------------------------------
19
library ieee;
20
use ieee.std_logic_1164.all;
21
use ieee.numeric_std.all;
22
 
23
entity gpr is
24
   port(
25
      clk_i : in  std_logic;
26
      hld_i : in  std_logic;
27
      rs_a  : in  std_logic_vector(4 downto 0);
28
      rt_a  : in  std_logic_vector(4 downto 0);
29
      rd_a  : in  std_logic_vector(4 downto 0);
30
      rd_we : in  std_logic;
31
      rd_i  : in  std_logic_vector(31 downto 0);
32
      rs_o  : out std_logic_vector(31 downto 0);
33
      rt_o  : out std_logic_vector(31 downto 0)
34
   );
35
end gpr;
36
 
37
architecture rtl of gpr is
38
 
39
   type gpr_t is array (0 to 31) of std_logic_vector(31 downto 0);
40
   signal gpr : gpr_t := (others => (others => '0'));
41
 
42
   attribute RAM_STYLE : string;
43
   attribute RAM_STYLE of gpr: signal is "BLOCK";
44
begin
45
 
46
   reg : process(clk_i)
47
   begin
48
      if rising_edge(clk_i) then
49
         if (hld_i = '0') then
50
 
51
            -- Save data only if it's register address is not zero.
52
            -- Keeps register $0 zero.
53
            if (rd_we = '1') and (rd_a /= "00000") then
54
               gpr( to_integer(unsigned(rd_a)) ) <= rd_i;
55
            end if;
56
            rs_o <= gpr( to_integer(unsigned(rs_a)) );
57
            rt_o <= gpr( to_integer(unsigned(rt_a)) );
58
         end if;
59
      end if;
60
   end process;
61
end rtl;

powered by: WebSVN 2.1.0

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