当前位置:网站首页>Verilog daily question (vl8 uses generate... For statement to simplify code)
Verilog daily question (vl8 uses generate... For statement to simplify code)
2022-07-28 17:21:00 【Don't make any more errors】
Title Description
In a certain module It contains many similar continuous assignment statements , Please use generata…for Statement writing code , Replace the statement , The requirement cannot change the original module The function of .
module template_module(
input [7:0] data_in,
output [7:0] data_out
);
assign data_out [0] = data_in [7];
assign data_out [1] = data_in [6];
assign data_out [2] = data_in [5];
assign data_out [3] = data_in [4];
assign data_out [4] = data_in [3];
assign data_out [5] = data_in [2];
assign data_out [6] = data_in [1];
assign data_out [7] = data_in [0];
endmodule
This question is quite simple , Mainly review it again generate Usage of
`timescale 1ns/1ns
module gen_for_module(
input [7:0] data_in,
output [7:0] data_out
);
generate
genvar i;
for(i = 0;i < 8;i =i+1)
begin : ggg
assign data_out[i] = data_in[7-i];
end
endgenerate
endmodulegenerate
It can be done to module、reg、assign、always、task Wait for the statement or module to copy
You have to use genvar Declare a loop variable ; begin Need to label after ( That is, the label of the copied part ); Must be in begin end I'm going to cycle through it 、 Copy .
endgenerate
a key :
1、 Common uses include generate-for、generate-case and generate-if Three sentences .
2、 The key :generate Statements can be easily repeated Instantiation module !
3、 in the light of generate-for sentence , Loop variable i You have to use genvar Statement . And in for The assignment of the loop must use assgin perhaps always complete .( At first, I didn't write assign That leads to mistakes )
// See the example for the reuse of modules
边栏推荐
- Unity shader screen post-processing
- Codeforces round 768 (Div. 2) e.paint the middle (greedy / interval relationship processing)
- 利用SQL Server代理作业对数据库进行定时还原
- Message Passing for Complex Question Answering over Knowledge Graphs
- Analysis of browser decoding process
- What does the service grid that has been popular for two years bring to microservices? (Reprinted)
- Ugui learning notes (II) Scrollview related
- Iris framework practice of goweb development: project summary and review
- wpf命令按钮透明样式
- Unity3d simple implementation of water surface shader
猜你喜欢

WPF command button transparent style

Goweb开发之Beego框架实战:第三节 程序执行流程分析

Source code of voice live broadcast app

Atcoder regular contest 133 d.range XOR (digital dp+ classification discussion)

The practice of beego framework in goweb development: Section I Introduction to beego framework

Unity shader realizes water wave effect with noise texture

零基础利用Unity3D开发AR应用并远程下载3D模型

Introduction to vscade interface

使用阿里云免费的SSL证书

Unity shader procedural texture
随机推荐
Jupyter notebook win installation record
带参数的微信小程序二维码生成
侦察机与预警机的区别
Educational codeforces round 126 (rated for Div. 2) f.teleporters (two sets and two points)
Analysis of kubernetes service principle
Unity3d simple implementation of water surface shader
Verilog 每日一题 (VL5 信号发生器)
The actual combat of the beego framework of goweb development: Section III program execution process analysis
C# 导入Excel文件数据的几种方法
Re10: are we really making much progress? Revisiting, benchmarking, and refining heterogeneous gr
创建自定义分页控件
高速电路中电容的选型和应用——详解
Android Development - set cache
异步FIFO基本原理(基于Verilog的简单实现)
Azure Devops developed by visual studio 2015 team
Ugui learning notes (IV) ugui event system overview and Usage Summary
The maximum recommended number of rows for MySQL is 2000W. Is it reliable?
How to protect image security during construction
MySQL详细学习教程(建议收藏)
Reduce cycle complexity