URL
https://opencores.org/ocsvn/tinycpu/tinycpu/trunk
[/] [tinycpu/] [trunk/] [src/] [registerfile.vhd] - Blame information for rev 5
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
2 |
earlz |
library IEEE;
|
2 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
3 |
|
|
use IEEE.NUMERIC_STD.ALL;
|
4 |
|
|
use ieee.std_logic_unsigned.all;
|
5 |
|
|
|
6 |
|
|
entity registerfile is
|
7 |
|
|
port(
|
8 |
5 |
earlz |
Write1:in std_logic_vector(7 downto 0); --what should be put into the write register
|
9 |
|
|
Write2: in std_logic_vector(7 downto 0);
|
10 |
|
|
SelRead1:in std_logic_vector(3 downto 0); --select which register to read
|
11 |
|
|
SelRead2: in std_logic_vector(3 downto 0); --select second register to read
|
12 |
|
|
SelWrite1:in std_logic_vector(3 downto 0); --select which register to write
|
13 |
|
|
SelWrite2:in std_logic_vector(3 downto 0);
|
14 |
|
|
UseWrite1:in std_logic; --if the register should actually be written to
|
15 |
|
|
UseWrite2: in std_logic;
|
16 |
2 |
earlz |
Clock:in std_logic;
|
17 |
3 |
earlz |
Read1:out std_logic_vector(7 downto 0); --register to be read output
|
18 |
|
|
Read2:out std_logic_vector(7 downto 0) --register to be read on second output
|
19 |
2 |
earlz |
);
|
20 |
|
|
end registerfile;
|
21 |
|
|
|
22 |
|
|
architecture Behavioral of registerfile is
|
23 |
5 |
earlz |
type registerstype is array(0 to 15) of std_logic_vector(7 downto 0);
|
24 |
2 |
earlz |
signal registers: registerstype;
|
25 |
|
|
begin
|
26 |
5 |
earlz |
writereg: process(Write1, Write2, SelWrite1, SelWrite2, UseWrite1, UseWrite2, Clock)
|
27 |
2 |
earlz |
begin
|
28 |
5 |
earlz |
if(UseWrite1='1') then
|
29 |
2 |
earlz |
if(rising_edge(clock)) then
|
30 |
5 |
earlz |
registers(conv_integer(SelWrite1)) <= Write1;
|
31 |
2 |
earlz |
end if;
|
32 |
|
|
end if;
|
33 |
5 |
earlz |
if(UseWrite2='1') then
|
34 |
|
|
if(rising_edge(clock) and conv_integer(SelWrite1)/=conv_integer(SelWrite2)) then
|
35 |
|
|
registers(conv_integer(SelWrite2)) <= Write2;
|
36 |
|
|
end if;
|
37 |
|
|
end if;
|
38 |
2 |
earlz |
end process;
|
39 |
3 |
earlz |
Read1 <= registers(conv_integer(SelRead1));
|
40 |
|
|
Read2 <= registers(conv_integer(SelRead2));
|
41 |
2 |
earlz |
end Behavioral;
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.