日常记录(66)设计
2022/2/28 23:24:40
本文主要是介绍日常记录(66)设计,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
module的参数例化
module async_fifo #(parameter FIFO_PTR = 4, FIFO_WIDTH = 32)([port_list])
格雷码转换与generate结构
generate语句可以配合genvar实现将assign语句进行并行化处理。否则有有以下提示:
Generate for loop index variable must be a genvar.
Please refer to LRM (1364-2005), section 12.4.1 "Loop generate constructs".
一段错误的代码
格雷码转换代码与测试:
代码中若不延时1个时间单位(i赋值后),则导致输出无法按时获得。
这个代码似乎是将二进制转换为了格雷码,
module grey2bin #(parameter PTR=6)(grey_value, bin_value); input [PTR:0] grey_value; output [PTR:0] bin_value; /* wire [PTR:0] bin_value; */ assign bin_value[PTR] = grey_value[PTR]; generate genvar i; for (i = 0; i < PTR; i=i+1) begin assign bin_value[i] = grey_value[i+1] ^ grey_value[i]; end endgenerate endmodule module test_case (); reg [3:0] input_data; wire [3:0] output_data; grey2bin #(3) g2b(input_data, output_data); initial begin bit [4:0] i; bit [3:0] arr[$]; assign input_data = i; for (i = 0; i < 16 ; i=i+1) begin #1; $display("%04b, output is grey :%04b",i, output_data); arr.push_back(output_data); end $display("-----------------------------------------------"); foreach (arr[j]) begin i = arr[j]; #1; $display("%04b, output is binary :%04b",i, output_data); end $finish(); end endmodule
输出结果:
0000, output is grey :0000 0001, output is grey :0001 0010, output is grey :0011 0011, output is grey :0010 0100, output is grey :0110 0101, output is grey :0111 0110, output is grey :0101 0111, output is grey :0100 1000, output is grey :1100 1001, output is grey :1101 1010, output is grey :1111 1011, output is grey :1110 1100, output is grey :1010 1101, output is grey :1011 1110, output is grey :1001 1111, output is grey :1000 ----------------------------------------------- 0000, output is binary :0000 0001, output is binary :0001 0011, output is binary :0010 0010, output is binary :0011 0110, output is binary :0101 0111, output is binary :0100 0101, output is binary :0111 0100, output is binary :0110 1100, output is binary :1010 1101, output is binary :1011 1111, output is binary :1000 1110, output is binary :1001 1010, output is binary :1111 1011, output is binary :1110 1001, output is binary :1101 1000, output is binary :1100
这篇关于日常记录(66)设计的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2025-01-07如何利用看板工具优化品牌内容创作与审批,确保按时发布?
- 2025-01-07百万架构师第十一课:源码分析:Spring 源码分析:Spring源码分析前篇|JavaGuide
- 2025-01-07质量检测标准严苛,这 6 款办公软件达标了吗?
- 2025-01-07提升品牌活动管理的效率:看板工具助力品牌活动日历的可视化管理
- 2025-01-07宠物商场的精准营销秘籍:揭秘看板软件的力量
- 2025-01-07“30了,资深骑手” | 程序员能有什么好出路?
- 2025-01-07宠物公园的营销秘籍:看板软件如何帮你精准触达目标客户?
- 2025-01-07从任务分解到资源优化:甘特图工具全解析
- 2025-01-07企业升级必备指南:从传统办公软件到SaaS工具的转型攻略
- 2025-01-07一文告诉你IT项目管理如何做到高效