当前位置:网站首页>[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)
[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)
2022-07-07 15:34:00 【luoganttcc】
Reading guide : The author has the honor to be a pioneer in the field of electronic information in China “ University of electronic technology ” During postgraduate study , Touch the cutting edge Numbers IC Verification knowledge , I heard something like Huawei Hisilicon 、 Tsinghua purple light 、 MediaTek technology And other top IC related enterprises in the industry , Pairs of numbers IC Verify some knowledge accumulation and learning experience . Want to get started for help IC Verified friends , After one or two thoughts , This column is specially opened , In order to spend the shortest time , Take the least detours , Most learned IC Verify technical knowledge .
List of articles
One 、 Description of content
- Concurrent operation characteristics of logic simulation tools
- Threads :
fork...join | join_any | join_none wait forkdisable fork
Two 、 Logic simulation tool Concurrent Handling characteristics
2.1、 Concurrency means
- For all concurrent threads , Within the current simulation time of the simulation tool , The scheduled events will be completed before the simulation step to the next simulation time

2.2、 Concurrent thread execution
- When a thread executes , Only meet
waitStatement will stop- There are sub threads generated by the executing thread Execute by queue
- When the executing thread encounters Wait statement when , In the queue
readyThreads in state can execute - When all threads enter
waitIn the state of , Simulation time update - Examples of waiting statements :
@(router.cb);
wait(var_a == 1);
##1 router.cb.din <= 4’hf;
join_any;
join
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
2.3、 Concurrent thread execution mode
When a thread executes , All other threads enter the queue and wait
READY- Represents the thread executing within the current simulation timeWAIT- Indicates that the statement is blocked ( Thread cannot execute ), When a waiting condition is encountered, you can continue to execute
When the executing thread enters
WAITIn the state of , Thread intoWAITSequence , nextREADYThe thread in state continues to executeWhen all threads enter
WAITIn the state of , The simulation time steps to the next simulation cycle

3、 ... and 、 Concurrent thread thread
3.1、 Statement set
VeilogThere is a typical set of concurrent statementsinitialsentence : Only once in the entire simulation time ,initial Statements are concurrentalwayssentence : It can model combinational circuits and sequential circuits ,always Statements are concurrentassignsentence : It can model the combinational circuit ,assign Statements are concurrentbegin...end: Sentence from top to bottom , Sequential executionfork...join: sentence Parallel execution , Independent of statement order
fork...joinfork...joinStatement blocks can create processes that execute in parallel ; Twofork...joinstayinitialinbegin..endBetween , Twofork...joinIs a serial relationship , If twofork...joinThe two outer edges arefork...join, Well, the two one.fork...joinIt's parallel .
3.2、fork-join Create concurrent threads
- Use
fork-joinStatement to create a concurrent thread
int a, b, c;
fork
statement0; // Threads 1
begin // Threads 2
statement1;// Threads 2.1
statement2;// Threads 2.2
end
join | join_any | join_none
statement
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
fork-joinThread in 1 And thread 2 Is executed in parallelfork-joinStatements are encapsulated inbegin-endStatements in form a single child thread ( Threads2.1And thread2.2), And in the order of statements , From top to bottom- Concurrent thread There is no fixed sequence of execution
- All child threads share the variables of the parent thread
3.3、join Options
notes : The parent thread here refers to
for...joinOutside the statement block, below The thread of

fork...join( And The relationship between )- When all the sub threads are finished , The parent thread will continue to execute
- stay
fork...joinIn the block , have access tobegin...endThe statement block encapsulates a separate thread , All statements in this thread are executed sequentially

fork...join_any( or The relationship between )- When
fork...join_anyAfter any child thread in the statement block completes , The parent thread continues to execute
- When

fork...join_noe- Parent thread and for The sub threads in the statement block are executed in parallel
- When the parent thread executes a blocking statement , The child thread starts to execute ( The parent thread executes first )

fork...joinandbegin...endExample


fork...join_anyandbegin...endExample


fork...join_noneandbegin...endExample


Q: The above statements are preceded by time units , If there is no time unit in front of some sentences ,fork How to execute the statement ?
- A: There is no time unit , The sequence of execution of these statements can be determined at the compilation stage , After the compilation phase is determined, it is executed in sequence at the actual run time .【 The actual project must have a time unit !】
3.4、 Concurrent thread control
wait fork- Wait for all
forkConcurrent process execution completed - Before executing the parent thread , Ensure that all
forkParallel sub thread execution is completed - Wait for all
forkSend all the sub threads to complete the execution
- Wait for all

