list_ch04_06_reg_file.vhd
来自「VHDL FFT SOURCECODE great one」· VHDL 代码 · 共 36 行
VHD
36 行
-- Listing 4.6
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity reg_file is
generic(
B: integer:=8; -- number of bits
W: integer:=2 -- number of address bits
);
port(
clk, reset: in std_logic;
wr_en: in std_logic;
w_addr, r_addr: in std_logic_vector (W-1 downto 0);
w_data: in std_logic_vector (B-1 downto 0);
r_data: out std_logic_vector (B-1 downto 0)
);
end reg_file;
architecture arch of reg_file is
type reg_file_type is array (2**W-1 downto 0) of
std_logic_vector(B-1 downto 0);
signal array_reg: reg_file_type;
begin
process(clk,reset)
begin
if (reset='1') then
array_reg <= (others=>(others=>'0'));
elsif (clk'event and clk='1') then
if wr_en='1' then
array_reg(to_integer(unsigned(w_addr))) <= w_data;
end if;
end if;
end process;
-- read port
r_data <= array_reg(to_integer(unsigned(r_addr)));
end arch;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?