xilinx和altera单双口RAM的配置解析

首先看ALTERA的RAM配置和说明

下面是quartus2 下的双口RAM的IP配置设置界面

单双口RAM

简单双口ram:其实就是有一组读数据和读地址线,一组写数据和写地址线,
所以能同时进行读和写操作,但不能同时对同一地址进行读和写操作。

配置界面:
在这里插入图片描述

在这里插入图片描述

这个图比上一个图多了rden读使能信号,这不是必须信号。当使用rden信号时,此信号高电平有效,当不使用rden信号时,给定地址,对应数据会在时钟下一个上升沿从q端输出

下面是altera的一个简单双口RAM

在这里插入图片描述

在简单的双端口模式下,M9K存储模块支持单独的写和读信号。 不读取时,可以通过将rden信号保持为低电平(无效)来节省功耗。 如果创建了读使能端口并执行了写操作,但是读使能没激活,那么输出会保持最近一次读使能激活时的值,如下图1处。如果在写操作期间激活了读使能,或者未创建读使能信号,那么给定读地址,对应数据会在时钟下一个上升沿从q端输出,如下图2处。对同一地址的读写操作可以在该位置输出“无效”数据,也可以输出“旧数据”。 要选择所需的行为,请在Quartus II软件的RAM MegaWizard Plug-In Manager中将Read-During-Write选项设置为Don’t Care或Old Data。

官方文档说明
Memory Blocks in Cyclone IV Devices, Cyclone IV Device Handbook, Volume 1, Chapter 3.
Internal Memory (RAM and ROM) User Guide

During a write operation, the behavior of the RAM outputs is configurable. If you activate rden during a write operation, the RAM outputs show either the new data being written or the old data at that address. If you perform a write operation with
rden deactivated, the RAM outputs retain the values they held during the most recent active rden signal.To choose the desired behavior, set the Read-During-Write option to either New Data or Old Data in the RAM MegaWizard Plug-In Manager in the Quartus II software.

在这里插入图片描述

下面是一个真双口RAM

真双口ram:有两组数据线与地址线
能同时进行两个端口读
能同时进行两个端口写
能同时一个端口读同时另一个端口写
这个真双口ram 其实就是两个单口ram组合在一起构成的,只是真双口ram里的两个单口ram是操作的同一片存储空间。
配置界面:
在这里插入图片描述
在这里插入图片描述

官方的读取写入时序图

In true dual-port mode, M9K memory blocks support separate wren and rden signals.You can save power by keeping the rden signal low (inactive) when not reading.Read-during-write operations to the same address can either output “New Data” at
that location or “Old Data”. To choose the desired behavior, set the Read-During-Write option to either New Data or Old Data in the RAM MegaWizard Plug-In Manager in the Quartus II software. In true dual-port mode, you can access any memory location at any time from either port A or port B. However, when accessing the same memory location from both ports, you must avoid possible write conflicts. When you attempt to write to the same address location from both ports at the same time, a write conflict happens. This results in unknown data being stored to that address location. There is no conflict resolution circuitry built into the Cyclone IV devices M9K memory blocks. You must handle address conflicts external to the RAM block.

在真正的双端口模式下,M9K存储模块支持单独的wren和rden信号。您可以通过在不读取时将rden信号保持为低电平(无效)来节省功耗。对同一地址的读写过程可以输出“新数据” ”或“旧数据”。 要选择所需的行为,请在Quartus II软件的RAM MegaWizard插件管理器中将Read-DuringWrite选项设置为New Data或Old Data。在真正的双端口模式下,您可以随时从端口A或端口B访问任何内存位置。但是,从两个端口访问相同的内存位置时,必须避免可能的写冲突。 当您尝试同时从两个端口写入同一地址位置时,会发生写冲突。 这导致未知数据被存储到该地址位置。 Cyclone IV器件M9K存储模块中没有内置冲突解决电路。 您必须处理RAM块外部的地址冲突。
在这里插入图片描述

下面是一个单口ram

单口ram:只有一组数据线和地址线,所以不能同时进行读写操作。即同一时刻要么读要么写。
配置界面:
在这里插入图片描述
在这里插入图片描述

