
Verilog系列教程
文章平均质量分 63
Verilog系列教程
whik1194
这个作者很懒,什么都没留下…
展开
-
Verilog parameter 参数
文章目录语法注意示例:支持递增或递减的计数器localparamVerilog支持使用参数来指定数据位宽或表示某些有特殊含义的常量,可以便于实现模块的通用性和以后的维护,对于同一个模块,可以通过指定不同的参数值来实现不同的功能,比如通过改变加法器模块的数据位宽来实现4/8/16位数据操作,类似函数调用时传入的不同参数。语法parameter [type] [range] [name] = [constant value]; 例如:parameter msb = 7;原创 2021-03-12 23:13:17 · 12442 阅读 · 0 评论 -
Verilog for 循环
文章目录语法示例#1:基本循环控制示例#2:8位左移移位寄存器的实现语法for(<initial_condition>;<condition>;<step_assignment>)begin //statements end执行过程如下:指定初始循环变量值条件是否为真,条件为假则跳出循环若条件为真则执行控制语句循环变量迭代更新示例#1:基本循环控制module my_design; integer i; initial begin原创 2021-03-12 19:04:23 · 30933 阅读 · 0 评论 -
Verilog task 任务
文章目录语法静态task的定义静态调用示例automatic示例全局tasktask和function的区别禁止任务语法function可以对输入数据进行处理,并返回一个值,而task更通用,可以计算出多个值,可以使用output或inout参数类型,task可以包含仿真时间控制,例如@,posedge等。// Style 1task [name]; input [port_list]; inout [port_list]; output [port_list];原创 2021-03-12 19:47:54 · 4946 阅读 · 0 评论 -
Verilog function 函数
文章目录语法函数的定义函数的调用递归调用语法function [automatic] [return_type]name([port_list]); [statements]endfunctionVerilog中的Function函数和C中的函数非常类似,它可以根据你的输入,返回计算的结果,函数的实现只能是组合逻辑,不能包括时间控制,例如#100,可以指定返回值的类型,应该包含至少1个输入,输入只能是input类型,不能是inout或output,只能返回一个值。函数的定义支持以下两种原创 2021-03-12 19:24:28 · 3955 阅读 · 0 评论 -
Verilog `ifdef 条件编译
文章目录语法格式示例#1:ifdef示例#2:ifdef和elsif示例#3:ifndef和elsif示例#4:ifdef的嵌套Verilog支持编译器指令,可以通过编译器指令选择部分代码是否被使用。语法格式关键字主要有以下几种:ifdef、ifndef、else、elsif、endif和define主要以下几种格式://style #1:Only singleifdef`ifdef <FLAG> //statements`endif// style #2:ifdef原创 2021-03-12 18:35:45 · 12597 阅读 · 0 评论 -
Verilog math 数学函数
文章目录示例常用数学函数仿真文件运行结果Verilog中的数学函数可以用来代替常量表达式,支持整数和实数。示例module des #(parameter NUM_UNITS = 7) // Use of this system function helps to reduce the // number of input wires to this module (input [$clog2(NUM_UNITS)-1:0] active_un原创 2021-03-12 23:22:23 · 5391 阅读 · 1 评论 -
Verilog 二进制转BCD码
Binary to BCD ConverterFrom: Binary to BCD Converter (johnloomis.org)Shift and Add-3 AlgorithmShift the binary number left one bit.If 8 shifts have taken place, the BCD number is in the Hundreds, Tens, and Units column.If the binary value in any of t原创 2021-07-20 10:11:44 · 2739 阅读 · 0 评论 -
全平台轻量开源verilog仿真工具iverilog+GTKWave使用教程
文章目录前言关于 Icarus Verilogiverilog的安装Windows下的安装Linux下的安装MacOS下的安装查看是否安装成功基本参数介绍参数-o参数-y参数-I参数-tvhdlVerilog的编译仿真实际应用1.编译2.生成波形文件3.打开波形文件Verilog转换为VHDLVHDL文件的编译和仿真批处理文件一键执行总结参考资料推荐阅读前言如果你只是想检查Verilog文件的...原创 2019-12-03 22:18:52 · 12503 阅读 · 8 评论 -
Verilog信号的展宽和延时
通过这种方法可以使波形向后延时一个时钟周期。always@(posedge clk)begindelay <= in;end下面是一个实际应用:“原信号中随机出现高电平,高电平之间间隔大于5个周期,高电平宽度均为1个时钟周期。设计电路,将原信号中的高电平展宽为2个时钟周期宽度,并将展宽后的信号延时一个系统时钟再输出。”module top(in,out,clk);inpu...原创 2019-09-05 15:32:33 · 6913 阅读 · 6 评论