个人觉得学好VHDL,最主要的还是实践,如果原先有一点C语言基础,VHDL就不难学,多自行练几次就没问题了!!可以先熟悉语法,了解一些逻辑功能,然后再上网或者在书上找一些小项目做做,最好是手头上自已有实验板,多做几次就OK了!!!
以下是你要求的程序,至于读写速度,主要就是看读时钟和写时钟,哪个频率快,就哪个快了!!!
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
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载