双口RAM的VHDL描述

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。


library ieee;
use ieee.std_logic_1164.all; --调用常用的程序包
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity ram_test is --定义实体
generic(width:integer :=8;length:integer:=8); --根据这个来改变RAM的大小,width为数据长度,length为数据个数
port(r_clk,w_clk:in std_logic;---定义写时钟和读时钟
r_add,w_add:in std_logic_vector(2 downto 0);--写地址和读地址
r_en,w_en:in std_logic;--读使能和写使能
d_in:in std_logic_vector(width-1 downto 0);--数据输入
d_out:out std_logic_vector(width-1 downto 0));--数据输出
end entity;
architecture art of ram_test is
type memory is array (0 to length-1) of std_logic_vector(width-1 downto 0);---定义一数组类型来存储数据
signal data:memory;
begin
process(w_clk,w_add,w_en,d_in)--写数据进程
begin
if w_clk'event and w_clk='1' then--在时钟上升沿来时
if w_en='1' then --若使能为1,则写数据
data(conv_integer(w_add))<=d_in;
end if;
end if;
end process;
process(r_clk,r_add,r_en,data)--读数据进程
begin
if r_clk'event and r_clk='1' then
if r_en='1' then
d_out<=data(conv_integer(r_add));
end if;
end if;
end process;
end art;

相关文档
最新文档