当前位置:网站首页>Verilog HDL continuous assignment statement, process assignment statement, process continuous assignment statement
Verilog HDL continuous assignment statement, process assignment statement, process continuous assignment statement
2022-07-03 18:51:00 【Then the dish】
1. Continuous assignment statement (Continuous Assignments)
The continuous assignment statement is Verilog The basic statement of data flow modeling , Used for line network wire Assign a value , Equivalent to gate level description , yes Describe the circuit from a higher abstract point of view . Consecutive assignment statements must begin with key word assign Start .
assign LHS_target = RHS_expression ;
The main feature of continuous replication is :
(1) Lvalue of continuous assignment statement , It can be one of the following types :
① Scalar network
② Vector network
③ An element of a matrix ( The matrix can be scalar wire net type , It can also be of vector line network type )
④ Some bit of vector line network
⑤ Partial bit of vector line network
And the various types of splices mentioned above , however , Cannot be a vector or a vector register .
(2) Continuous assignment statements are always active . As long as one operand changes , The expression will be immediately recalculated , And assign the result to the net to the left of the equal sign .
(3) Operands can be scalar or vector nets or registers , It can also be a function call .
(4) The assignment delay is used to control the time when a new value is assigned to the network , Explain according to the simulation time unit . The assignment delay is similar to the gate delay , It is very important to describe the timing in actual circuits .
Verilog It also provides another pair of wire A simple method of type assignment , That is to say wire Type variables are assigned values when declared .wire Type variables can only be assigned once , Therefore, this continuous assignment method can only be used once . For example, the following assignment method and the assignment method of the above assignment example , The results are consistent .
wire A, B ; wire Cout = A & B ;
2. Procedure assignment statement (Procedural Assignments)
The update object of procedure assignment statement is register 、 Integers 、 Real numbers or time variables . These types of variables are assigned , Its value will remain unchanged , Until a new value is assigned by another procedure assignment statement . Procedure assignment statements only work when they are executed . Procedure assignment statements can only be used in initial or always Assignment within a statement , Only variable data types can be assigned , meanwhile initial and always Only procedure assignment statements can be used in . The lvalue of a procedure assignment statement can be one of the following types :
①reg、 Plastic number 、 Real type number 、 Time register variable or memory unit
② The above various types of bit selection ( for example :addr[3])
③ The above various types of domain selections ( for example :addr[31:16])
④ The above three types of splicing
Procedural assignment statements include two types of assignment statements : Block assignment (=) And non blocking assignment (<=)( The main differences are detailed in various Verilog Reference books , No more details here ).
3. Procedure continuous assignment statement (Procedural Continuous Assignments)
Process continuous assignment is to assign variables in the process block Or continuous assignment of wire network data , It is a procedural assignment , In other words , Procedural continuous assignment statement is a kind of statement that can be used in always or initial Statements that appear in statement blocks . This assignment can be rewritten (Override) All other statements assign values to nets or variables . This assignment allows assignment expressions to be continuously driven into variables or nets .
There are two types of procedure continuous assignment statements :
①assign and deassign Procedural statement : Assign values to variables .
②force and release Procedural statement : It is mainly used to assign values to the network , It can also be used to assign values to variables .
3.1 assign and deassign sentence
assign and deassign Statements constitute a class of procedural continuous assignment statements , It can only be used for continuous assignment of register type variables , It cannot be used for continuous assignment of network type data .
①assign sentence
grammar :assign < Register type variable > = < Assignment expression >;
assign When executed , Register type variables will be continuously driven by assignment expressions , That is, enter the continuous assignment state . If there is an ordinary procedure assignment statement to perform procedure assignment on the register variable , Because the procedure is continuous, the assignment statement assign The priority of is higher than that of ordinary procedure assignment statements , Therefore, the register variable in continuous assignment state will ignore the process assignment operation of ordinary process assignment statement , Its logical state is still determined by the assignment expression in the continuous assignment statement of the process .
If there are two assign Statement to continuously assign values to the same register variable , So the second one assign The execution of will override the first assign The implementation effect of .
②deassign sentence
grammar :deassign < Register type variable >;
deassign Statement is a statement that cancels a continuous assignment , Used to end the continuous assignment of variables . When deassign After statement execution , Originally by assign The continuous assignment of the variable by the statement will be invalidated , The state in which the register variable is continuously assigned will be released , The variable can be assigned again by the ordinary process assignment statement . Here's a little bit of attention , When this statement is executed to undo the continuous assignment of a register variable , The register variable will remain the original value before using the statement .
③ Example :
The execution process of the above statement is as follows :
s0: stay 0 moment ,out To be an assignment 0, And keep this value ;
s1: stay 10 moment ,s1 Start execution , The implementation of variable out Continuous assignment operation , So from 10 The moment begins ,out Will be in a continuous assignment state ;
s2: stay 20 moment ,s2 Start execution , Will cover s1 The effect of , So from 20 The moment begins ,out Will be made by c & d Continuous drive ;
s3:s3 Operation covers s2 operation ;
s4: When deassign The statement is executed , Variable out The continuous assignment state is released , Its value will remain the last assign Statement , namely “e & f”;
3.2 force and release sentence
force and release Statements and assign and deassign Statements like , It is also a procedure continuous assignment statement . This set of assignment statements can not only have an effect on register type variables , It can also continuously assign values to the network type data .
①force sentence
grammar :force < Register variable or wire network data > = < Assignment expression >>;
force Statement when applied to a register type variable , It's in force After statement execution , This register variable will be forced by < Assignment expression > Continuous drive , Enter the state of continuous assignment , At this time, the assignment of other lower priority assignment statements to the register variable will be ignored , Until the execution of one release Statement to release successive assignments to the register variable .
force When the statement is applied to network data , be force After statement execution , The corresponding network data will be < Assignment expression > Continuous drive , Drivers with lower priority on the network data will be ignored , Until there is one release Until the statement is executed .
②release sentence
grammar :release < Register variable or wire network data >;
release After statement execution , Originally by force The continuous assignment of a procedure imposed by a statement on a variable or network will be invalidated , The variable will be released from the state of being continuously assigned , The assignment operation of the assignment statement with lower priority will be valid .
③ Example :
s0: Implementation of the variable var_reg1 Procedure assignment operation , namely var_reg1 To be an assignment 3'b000;
s1: perform assign Procedure continuous assignment statement , Used to implement the control of variables var_reg2 Continuous assignment of , thus var_reg2 Will be consecutively assigned to 3'b001;
s2: When executing this statement ,var_reg1 Not by assign Statement has carried out continuous assignment operation , therefore var_reg1 By force Continuous assignment is 3'b100;
s3: After executing this statement ,var_reg2 By force Continuous assignment is 3'b100;
s4: When executing this statement , Because of the variable var_reg1 Will exit the state of continuous assignment , because var_reg1 Never been assign Statement has carried out continuous assignment operation , so var_reg1 The value remains unchanged , That is to keep force The value in the State 3'b100;
s5: When executing this statement , because var_reg2 In execution s3 It's been done by s1 Continuous assignment is realized , So in this sentence s5 After execution , Variable var_reg2 Will be restored to by assign sentence s1 Determined continuous assignment state , namely 3'b001;
4. The difference between assignment statements
4.1 The difference between continuous assignment statements and procedure assignment statements
- The continuous assignment statement consists of assign To mark , The procedure assignment statement cannot contain this keyword ;
- The data type on the left side of the continuous assignment statement must be the line network data type , The assigned data type in the procedure assignment statement must be a variable of register type ;
- Continuous assignment statements cannot appear in procedure blocks (initial or always) in , The procedure assignment statement can ;
- Continuous assignment statement is mainly used to model combinational logic circuit and describe the connection between line network data , The process assignment statement is mainly used to describe the behavior of sequential logic circuits ;
- The assignment of continuous assignment statement to the assigned wire network data is “ continuity ” Of ( That is, any change in the assignment expression will immediately reflect the value of online data ), And procedural assignment statements , The assignment operation is performed only when the procedure assignment statement is executed , After the statement is executed, the value of the assigned variable is no longer affected by the assignment expression ( Note that once here means : stay initial In block , Procedural assignments are performed only once in sequence , And in the always In block , Every time you meet always The condition of , The... Should be executed once in sequence always Statement in block .).
- The difference between continuous assignment and process assignment :
Process assignment | Continuous assignment | |
assign | nothing assign( Except for procedural continuous assignment ) | Yes assign |
Symbol | Use “=” or “《=” | Use only “=” |
Location | stay always Sentence or initial ... can appear in any statement | Do not appear in always Statement and initial sentence |
conditions for execution | Related to other statements around | When the value of the operand at the right end of the equal sign changes |
purpose | Drive register | Drive wire network |
4.2 The difference between procedure continuous assignment statement and continuous assignment statement
- Procedure continuous assignment statements can only be used in procedure blocks (initial The process is fast or always Process block ) Inside , Continuous assignment statements cannot appear in procedure blocks .
- The procedure continuous assignment statement can continuously assign values to register type variables ( among force-release Statement can also continuously assign values to the network ), However, the assignment target cannot be a variable or one or more bits of the network , The continuous assignment statement can only assign values to the network data , The assignment target can be one or several bits of wire mesh data .
Thank you for sharing !!!
边栏推荐
- What problems can cross-border e-commerce sellers solve with multi platform ERP management system
- In addition to the prickles that pierce your skin, there are poems and distant places that originally haunt you in plain life
- There are several levels of personal income tax
- CTO and programmer were both sentenced for losing control of the crawler
- How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
- 2022-2028 global physiotherapy clinic industry research and trend analysis report
- 2022-2028 global plasmid DNA cdmo industry research and trend analysis report
- [combinatorics] exponential generating function (properties of exponential generating function | exponential generating function solving multiple set arrangement)
- Record: MySQL changes the time zone
- leetcode:11. 盛最多水的容器【雙指針 + 貪心 + 去除最短板】
猜你喜欢
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
Zhengda futures news: soaring oil prices may continue to push up global inflation
There are several levels of personal income tax
Torch learning notes (3) -- univariate linear regression model (self training)
What problems can cross-border e-commerce sellers solve with multi platform ERP management system
The installation path cannot be selected when installing MySQL 8.0.23
After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
application
Flutter网络和数据存储框架搭建 -b1
我眼中真正优秀的CTO长啥样
随机推荐
Max of PHP FPM_ Some misunderstandings of children
php-fpm的max_chindren的一些误区
User identity used by startup script and login script in group policy
Day-27 database
FBI warning: some people use AI to disguise themselves as others for remote interview
Integrated easy to pay secondary domain name distribution system
Opencv learning notes (continuously updated)
Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come
235. The nearest common ancestor of the binary search tree [LCA template + same search path]
[leetcode周赛]第300场——6110. 网格图中递增路径的数目-较难
After nohup NPM start &, close the shell window directly, and the process closes accordingly
Which do MySQL and Oracle learn?
Introduction to SSH Remote execution command
[Yu Yue education] world reference materials of Microbiology in Shanghai Jiaotong University
__ Weak and__ The difference between blocks
Know what it is, and know why, JS object creation and inheritance [summary and sorting]
Typescript configuration
SSM整合-前后台协议联调(列表功能、添加功能、添加功能状态处理、修改功能、删除功能)
What does foo mean in programming?
我眼中真正优秀的CTO长啥样