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

Subversion Repositories uos_processor

[/] [vhdl/] [cpuregbank.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 droggen
-- CPU register banks holding the 4 CPU registers.
2
-- This is used to simplify the reading and writing to registers
3
-- by allowing to address them with a 2-bit address and enable signal.
4
 
5
library IEEE;
6
use IEEE.STD_LOGIC_1164.ALL;
7
 
8
entity cpuregbank is
9
        port(
10
                clk : in STD_LOGIC;
11
                rrd1 : in STD_LOGIC_VECTOR(1 downto 0);
12
                rrd2 : in STD_LOGIC_VECTOR(1 downto 0);
13
                rwr : in STD_LOGIC_VECTOR(1 downto 0);
14
                rwren : in STD_LOGIC;
15
                rst : in STD_LOGIC;
16
                d : in STD_LOGIC_VECTOR(7 downto 0);
17
                q1 : out STD_LOGIC_VECTOR(7 downto 0);
18
                q2 : out STD_LOGIC_VECTOR(7 downto 0);
19
                -- Only for debugging
20
                dbg_qa : out STD_LOGIC_VECTOR(7 downto 0);
21
                dbg_qb : out STD_LOGIC_VECTOR(7 downto 0);
22
                dbg_qc : out STD_LOGIC_VECTOR(7 downto 0);
23
                dbg_qd : out STD_LOGIC_VECTOR(7 downto 0)
24
                );
25
 
26
end cpuregbank;
27
 
28
architecture Behavioral of cpuregbank is
29
        signal enables: STD_LOGIC_VECTOR(3 downto 0);
30
        signal qa,qb,qc,qd: STD_LOGIC_VECTOR(7 downto 0);
31
begin
32
 
33
        ra: entity work.dffre generic map (N=>8) port map(clk=>clk,en=>enables(0),rst=>rst,d=>d,q=>qa);
34
        rb: entity work.dffre generic map (N=>8) port map(clk=>clk,en=>enables(1),rst=>rst,d=>d,q=>qb);
35
        rc: entity work.dffre generic map (N=>8) port map(clk=>clk,en=>enables(2),rst=>rst,d=>d,q=>qc);
36
        rd: entity work.dffre generic map (N=>8) port map(clk=>clk,en=>enables(3),rst=>rst,d=>d,q=>qd);
37
 
38
        with rwr select
39
                enables <=      "0001" and rwren&rwren&rwren&rwren when "00",
40
                                                "0010" and rwren&rwren&rwren&rwren when "01",
41
                                                "0100" and rwren&rwren&rwren&rwren when "10",
42
                                                "1000" and rwren&rwren&rwren&rwren when others;
43
 
44
        with rrd1 select
45
                q1 <=   qa when "00",
46
                                qb when "01",
47
                                qc when "10",
48
                                qd when others;
49
 
50
        with rrd2 select
51
                q2 <=   qa when "00",
52
                                qb when "01",
53
                                qc when "10",
54
                                qd when others;
55
 
56
        -- Only for debugging
57
        dbg_qa <= qa;
58
        dbg_qb <= qb;
59
        dbg_qc <= qc;
60
        dbg_qd <= qd;
61
 
62
end Behavioral;
63
 

powered by: WebSVN 2.1.0

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