当前位置:网站首页>[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 fork
disable 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
wait
Statement 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
ready
Threads in state can execute - When all threads enter
wait
In 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
WAIT
In the state of , Thread intoWAIT
Sequence , nextREADY
The thread in state continues to executeWhen all threads enter
WAIT
In the state of , The simulation time steps to the next simulation cycle
3、 ... and 、 Concurrent thread thread
3.1、 Statement set
Veilog
There is a typical set of concurrent statementsinitial
sentence : Only once in the entire simulation time ,initial Statements are concurrentalways
sentence : It can model combinational circuits and sequential circuits ,always Statements are concurrentassign
sentence : 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...join
fork...join
Statement blocks can create processes that execute in parallel ; Twofork...join
stayinitial
inbegin..end
Between , Twofork...join
Is a serial relationship , If twofork...join
The two outer edges arefork...join
, Well, the two one.fork...join
It's parallel .
3.2、fork-join
Create concurrent threads
- Use
fork-join
Statement 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-join
Thread in 1 And thread 2 Is executed in parallelfork-join
Statements are encapsulated inbegin-end
Statements in form a single child thread ( Threads2.1
And 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...join
Outside 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...join
In the block , have access tobegin...end
The statement block encapsulates a separate thread , All statements in this thread are executed sequentially
fork...join_any
( or The relationship between )- When
fork...join_any
After 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...join
andbegin...end
Example
fork...join_any
andbegin...end
Example
fork...join_none
andbegin...end
Example
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
fork
Concurrent process execution completed - Before executing the parent thread , Ensure that all
fork
Parallel sub thread execution is completed - Wait for all
fork
Send all the sub threads to complete the execution
- Wait for all
without
wait fork
,exec5(); Need to wait untilfork...join_any
After any one of them is executed , andfork...join_none
Need 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
边栏推荐
- Stream learning notes
- Whether runnable can be interrupted
- CTFshow,信息搜集:web8
- Unity之ASE实现卡通火焰
- What are PV and UV? pv、uv
- [quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
- CTFshow,信息搜集:web4
- [Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
- Stm32f103c8t6 PWM drive steering gear (sg90)
- How does the database perform dynamic custom sorting?
猜你喜欢
CTFshow,信息搜集:web3
CTFshow,信息搜集:web12
Unity's ASE realizes cartoon flame
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
【OBS】RTMPSockBuf_Fill, remote host closed connection.
CTFshow,信息搜集:web10
【兰州大学】考研初试复试资料分享
Ctfshow, information collection: web14
【目标检测】YOLOv5跑通VOC2007数据集
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
随机推荐
Unity's ASE realizes cartoon flame
Niuke real problem programming - day18
Niuke real problem programming - day15
Ctfshow, information collection: web7
CTFshow,信息搜集:web13
Guangzhou Development Zone enables geographical indication products to help rural revitalization
Niuke real problem programming - Day12
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
Ctfshow, information collection: web9
2022年5月互联网医疗领域月度观察
Classification of regression tests
Summer safety is very important! Emergency safety education enters kindergarten
Pit avoidance: description of null values in in and not in SQL
8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
【数字IC验证快速入门】29、SystemVerilog项目实践之AHB-SRAMC(9)(AHB-SRAMC SVTB Overview)
Use cpolar to build a business website (2)
2. Basic knowledge of golang
CTFshow,信息搜集:web7
[server data recovery] data recovery case of raid failure of a Dell server
CTFshow,信息搜集:web6