当前位置:网站首页>Verilog for loop (1)
Verilog for loop (1)
2022-07-22 18:15:00 【qq_ forty-four million nine hundred and eighty-five thousand si】
This introduction is currently in verilog In language , The only cycle that can be integrated into a circuit : Constant number of cycles for loop .for The general form of a cycle is :
for(variable = start_value;continue_condition; circle_express)
begin
operations……
end
among ,varible It's a variable name ;start_value Is the initial value of the variable ;continue_condition Is the continuation condition of the cycle ;circle_express Is the step operation of each cycle ;operations Is the operation of each cycle . If you want to for Cycles can be integrated , The number of cycles must be a definite value .
Here's an example for The integrable characteristics of the cycle :
for(loop=0; loop<10; loop=loop+1)// Integrable , The number of cycles is 10
for(loop=0; loop<10; loop=loop+2)// Integrable , The number of cycles is 5
for(loop=variable; loop<10;loop=loop+1)// The initial value is variable and cannot be synthesized
for(loop=0; loop<variable;loop=loop+1)// The end condition is that the variable cannot be synthesized
for(loop=0; loop<10; loop=loop+ variable)// Step size is variable and cannot be synthesized
Here's how for Loop is the key code for the practical application of multi-level register chain :
module DFF_link(
input clk,
input rst,
input [7:0] data_i,
output [7:0] data_o
);
localparam Number_reg = 16; // Define the number of registers that need to be cycled
reg[7:0] dff[Number_reg-1:0];// For this example 16 A register
integer loop;// Cyclic variables are best defined as integer
// When defined as reg Pay attention when designing loop A wide
[email protected](posedge clk or negedge rst)
if(!rst)
begin
for(loop= 0; loop <= Number_reg-1; loop = loop+1)
dff[loop]<= 8'd0
end
else
begin
dff[0]<=data_i;
for(loop= 1; loop <= Number_reg-1; loop = loop+1)
dff[loop]<= dff[loop-1]
end
assigndata_o = dff[15];
endmodule
We need to understand , There is no loop This variable , It only works in synthesis , Tell the synthesizer software to repeat several times for operation .
for Circulation in actual engineering , It has great practical value , It can greatly simplify the code , Improve work efficiency , We can think of it as c In language for The circulation function is the same , But in verilog Pay attention to its use rules and c Different language .
边栏推荐
- What is the routing protocol
- 「武汉理工大学 软件工程复习」第一章 | 软件工程概述
- Computer Graphics From Scratch - Chapter 4
- QT笔记——QTableWidget表格生成树,QTreeWidget树节点生成表格内容
- GBase8s数据库由数据库对象执行的对照
- QT笔记——自定义数据类型
- Use of bullets in object pool mode in aircraft war
- 「武汉理工大学 软件工程复习」第七章 | 软件测试
- 需要达到什么水平,程序员才能顺利拿到20k月薪无压力?
- shell脚本使用expect自动化交互登录远程主机进行批量关机
猜你喜欢
[opencv introduction practice] use the front camera of the computer for face detection
QT筆記—— QTableWidget 之 拖拽行數 和 移動
QT笔记——QtXml
并发模型值Actor和CSP
QT笔记——Qt动态属性 之 unpolish() 和 polish()
[exception] generate guid and datetime, import test data to the database
学IT,你后悔了么?
逆袭黑马:数据库全栈工程师(DevDBOps)培训,把最好的课程送给您!
QT笔记——QTableWidget表格生成树,QTreeWidget树节点生成表格内容
【Bug】datetime格式化失败
随机推荐
Gbase8s database set collection statement
GBase8s数据库标识连接
GBase8s数据库MINUS 运算符
「武汉理工大学 软件工程复习」第三章 | 软件需求
Dokcer运行Nacos容器自动退出问题
Microsoft SQL Server数据库语言及功能使用(十二)
Rk3399 platform development series explanation (input subsystem) 4.52. Implementation principle of input subsystem
一招教你招聘数据可视化~还有人不会这些数据分析小案例吗?
Ssl/tls protocol attack detection method based on stream spectrum theory
Reversible information hiding method of image in ciphertext domain based on fine-grained embedding space reservation
Gbase8s database identity connection
基于混合深度学习的多类型低速率DDoS攻击检测方法
go fmt包详解
Vim编辑器常用快捷方式
Go slice, set, simple explanation
QT notes - vs generating multiple exe files for a project
【Rust】Rust 语言基础 | 学习语言都应该快速得出印象
济南 章丘 科目三 资料 收集
Pytoch implements word2vec
学点编程:防失业“疫苗”