当前位置:网站首页>从底层结构开始学习FPGA----RAM IP的定制与测试
从底层结构开始学习FPGA----RAM IP的定制与测试
2022-07-01 05:31:00 【孤独的单刀】
文章目录
系列目录与传送门
在定制一个RAM IP核之前,强烈建议您先阅读:从底层结构开始学习FPGA----RAM IP核及关键参数介绍。在这篇文章中,已经对RAM IP核的各个关键因素做了详细的讲解。
1、RAM IP的定制
- 在新建一个工程后, 点击IP Catalog
- 点击后会出现 IP Catalog 页面,在 IP 核的搜索框中搜索 block
- 根据筛选,双击选择RAM & ROM 核“Block Memory Generator”
①、第一页
②、第二页
③、第三页
④、第四页
⑤、第五页
2、RAM IP的例化与仿真测试
2.1、例化一个RAM IP核
按上述步骤生成IP后,复制 IP核 自带的例化模板。
然后在我们的RTL代码中,例化生成一个4*16的SDP RAM。
该RTL不做其他功能,只例化RAM即可。
module test(
input clk, //输入时钟
input [3:0] data_in, //输入数据
input en_wr, //写使能信号
input en_rd, //读使能信号
input [3:0] addr_wr, //写地址
input [2:0] addr_rd, //读地址
input we_wr, //写使能
output [7:0] data_out //输出数据
);
//例化RAM IP核
ram_w4_d16 ram_w4_d16_inst (
//端口A--写端口
.clka (clk),
.ena (en_wr),
.wea (we_wr),
.addra (addr_wr),
.dina (data_in),
//端口B--读端口
.clkb (clk),
.enb (en_rd),
.addrb (addr_rd),
.doutb (data_out)
);
endmodule
2.2、仿真测试
写个testbench,对RAM IP测试一下。
测试行为:先往地址0-15写入数据0-15,然后从地址0-7读出数据(因为读数据位宽是写数据位宽的2倍,所以读数据一次会读出2个写地址的数据)。
`timescale 1ns / 1ns
module tb_test();
reg clk;
reg [3:0] data_in;
reg en_wr;
reg en_rd;
reg [3:0] addr_wr;
reg [2:0] addr_rd;
reg we_wr;
wire [7:0] data_out;
initial begin
clk = 0;
en_wr = 0;en_rd = 0;we_wr = 0;
data_in = 4'd0;
addr_wr = 4'd0;
addr_rd = 3'd0;
#110
en_wr = 1;we_wr = 1; //开始写入数据
repeat(15) begin //向地址0-15写入数据0-15
#10
data_in = data_in + 1;
addr_wr = addr_wr + 1;
end
#10
en_wr = 0; //停止写入数据
en_rd = 1;we_wr = 0; //开始读出数据
repeat(10) begin //从地址0-7读数据
#10 addr_rd = addr_rd + 1;
end
en_rd = 0; //停止读出数据
#20 $finish; //结束仿真
end
always #5 clk = ~clk; //生成时钟,周期10ns
//例化被测模块test
test test_inst(
.clk (clk ),
.data_in (data_in ),
.en_wr (en_wr ),
.en_rd (en_rd ),
.addr_wr (addr_wr ),
.addr_rd (addr_rd ),
.we_wr (we_wr ),
.data_out (data_out )
);
endmodule
使用vivado自带的仿真工具simulator运行仿真,仿真结果如下:
符合预期结果。
3、总结与参考
- 可以看到RAM IP的定制还是挺简单的,在了解其参数后,可以很快、很方便地例化一个自己需要的RAM模块。
- 创作不易,如果本文对您有帮助,还请多多点赞、评论和收藏。您的支持是我持续更新的最大动力!
边栏推荐
- 数据治理:数据治理框架(第一篇)
- Programmers dig "holes" to get rich: if they find a loophole, they will be rewarded 12.72 million yuan
- Worried about infringement? Must share copyrightless materials on the website. Don't worry about the lack of materials for video clips
- HDU - 1024 Max Sum Plus Plus(DP)
- Tar command
- Use and principle of reentrantlock
- What things you didn't understand when you were a child and didn't understand until you grew up?
- QT waiting box production
- 积分商城游戏能够给商家带来什么?怎么搭建积分商城?
- Youqitong [vip] v3.7.2022.0106 official January 22 Edition
猜你喜欢
TypeORM 框架
Use and principle of Park unpark
Set集合詳細講解
Memtable for leveldb source code analysis
Explanation of characteristics of hydraulic slip ring
[RootersCTF2019]babyWeb
el-cascader回显失败;el-cascader回显不出来
[RootersCTF2019]babyWeb
智慧运维:基于 BIM 技术的可视化管理系统
Is there any good website or software for learning programming? [introduction to programming]?
随机推荐
LRU cache for leveldb source code analysis
mysql 将毫秒数转为时间字符串
Memtable for leveldb source code analysis
Use and principle of reentrantlock
Flutter can refresh data every time the interface comes in
Detailed explanation of set
担心侵权?必备无版权素材网站分享,不用担心视频剪辑缺素材
在Rainbond中一键部署高可用 EMQX 集群
Rust基础入门之变量绑定与解构
Youqitong [vip] v3.7.2022.0106 official January 22 Edition
了解 JVM 中几个相关问题 — JVM 内存布局、类加载机制、垃圾回收
Spanner 论文小结
液压滑环的特点讲解
Ssgssrcsr differences
Series of improving enterprise product delivery efficiency (1) -- one click installation and upgrade of enterprise applications
[RootersCTF2019]babyWeb
Deeply understand the underlying implementation principle of countdownlatch in concurrent programming
Global and Chinese market of search engine optimization (SEO) software 2022-2028: Research Report on technology, participants, trends, market size and share
Explanation of characteristics of hydraulic slip ring
Application and principle of ThreadPoolExecutor thread pool