当前位置:网站首页>Chapter 9 practical modeling technology
Chapter 9 practical modeling technology
2022-07-26 19:37:00 【Jiangnan small workshop】
Practical modeling techniques
Preface
- Here it is... Here it is ,Verilog Other enhancements to the language , These characteristics make Verilog Language has more flexibility in modeling and design analysis .
Processes are continuously assigned values
- Process assignment : Assign a value to a register , Values are always stored in registers , Until another process assignment stores another value in this register .
- Processes are continuously assigned values : It is allowed to add the value of the expression continuously in a limited period of time ( drive ) To register or wire network . Rewrite the existing value of a register or line .
assign and deassign
- keyword :
assign、deassign - It is used to represent the continuous assignment statement of the first kind of procedure , Not recommended , Get to know .

force and release
- keyword :
force、release - The second form of procedure continuous assignment statement , It can be used to rewrite ( Cover ) Assignment on register , You can also rewrite ( Cover ) Assignment on the wire network .
- Typical applications : During interactive debugging .
- It is not recommended to use it inside the design module , Should only appear in incentives , Or just as a debug statement .
Act on registers
- Rewrite within a controlled period q and qbar Value .

Function online
- After the wire net is released , Immediately return to your normal drive . The network can be forcibly assigned an expression or a value .

Rewrite parameters
- Also known as coverage parameter . Parameters can be defined within the module definition , But in Verilog During module compilation , Parameter values can be changed individually for each module call .
- The two methods : adopt defparam sentence 、 Parameter assignment through module call .
defparam sentence
- keyword :
defparam - Parameter values can be changed in any module call , The hierarchical name of the module call can be used to rewrite ( Cover ) In the statement of parameter value .

- There can be more than one in a module defparam sentence .
- It can be used defparam Statement overrides any parameter .
- ok, Another bad link ,defparam Statements are considered bad code style , It is suggested that Verilog HDL Use alternative forms in code . Just get to know .
Parameter values of module instances
- When calling a module, you can rewrite ( Cover ) Its originally defined parameter value .
- Modify the above example as follows

- Parameters are assigned by name

Conditional compilation and execution
- Conditional compilation :Verilog Part of the code may be used in a compilation environment , But it doesn't apply to another environment . The designer specifies in the code that a part of the code can be compiled only after setting a specific flag . This is conditional compilation .
- Condition execution : Empathy , When the program runs , Only after a certain flag is set can it be executed Verilog Some parts of the design .
Conditional compilation
Compile instructions :
`ifdef, `ifndef, `else, `elsif, `endifas follows

Because the symbol in front of the instruction conflicts with the editor , The following description without symbols .
ifdef and ifndef Instructions can appear anywhere in the design .
else Instructions are optional . One else The instruction can match at most one ifdef perhaps ifndef.
One ifdef perhaps ifndef Can match any number of elsif command .
ifdef perhaps ifndef Always use the corresponding endif To the end .
stay Verilog In file , The conditional compilation flag can be used define Statement settings .
Condition execution
- The conditional execution flag allows the designer to control the flow of statement execution at run time . All statements are compiled , But execute them conditionally .
- The conditional execution flag can only be used for behavior statements .
- keyword :
$test$plusargs$、$value$plusargs$ - use
$test$plusargs$control
- use
$value$plusargs$Further control condition execution , This system task is used to test the parameter value of the call option , If no matching call options are found , be$value$plusargs$return 0, If you find it , be$value$plusargs$Return non 0 value .
Time scale
In the simulation , The delay value of a module needs to be defined in a certain time unit .
keyword :
'timescaleSuch as
'timescale 1ns/1psamong ,1nsIs the unit of measurement of the specified time and delay ,1psIs the precision of rounding the delay value .Only 1,10 and 100 Is the legal integer that describes the time unit and time accuracy .
`timescale 100ns/1ns module fx(); ... // 500ns clk Flip once #5 clk = ~clk; ...
Common system tasks
- Common system tasks : File output 、 Display hierarchy 、 Strobe display 、 Random number generation 、 Memory initialization 、 Value change dump, etc .
File output
- Verilog The results are usually output to standard output and files verilog.log in , You can redirect its output to the selected file .
Open file
System tasks :
$fopenusage :
- One ,
$fopen(" file name "); - Two ,
file_handle = $fopen(" file name ");
- One ,
$fopenReturn to one 32 Bit multichannel descriptor , And only one bit of the multi-channel descriptor is set to 1.The standard output has a multi-channel descriptor , Its lowest position ( The first 0 position ) Is set to 1.
Standard output is also called channel 0, Always open .
$fopenEach call of will open a new channel , And will return a 32 Channel character of bit , You can set the 1 position , Second …… Until 30 position , The first 31 Bit is reserved bit .Advantages of multichannel : You can choose to write multiple files at the same time .
// Multichannel descriptor integer handle1, handle2; // Standard output is on , That is to say 0 Location 1 // descriptor = 32'h0000_0001 initial begin handle1 = $fopen("file1.out"); // handle1 = 32'h0000_0002( The first 1 Location 1) handle2 = $fopen("file1.out"); // handle2 = 32'h0000_0004( The first 2 Location 1) end
Writing documents
- System tasks :
$fdisplay、$fmonitor、$fwrite、$fstrobe - Commonly used
$fdisplay、$fmonitor - usage :
$fdisplay(<file_descriptor>,p1,p2,...,pn);$fmonitor(<file_descriptor>,p1,p2,...,pn);p1,p2,...,pnIt could be a variable 、 Signal name or quoted string .
- The file descriptor is a multichannel descriptor , It can be a file handle or a bitwise combination of multiple file handles .
- Verilog The output will be written to the file descriptor with a value of 1 All files associated with the phase of .

