永发信息网

在网上找了下,发现都只有伪双口ram的vhdl程序,有谁知道真双口ram怎么做吗?求真双口ram的vhdl程序。谢!

答案:1  悬赏:80  手机版
解决时间 2021-03-31 12:41
在网上找了下,发现都只有伪双口ram的vhdl程序,有谁知道真双口ram怎么做吗?求真双口ram的vhdl程序。谢!
最佳答案
这是我以前写的一个标准双端口ram,可以作为单端口或者双端口用
library ieee;
use ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.all;
use IEEE.STD_LOGIC_UNSIGNED.all;

entity blk_mem is
generic(
data_width : integer := 8; -- used to change the memory data's width
addr_width : integer := 11); -- used to change the memery address' width
port (
clka : in std_logic;
dina : in std_logic_vector(data_width - 1 downto 0);
addra : in std_logic_vector(addr_width - 1 downto 0);
ena : in std_logic;
wea : in std_logic;
douta : out std_logic_vector(data_width - 1 downto 0);
clkb : in std_logic;
dinb : in std_logic_vector(data_width - 1 downto 0);
addrb : in std_logic_vector(addr_width - 1 downto 0);
enb : in std_logic;
web : in std_logic;
doutb : out std_logic_vector(data_width - 1 downto 0));
end blk_mem;

architecture blkmem of blk_mem is

type ram_template is array(2 ** addr_width - 1 downto 0) of std_logic_vector(data_width - 1 downto 0);
shared variable ram1 : ram_template;

begin -- blkmem

process (clka)
begin -- process
if clka'event and clka = '1' then -- rising clock edge
if ena = '1' then
douta <= ram1(conv_integer(addra));
if wea = '1' then
ram1(conv_integer(addra)) := dina;
end if;
else
douta <= (others => '0');
end if;
end if;
end process;

process (clkb)
begin -- process
if clkb'event and clkb = '1' then -- rising clock edge
if enb = '1' then
doutb <= ram1(conv_integer(addrb));
if web = '1' then
ram1(conv_integer(addrb)) := dinb;
end if;
else
doutb <= (others => '0');
end if;
end if;
end process;

end blkmem;追问如果A,B同时进行读写的时候,怎么办?不是会有冲突嘛。追答可以同时读写同一个地址,但是有优先的,一般是读优先
对AB的同时读写同一个地址是要你的控制部分避免的,
如果不是同一个地址的话就没问题
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
我记得有个什么徒手撕鬼子的电视,叫什么来的
做咖啡师有什么要求
多选题同种材料的甲、乙两木箱的质量之比为2:
湍字,词类活用意思是什么
如何应对劳动合同履行过程中出现的各种变化
世界上最白的人是谁
六野实体娃娃评测
法院协警和派出所协警的区别
健身很久了为什么纬度一点都没有变大
冷月居士业余爱好是什么?会写毛笔字吗?
请问,ms单刷MLD请教,单刷MLD要注意啥,是刷BS
来个淄博本地帮帮我
为什么才26岁就蛀了
我家灯是8瓦的,为什么我去买灯泡只看到7瓦和
半自动的奶茶封口机胶带太紧了怎么弄
推荐资讯
招商加盟玩偶需要多少钱
labview窗口里面的控件怎么随着窗口的大小改
泰语心怎么写
刚从鱼塘带回来的金鲤鱼放进鱼缸怎么鱼老是跳
中国传媒大学南广学院是重本院校吗?
皇帝拉石头 图片猜谜 打一成语
YZR200L6 22kw电机用YZR200L8 15kw电阻器有什
淘宝违规节点处理是什么意思
济南兴牛牛奶怎么样
2019年退休90学时还要培训吗?
是什么原因导致汉元帝未老先衰,不到四十岁便
什么什么真实我难忘作文250字
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?