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

Subversion Repositories marca

[/] [marca/] [tags/] [INITIAL/] [vhdl/] [regfile.vhd] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 jeunes2
--  This file is part of the marca processor.
2
--  Copyright (C) 2007 Wolfgang Puffitsch
3
 
4
--  This program is free software; you can redistribute it and/or modify it
5
--  under the terms of the GNU Library General Public License as published
6
--  by the Free Software Foundation; either version 2, or (at your option)
7
--  any later version.
8
 
9
--  This program is distributed in the hope that it will be useful,
10
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
--  Library General Public License for more details.
13
 
14
--  You should have received a copy of the GNU Library General Public
15
--  License along with this program; if not, write to the Free Software
16
--  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
17
 
18
-------------------------------------------------------------------------------
19
-- MARCA decode stage
20
-------------------------------------------------------------------------------
21
-- architecture for the instruction-decode pipeline stage
22
-------------------------------------------------------------------------------
23
 
24
-------------------------------------------------------------------------------
25
-- Wolfgang Puffitsch
26
-- Computer Architecture Lab, Group 3
27
-------------------------------------------------------------------------------
28
 
29
library IEEE;
30
use IEEE.std_logic_1164.all;
31
use IEEE.numeric_std.all;
32
 
33
use work.marca_pkg.all;
34
 
35
architecture behaviour of regfile is
36
 
37
type registers is array (REG_COUNT-1 downto 0) of std_logic_vector(REG_WIDTH-1 downto 0);
38
 
39
signal regs, next_regs : registers;
40
 
41
begin  -- behaviour
42
 
43
  syn_proc: process (clock, reset)
44
  begin  -- process syn_proc
45
    if reset = RESET_ACTIVE then                 -- asynchronous reset (active low)
46
      regs <= (others => (others => '0'));
47
    elsif clock'event and clock = '1' then  -- rising clock edge
48
      if hold = '0' then
49
        regs <= next_regs;
50
      end if;
51
    end if;
52
  end process syn_proc;
53
 
54
  forward: process(rd1_addr, rd2_addr, wr_ena, wr_addr, wr_val, regs)
55
  begin  -- process forward
56
 
57
    next_regs <= regs;
58
 
59
    if wr_ena = '1' then
60
      next_regs(to_integer(unsigned(wr_addr))) <= wr_val;
61
    end if;
62
 
63
    if rd1_addr /= wr_addr or wr_ena = '0' then
64
      rd1_val <= regs(to_integer(unsigned(rd1_addr)));
65
    else
66
      rd1_val <= wr_val;
67
    end if;
68
 
69
    if rd2_addr /= wr_addr or wr_ena = '0' then
70
      rd2_val <= regs(to_integer(unsigned(rd2_addr)));
71
    else
72
      rd2_val <= wr_val;
73
    end if;
74
 
75
  end process forward;
76
 
77
end behaviour;

powered by: WebSVN 2.1.0

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