Close file
- System tasks :
$fclose - usage :
$fclose(<file_descriptor>);
Display hierarchy
- Use any display task ,
$display,$write,$monitor,$strobeIn the task%mOptions , Show any level of hierarchy .
- Output results

Strobe display
- System tasks :
$strobe $strobeProvide synchronization mechanism , It can ensure that all other statements assigned along the same clock edge will display data after execution .
- The value of the rising edge of the clock is in the statement a=b and c=d After execution, it will display .
Random number generation
- System tasks :
$random - usage :
$random;$random(<seed>);<seed>It's optional , Used to ensure that the same sequence of random numbers is generated each time the test is run , The value could be reg,integer perhaps time Variable .
- Mission
$randomReturn to one 32 An integer .
- Generate signed integer

Initialization memory
- Initialize the memory according to the data file .
- System tasks :
$readmemb( Binary number )、$readmemh( Hexadecimal number ) - usage :
$readmemb("<file_name>", <memory_name>);$readmemb("<file_name>", <memory_name>, <start_addr>);$readmemb("<file_name>", <memory_name>, <start_addr>, <finish_addr>);$readmemhSame as .- File name and memory name are required ,
<start_addr>and<finish_addr>It's optional .
- Here's an example

- file init.dat Contains initialization data . The address is expressed in hexadecimal numbers , The data is separated by a space character , The data can contain x or z.

- Simulation test results

Value change dump file
- Value change dump file (VCD) What is it? ?
- One ASCⅡ file , Including simulation time 、 The definition of range and signal and the change of signal value during simulation operation .
- How to use it ?
- All signals in the design or selected signal sets can be written in the simulation process VCD file , The post-processing tool can put VCD File as input and put the hierarchy information 、 The signal value and signal waveform are displayed .

- System tasks include :
$dumpvars: Select the module instance or module instance signal to dump ;$dumpfile: choice VCD The name of the document ;$dumpon: Select the starting point of the dump ;$dumpoff: Select the destination of the dump ;$dumpall: Select generate test points ;
- As shown in the following example

边栏推荐
- File depth monitoring strategy
- 微信小程序插件--wxml-to-canvas(生成图片)
- Pychart loads CONDA to create a pytorch virtual environment and reports an error. It is normal on the CONDA command line
- Weekend highlights review | establishment of digital RMB industry alliance; China Mobile announced that hefeixin will stop its service
- 节省50%成本 京东云发布新一代混合CDN产品
- All you want to know about interface testing is here
- Synchronized理论
- The difference between advanced anti DDoS server and advanced anti DDoS IP
- If the key is forgotten and multiple devices have different keys, how does the cloud synchronize
- 利用MySQL主从复制延迟拯救误删数据
猜你喜欢

基于华为云 IOT 设计智能称重系统 (STM32)【二】结尾有资料
![[server data recovery] data recovery case of server storage shared folder loss](/img/bf/3f86a4e8abd4e045b022fd7574636f.png)
[server data recovery] data recovery case of server storage shared folder loss

All you want to know about interface testing is here

ReentrantLock学习之---释放锁过程

Redis6

AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘

Network protocol: tcp/ip protocol

Conda+pytorch environment tutorial

"Weilai Cup" 2022 Niuke summer multi school training camp 1

【YOLOv5】--详细版训练自己的数据集 保姆级学习日志记录 手把手教程
随机推荐
通过源码深度分析线程池中Worker线程的执行流程
[skim] two point answer solution
MySQL教程:MySQL数据库学习宝典(从入门到精通)
高防服务器和高防IP的区别
工作13年后,个人的一点软件测试经历及感想……
(ICLR-2022)TADA! Time adaptive convolution for video understanding
Last blog post
TB 117-2013 US Federal mandatory regulations
The passwords are consistent, and the total display is as shown in the figure below
openstack 虚拟机网卡被重名为cirename0
EN 1504-7混凝土结构保护和修理用产品钢筋防腐—CE认证
测试面试题集-UI自动化测试
Data Lake -- concept, characteristics, architecture and case overview
Image preview embedding location of blog maintenance record
What is a server cluster? What are the advantages of overseas server clusters?
如何保护电子商务网站免受网络攻击?
时空预测5-GAT
2022搭建企业级数据治理体系
The role of @requestmapping in the project and how to use it
J2 Redis之 AOF&RDB