without
wait fork,exec5(); Need to wait untilfork...join_anyAfter any one of them is executed , andfork...join_noneNeed to wait untilexec5()Only after the execution is completed .disable fork- Stop the execution of all parallel sub threads

3.5、 Test questions

- A: 2 individual ;B:2 individual ;C:1 individual ;D:1 individual


- Cannot simulate normally : Threads 1 The clock is simulating 0 Act at all times , Threads 2 Is in 5 In time units , hold a become 5, Threads will not emulate to the 5 Time units !

- a = 4;b = 8;
- Although the print results are parallel , But the simulator can't be fully parallel , The following can still use the above value !( There are tiny
δTime difference )

- a = 7; b = 4;





- Generally, we will not be in for Use in circulation
fork...join
- Just understand this mistake !
X、 Practice
X.1、fork...join/join_any/join_none Demo
module thread(); initial begin fork // Thread 1 begin #6; $display("******@%0t, fork join sub thread 1 begin", $time); end // Thread 2 begin #5; $display("******@%0t, fork join sub thread 2 begin", $time); end join $display("******@%0t, fork join father thread begin", $time); #20; fork // Thread 1 begin #6; $display("******@%0t, fork join_any sub thread 1 begin", $time); end // Thread 2 begin #5; $display("******@%0t, fork join_any sub thread 2 begin", $time); end join_any $display("******@%0t, fork join_any father thread begin", $time); #20; fork // Thread 1 begin #6; $display("******@%0t, fork join_none sub thread 1 begin", $time); end // Thread 2 begin #5; $display("******@%0t, fork join_none sub thread 2 begin", $time); end join_none $display("******@%0t, fork join_none father thread begin", $time); end endmodule******@5000, fork join sub thread 2 begin ******@6000, fork join sub thread 1 begin ******@6000, fork join father thread begin ******@31000, fork join_any sub thread 2 begin ******@31000, fork join_any father thread begin ******@32000, fork join_any sub thread 1 begin ******@51000, fork join_none father thread begin ******@56000, fork join_none sub thread 2 begin ******@57000, fork join_none sub thread 1 begin
边栏推荐
- Change win10 Screensaver
- Nacos一致性协议 CP/AP/JRaft/Distro协议
- There is a cow, which gives birth to a heifer at the beginning of each year. Each heifer has a heifer at the beginning of each year since the fourth year. Please program how many cows are there in the
- CTFshow,信息搜集:web2
- 一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
- Unity之ASE实现卡通火焰
- 2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
- With 8 modules and 40 thinking models, you can break the shackles of thinking and meet the thinking needs of different stages and scenes of your work. Collect it quickly and learn it slowly
- Niuke real problem programming - Day11
- What are PV and UV? pv、uv
猜你喜欢

什麼是數據泄露
![[机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟](/img/38/cc5bb5eaa3dcee5ae2d51a904cf26a.png)
[机缘参悟-40]:方向、规则、选择、努力、公平、认知、能力、行动,读3GPP 6G白皮书的五层感悟

CTFshow,信息搜集:web13
![[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset](/img/69/9dadeb92f8d6299250a894690c2845.png)
[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset

【数据挖掘】视觉模式挖掘:Hog特征+余弦相似度/k-means聚类

What is data leakage

【数字IC验证快速入门】29、SystemVerilog项目实践之AHB-SRAMC(9)(AHB-SRAMC SVTB Overview)

IDA pro逆向工具寻找socket server的IP和port

【服务器数据恢复】戴尔某型号服务器raid故障的数据恢复案例

全日制研究生和非全日制研究生的区别!
随机推荐
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
【数字IC验证快速入门】18、SystemVerilog学习之基本语法5(并发线程...内含实践练习)
@ComponentScan
Briefly describe the working principle of kept
摘抄的只言片语
微信小程序 01
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
2. 堆排序『较难理解的排序』
连接ftp服务器教程
知否|两大风控最重要指标与客群好坏的关系分析
【数字IC验证快速入门】29、SystemVerilog项目实践之AHB-SRAMC(9)(AHB-SRAMC SVTB Overview)
With 8 modules and 40 thinking models, you can break the shackles of thinking and meet the thinking needs of different stages and scenes of your work. Collect it quickly and learn it slowly
MySQL installation configuration 2021 in Windows Environment
CTFshow,信息搜集:web13
MySQL bit type resolution
Nacos一致性协议 CP/AP/JRaft/Distro协议
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
Compile advanced notes
Configure mongodb database in window environment
使用cpolar建立一个商业网站(2)