我是靠谱客的博主 伶俐大雁,这篇文章主要介绍Verilog 学习笔记,现在分享给大家,希望可以做个参考。

Q1. 关于在书写testbench时,如何使用$readmemb / $readmenh 来实现从文件(格式:txt、dat)读取数据,并完成赋值。
A1. $readmemb / $readmenh 使用起来较为简单,直接上代码。

注意:最好将*.v 和* .txt放在同一工程目录下,以防止EDA工具找不到txt文 件

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
reg signed [11:0] fir_input_re ; reg [11:0] mem_factor[0:40];//difine a memory, the deepth is 41 by **[0:40]**, the data width is 12bit by **[11:0]** integer i;//Define an integer variable //==========generate mem_factor==========// initial begin $readmemh( "fir_factor_81_upsample8.txt", mem_factor);//read hex data from *.txt for(i = 0; i < 41 ; i = i + 1) $display("reg_factor[%d] = %h", i, mem_factor[i]);// we can check whether complete $readmenh,by using $display. end //==========valuation========== //valuing, at realtime 0 initial begin fir_factor0 = mem_factor[0] ; fir_factor1 = mem_factor[1] ; fir_factor2 = mem_factor[2] ; fir_factor3 = mem_factor[3] ; fir_factor4 = mem_factor[4] ; end

最后

以上就是伶俐大雁最近收集整理的关于Verilog 学习笔记的全部内容,更多相关Verilog内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(93)

评论列表共有 0 条评论

立即
投稿
返回
顶部