当前位置:网站首页>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 .
边栏推荐
- 高并发场景下缓存处理方案
- What is hybrid web containers for SAP ui5
- Cache processing scheme in high concurrency scenario
- Force deduction daily question 540 A single element in an ordered array
- Verilog 过程赋值 区别 详解
- V-model of custom component
- Apple added the first iPad with lightning interface to the list of retro products
- Mathematical calculation in real mode addressing
- JDBC details
- Leetcode question brushing (10) - sequential question brushing 46 to 50
猜你喜欢

批量检测url是否存在cdn—高准确率

Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
![[staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the](/img/fe/d97b25f702bbc05f941d08147259e0.jpg)
[staff] the direction of the symbol stem and the connecting line (the symbol stem faces | the symbol stem below the third line faces upward | the symbol stem above the third line faces downward | the

OSPF LSA message parsing (under update)

Start a business

连通块模板及变式(共4题)

QT environment generates dump to solve abnormal crash

Feature query of hypergraph iserver rest Service

2022-2028 global nano abrasive industry research and trend analysis report

Docker安装canal、mysql进行简单测试与实现redis和mysql缓存一致性
随机推荐
结婚后
Pychart creates new projects & loads faster & fonts larger & changes appearance
The number one malware in January 2022: lokibot returned to the list, and emotet returned to the top
[JS reverse series] analysis of a customs publicity platform
Gradle 笔记
2022-2028 global aluminum beverage can coating industry research and trend analysis report
GSE104154_scRNA-seq_fibrotic MC_bleomycin/normalized AM3
Apple added the first iPad with lightning interface to the list of retro products
Possible causes of runtime error
Special symbols in SAP ui5 data binding syntax, and detailed explanation of absolute binding and relative binding concepts
Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
2022-2028 global military computer industry research and trend analysis report
tarjan2
Formatting logic of SAP ui5 currency amount display
Qualcomm platform wifi-- WPA_ supplicant issue
跟着CTF-wiki学pwn——ret2shellcode
自定义组件的 v-model
Missing numbers from 0 to n-1 (simple difficulty)
JS <2>
C shallow copy and deep copy