当前位置:网站首页>Named block Verilog
Named block Verilog
2022-07-02 03:08:00 【Da Xi】
Named blocks
We can name the block statement structure .
Local variables can be declared in named blocks , Access variables through the method of hierarchical name reference .
The simulation code is as follows :
example
`timescale 1ns/1ns
module test;
initial begin: runoob // Name the module as runoob, You can't have less semicolons
integer i ; // This variable can be passed through test.runoob.i Used by other modules
i = 0 ;
forever begin
#10 i = i + 10 ;
end
end
reg stop_flag ;
initial stop_flag = 1'b0 ;
always begin : detect_stop
if ( test.runoob.i == 100) begin //i Add up 10 Time , namely 100ns Stop simulation when
$display("Now you can stop the simulation!!!");
stop_flag = 1'b1 ;
end
#10 ;
end
endmodule
The simulation results are as follows :
Named blocks can also be disabled , With keywords disable To express .
disable The execution of named blocks can be terminated , Can be used to exit from the loop 、 Handling errors, etc .
And C In language break similar , however break You can only exit the current cycle , and disable You can disable any named block in the design .
The simulation code is as follows :
example
`timescale 1ns/1ns
module test;
initial begin: runoob_d // Name the module as runoob_d
integer i_d ;
i_d = 0 ;
while(i_d<=100) begin: runoob_d2
# 10 ;
if (i_d >= 50) begin // Add up 5 Stop accumulation for times
disable runoob_d3.clk_gen ;//stop external block: clk_gen
disable runoob_d2 ; //stop At present block: runoob_d2
end
i_d = i_d + 10 ;
end
end
reg clk ;
initial begin: runoob_d3
while (1) begin: clk_gen // Clock generation module
clk=1 ; #10 ;
clk=0 ; #10 ;
end
end
endmodule
The simulation results are as follows :
It can be seen from the picture that , The signal i_d Add up to 50 in the future , No longer accumulate , in the future clk The clock is no longer produced .
so ,disable Exited the current while block .
It should be noted that ,disable stay always or forever When used in block, you can only exit the current round , The next statement will still be always or forever In the implementation of . because always Block and forever Blocks are always executed , At this time disable It's kind of similar C In language continue function .
边栏推荐
- Basic 01: print string
- Which kind of sports headphones is easier to use? The most recommended sports headphones
- MongoDB非關系型數據庫
- Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
- The video number will not be allowed to be put on the shelves of "0 yuan goods" in the live broadcasting room?
- Verilog avoid latch
- [JS reverse series] analysis of a customs publicity platform
- 旋转框目标检测mmrotate v0.3.1 学习模型
- 2022-2028 global wood vacuum coating machine industry research and trend analysis report
- venn圖取交集
猜你喜欢
The capacity is upgraded again, and the new 256gb large capacity specification of Lexar rexa 2000x memory card is added
小米青年工程师,本来只是去打个酱油
Baohong industry | what misunderstandings should we pay attention to when diversifying investment
Connected block template and variants (4 questions in total)
Batch detect whether there is CDN in URL - high accuracy
MongoDB非關系型數據庫
Baohong industry | 6 financial management models at different stages of life
Delphi xe10.4 installing alphacontrols15.12
STM32__05—PWM控制直流电机
Actual battle of financial risk control - under Feature Engineering
随机推荐
Mmsegmentation series training and reasoning their own data set (3)
Common means of modeling: aggregation
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
IPhone 6 plus is listed in Apple's "retro products" list
Framing in data transmission
ZABBIX API creates hosts in batches according to the host information in Excel files
Baohong industry | what misunderstandings should we pay attention to when diversifying investment
What is hybrid web containers for SAP ui5
[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials
竞争与冒险 毛刺
Addition without addition, subtraction, multiplication and division (simple difficulty)
Golang configure export goprivate to pull private library code
What kind of good and cost-effective Bluetooth sports headset to buy
Realize the code scanning function of a custom layout
STM32__05—PWM控制直流电机
4. Find the median of two positive arrays
venn图取交集
Qualcomm platform WiFi -- Native crash caused by WiFi
PHP notes - use Smarty to set public pages (include, if, else, variable settings)
QT environment generates dump to solve abnormal crash