当前位置:网站首页>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 .
边栏推荐
- Cache processing scheme in high concurrency scenario
- [road of system analyst] collection of wrong topics in enterprise informatization chapter
- Realize the code scanning function of a custom layout
- tarjan2
- 結婚後
- ORA-01547、ORA-01194、ORA-01110
- Remote connection to MySQL under windows and Linux system
- [JS reverse series] analysis of a customs publicity platform
- Mongodb non relational database
- 2022-2028 global encryption software industry research and trend analysis report
猜你喜欢

West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials

JS <2>

How to create an instance of the control defined in SAP ui5 XML view at runtime?

Formatting logic of SAP ui5 currency amount display

ZABBIX API creates hosts in batches according to the host information in Excel files

多线程查询,效率翻倍

Share the basic knowledge of a common Hongmeng application

Delphi xe10.4 installing alphacontrols15.12

Verilog avoid latch

Soul app released the annual report on generation Z behavior: nearly 20% of young people love shopping in the vegetable market
随机推荐
buu_ re_ crackMe
New programmer magazine | Li Penghui talks about open source cloud native message flow system
Websocket + spingboot realize code scanning login
Mongodb base de données non relationnelle
QT implementation interface jump
[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
結婚後
Gradle 笔记
结婚后
AcWing 245. Can you answer these questions (line segment tree)
Possible causes of runtime error
【无标题】
Baohong industry | what misunderstandings should we pay attention to when diversifying investment
小米青年工程师,本来只是去打个酱油
About DNS
Pychart creates new projects & loads faster & fonts larger & changes appearance
/silicosis/geo/GSE184854_scRNA-seq_mouse_lung_ccr2/GSE184854_RAW/GSM5598265_matrix_inflection_demult
Which kind of sports headphones is easier to use? The most recommended sports headphones
Verilog 避免 Latch
2022-2028 global aluminum beverage can coating industry research and trend analysis report