Internal delay and external delay for non-blocking assignment

Source: Internet
Author: User

Learning Verilog for a while, literally understanding that the difference between blocking and non-blocking is straightforward. The former is serial, mainly used to describe combinatorial logic, and is similar to the assignment in software; the latter is parallel and is mainly used to describe the temporal logic.

However, when mixed with internal delay and external delay, various unexpected situations occur.

As described below, for non-blocking assignments, the results of internal and external delays are very different.

Example 1: Assuming a positive jump along the pclock at 5ns, and current_state before the positive jump, the value is 5, the positive jump appears 3ns after the change to 7, the following two always statements Next_state_h and Next_state_ What will be the value of l?

Always @ (Posedge pclock)    #7 next_state_h <= current_state;always @ (posedge pclock)     next_state_l <= #7 Current_state;

After analysis, next_state_l <= #7 current_state can be decomposed into two words: 1) temp <= next_state_l; 2) #7 next_state_l <= temp; So despite the delay of 7ns, next_state_l gets the value of the Current_state (5) that corresponds to Pclock's transition. The concrete simulation results are as follows

Example 2: Slave_clock of phase delay is generated according to known Master_clock.

' Timescale 1ns/1ps

Module Clock_shift (MASTER_CLK, SLAVE_CLK);
Output Reg MASTER_CLK;
Output Reg SLAVE_CLK;
Parameter TON = 2, TOFF = 3, Tdelay = 5;

Always
Begin
#tON master_clk = 0;
#tOFF MASTER_CLK = 1;
End

Always @ (MASTER_CLK)
SLAVE_CLK <= #tDELAY master_clk;
Endmodule

The simulation waveform diagram is as follows

However, if the #tdelay is prevented from being externally, such as #tDELAY slave_clk <= MASTER_CLK, then the simulation graph will become as follows:





Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Internal delay and external delay for non-blocking assignment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.