单口RAM读写时序图

During a write operation, the behavior of the RAM outputs is configurable. If you activate rden during a write operation, the RAM outputs show either the new data being written or the old data at that address. If you perform a write operation with rden deactivated, the RAM outputs retain the values they held during the most recent active rden signal.To choose the desired behavior, set the Read-During-Write option to either New Data or Old Data in the RAM MegaWizard Plug-In Manager in the Quartus II software.

在写操作期间,RAM输出的行为是可配置的。 如果在写操作期间激活rden,则RAM输出将在该地址显示正在写入的新数据或旧数据。 如果在禁用rden的情况下执行写操作,则RAM输出将保留在最近激活rden信号期间保持的值。要选择所需的行为,请在Quartus II软件中的MegaWizard插件管理器中将RAM中的Read-During-Write选项设置为New Data或Old Data。
在这里插入图片描述

下面来看xilinx的RAM配置和说明

下图是vivado下创建单双口RAM配置界面
在这里插入图片描述

在简单双端口ram中最简单有9个端口:分别是

clka 为输入端口的时钟
wea 端口A写使能
addra 端口A写地址
dina 待写入的数据
clkb 为输出端口时钟
addrb 端口B读地址
doutb 读出的数据
在这里插入图片描述
在ip核中还可以加入ena/enb端口,这两个端口的作用是控制端口A和B的时钟使能,Enables Read, Write, and reset operations
Optional in all configurations.

可以看到端口A可以被配置为三种模式,下面具体介绍
在这里插入图片描述

下面是一个读时钟使能一直有效的仿真图,问题是由于读使能一直有效那么在0地址的时候,刚好又要写,就会出现冲突,但是仿真更新了这个255数值,我认为是类似于写优先模式,在0地址写入的同时,输出储存进来的数据255.
在这里插入图片描述

在这里插入图片描述
简单双端口RAM就像真正的双端口RAM,其中仅连接了A端口的Write接口和B端口的Read接口。 工作模式定义了A或B端口的读写关系,并且仅在地址冲突期间影响A端口和B端口之间的关系。对于同步时钟和冲突期间,可以配置端口A的写模式,以便于端口B读取时产生数据(行为类似于READ_FIRST),要么生成未定义的数据(Xs)。 因此,始终建议在配置为简单双端口RAM时使用READ_FIRST。 对于异步时钟,Xilinx建议将端口A的写入模式设置为WRITE_FIRST以确保冲突安全。

这三种模式具体介绍
当A和B端口地址发生冲突时,工作模式会影响A和B端口之间的关系,这对于RAM都是一样的。

1.写优先模式(write first mode):

在写优先模式中,输入数据被自动写入存储器件中,并且出现在数据输出端口。时序见下图。这种传输模式增强了在同一端口写操作时使用数据输出总线的灵活性。(即输入数据的同时自动写进存储器和驱动数据到数据输出端)
在这里插入图片描述

2.读优先模式(read first mode):

在读优先模式中,预先存储在写地址中的数据会被输出,而输入数据被存入存储器件中。这种模式见下图。(即以前写进当前写地址的数据出现在数据输出端,此时输入的数据被保存到存储器中)
在这里插入图片描述

3.不变模式(no-change mode):

在不变模式中,输出锁存器在写操作时候保持不变,见下图。在同一端口的写操作不会对数据输出端口产生影响,输出仍然是以前的读数据。(即输出锁存器在写操作期间保持不改变。说明在写期间输出端不会输出写期间地址的数据,不管以前保存数据还是现在的输入数据)

在这里插入图片描述

下面是真双口RAM的模块图

不进行具体介绍
在这里插入图片描述

最后附上单口RAM的仿真图

单端口RAM通过一个端口对存储进行读写访问
通过下图的仿真可以看到,数据读端口douta一直都有输出对应地址的数据,一直在读,当wea拉高时,会将数据写入对应的地址,仿真选择的Operating Mode是Write First,所以wea拉高时douta输出的数据与此时写入的数据是一致的。所以单端口RAM的读写不能同时进行。延迟是由于IP设置里加入了流水线。
在这里插入图片描述
在这里插入图片描述

  • 6
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值