URL
https://opencores.org/ocsvn/uart2bus/uart2bus/trunk
Go to most recent revision |
Details |
Compare with Previous |
View Log
| Line No. |
Rev |
Author |
Line |
| 1 |
6 |
smuller |
-----------------------------------------------------------------------------------------
|
| 2 |
|
|
-- register file model as a simple memory
|
| 3 |
|
|
--
|
| 4 |
|
|
-----------------------------------------------------------------------------------------
|
| 5 |
|
|
library ieee;
|
| 6 |
|
|
use ieee.std_logic_1164.ALL;
|
| 7 |
|
|
use ieee.std_logic_unsigned.all;
|
| 8 |
|
|
|
| 9 |
|
|
entity regFileModel is
|
| 10 |
|
|
port ( -- global signals
|
| 11 |
|
|
clr : in std_logic; -- global reset input
|
| 12 |
|
|
clk : in std_logic; -- global clock input
|
| 13 |
|
|
-- internal bus to register file
|
| 14 |
|
|
intAddress : in std_logic_vector(7 downto 0); -- address bus to register file
|
| 15 |
|
|
intWrData : in std_logic_vector(7 downto 0); -- write data to register file
|
| 16 |
|
|
intWrite : in std_logic; -- write control to register file
|
| 17 |
|
|
intRead : in std_logic; -- read control to register file
|
| 18 |
|
|
intRdData : out std_logic_vector(7 downto 0)); -- data read from register file
|
| 19 |
|
|
end regFileModel;
|
| 20 |
|
|
|
| 21 |
|
|
architecture Behavioral of regFileModel is
|
| 22 |
|
|
|
| 23 |
|
|
type RAM is array (integer range <>)of std_logic_vector (7 downto 0);
|
| 24 |
|
|
signal regFile : RAM (0 to 255);
|
| 25 |
|
|
|
| 26 |
|
|
begin
|
| 27 |
|
|
-- register file write
|
| 28 |
|
|
process (clr, clk)
|
| 29 |
|
|
begin
|
| 30 |
|
|
if (clr = '1') then
|
| 31 |
|
|
for index in 0 to 255 loop
|
| 32 |
|
|
regFile(index) <= (others => '0');
|
| 33 |
|
|
end loop;
|
| 34 |
|
|
elsif (rising_edge(clk)) then
|
| 35 |
|
|
if (intWrite = '1') then
|
| 36 |
|
|
regFile(conv_integer(intAddress)) <= intWrData;
|
| 37 |
|
|
end if;
|
| 38 |
|
|
end if;
|
| 39 |
|
|
end process;
|
| 40 |
|
|
-- register file read
|
| 41 |
|
|
process (clr, clk)
|
| 42 |
|
|
begin
|
| 43 |
|
|
if (clr = '1') then
|
| 44 |
|
|
intRdData <= (others => '0');
|
| 45 |
|
|
elsif (rising_edge(clk)) then
|
| 46 |
|
|
if (intRead = '1') then
|
| 47 |
|
|
intRdData <= regFile(conv_integer(intAddress));
|
| 48 |
|
|
end if;
|
| 49 |
|
|
end if;
|
| 50 |
|
|
end process;
|
| 51 |
|
|
end Behavioral;
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.