📄 rom.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
package roms is
constant rom_width: integer:= 8 ;
subtype rom_word is std_logic_vector ( rom_width-1 downto 0 );
subtype rom_range is integer range 0 to 31;
type rom_table is array ( 0 to 31) of rom_word;
constant rom:rom_table := rom_table '(
("10101000"),("11100000"),( "00000000"),( "01110101"),
( "00000000"),( "00000000"),( "00000000"),( "00000000"),
( "00000000"),( "00000000"),( "00000000"),( "00000000"),
( "00000000"),( "00000000"),( "00000000"),( "00000000"),
( "00000000"),( "00000000"),( "00000000"),( "00000000"),
( "00000000"),( "00000000"),( "00000000"),( "00000000"),
( "00000000"),( "00000000"),( "00000000"),( "00000000"),
( "00000000"),( "00000000"),( "00000000"),( "00000000")
);
end roms;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
use work.roms.all;
entity rom_32 is
port ( addr: in std_logic_vector ( 4 downto 0 );
clk:in std_logic;
rd: in std_logic;
data: out std_logic_vector ( 7 downto 0 ));
end rom_32 ;
architecture behavior of rom_32 is
begin
output:process
begin
wait until clk'event and clk = '1';
if rd='1' then
data<= rom( conv_integer(addr)) ;
elsif rd = '0' then
data<= ( others=>'Z' );
end if ;
end process output ;
end behavior;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -