⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ram.vhd

📁 在quartus开发环境下
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ram is
port(addr:in std_logic_vector(4 downto 0);--------地址选择信号
     wr:in std_logic;-----------------------------写信号
     rd:in std_logic;-----------------------------读信号
     cs:in std_logic;-----------------------------片选信号
     datain:in std_logic_vector(7 downto 0);------数据输入端
     dataout:out std_logic_vector(7 downto 0));---数据输出端
end;
architecture one of ram is
	type memory is array(0 to 31)of std_logic_vector(7 downto 0);-------定义数据类型
	signal data1:memory;
	signal addr1:integer range 0 to 31;
begin
	addr1<=conv_integer(addr);-----二进制到十进制的转换
process(wr,cs,addr1,data1,datain)------------------------写操作
begin
   if cs='0' and wr='1' then 
      data1(addr1)<=datain;
    end if;
end process;
process(rd,cs,addr1,data1)---------读操作
begin
if cs='0' and rd='1' then
     dataout<=data1(addr1);
else
     dataout<=(others=>'Z');
end if;
end process;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -