当前位置:网站首页>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 .
边栏推荐
- 流线线使用阻塞还是非阻塞
- 2022-2028 global nano abrasive industry research and trend analysis report
- el-table的render-header用法
- Stack - es - official documents - filter search results
- [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
- 创业了...
- Intersection of Venn graph
- 2022 hoisting machinery command examination paper and summary of hoisting machinery command examination
- Unit · elementary C # learning notes
- What are the characteristics of common web proxy IP
猜你喜欢
Design details of SAP e-commerce cloud footernavigationcomponent
Jvm-01 (phased learning)
Verilog 过程连续赋值
Addition without addition, subtraction, multiplication and division (simple difficulty)
el-table的render-header用法
[road of system analyst] collection of wrong topics in enterprise informatization chapter
About DNS
Soul app released the annual report on generation Z behavior: nearly 20% of young people love shopping in the vegetable market
[JSON] gson use and step on the pit
Verilog 避免 Latch
随机推荐
tarjan2
Qualcomm platform WiFi -- P2P issue (2)
Force deduction daily question 540 A single element in an ordered array
GB/T-2423.xx 环境试验文件,整理包括了最新的文件里面
3048. Number of words
JS introduction < 1 >
West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
GSE104154_scRNA-seq_fibrotic MC_bleomycin/normalized AM3
Yyds dry goods inventory accelerating vacuum in PG
2022-2028 global deep sea generator controller industry research and trend analysis report
verilog 并行块实现
The number one malware in January 2022: lokibot returned to the list, and emotet returned to the top
spark调优
流线线使用阻塞还是非阻塞
Systemserver service and servicemanager service analysis
Intersection vengraph
The capacity is upgraded again, and the new 256gb large capacity specification of Lexar rexa 2000x memory card is added
PHP notes - use Smarty to set public pages (include, if, else, variable settings)
Verilog 避免 Latch
Multi threaded query, double efficiency