• The Verilog-AMS Language
  • Continuous Assigns

Continuous Assigns 

A module may have any number of continuous assign statements. Continuous assign statements are used to drive values on to wires. For example:

This is referred to as a continuous assign because the wire on the left-hand side of the assignment operator is continuously driven with the value of the expression on the right hand side. The target of the assign statement must be a wire. The continuous assign statement is not a procedural statement and so must be used at the module level; it cannot be placed in an initial or always process.

You can add delay to a continuous assign statement as follows:

In this case, the value of a changes 10 units of time after the expression b & c changes. Continuous assign statement implement inertial delay, meaning that continuous assign statements swallow glitches. This is illustrated below with the assumption that the unit of time is 1ns.

../../_images/inertial-delay.png

It is possible to specify up to three delay values on a continuous assignment:

When you specify more than one:

The first delay refers to the transition to the 1 value (rise delay).

The second delay refers to the transition to the 0 value (fall delay).

The third delay refers to the transition to the high-impedance value.

When a value changes to the unknown (x) value, the delay is the smallest of the delays specified.

If only two delays are specified, then the delay to high-impedance is the smallest of the two values specified.

Reference Designer

  • Tutorials Home
  • Verilog Miscellaneous Topics

Continuous Assignment Statement

Copyright © 2009 Reference Designer

Tutorials | Products | Services | Contact Us

Verilog Continuous Assignment Statements Tutorial

Continuous assignment statements are an essential aspect of Verilog that allows you to assign values to signals without using procedural blocks. Unlike procedural assignments found in always blocks, continuous assignments are used for modeling combinational logic. In this tutorial, we will explore continuous assignment statements in Verilog and learn how to use them to describe the behavior of combinational circuits efficiently.

Introduction to Continuous Assignment Statements

Continuous assignment statements in Verilog are used to specify the relationship between input and output signals in a combinational circuit. They allow you to assign a value to a signal continuously, meaning the assignment is continuously evaluated as the inputs change. Continuous assignments are used outside procedural blocks and are ideal for describing combinational logic or interconnections between signals.

Example of Continuous Assignment Statements:

Another example:, steps to use continuous assignment statements.

To use continuous assignment statements in Verilog, follow these steps:

  • Identify the combinational logic relationship between input and output signals.
  • Use the 'assign' keyword to create a continuous assignment statement.
  • Specify the output signal on the left-hand side and the combinational logic expression on the right-hand side of the assignment.
  • Ensure that the right-hand side expression does not contain any procedural constructs, as continuous assignments are not allowed to contain procedural statements.
  • Continuous assignments are evaluated in parallel with no explicit sequencing, making them suitable for combinational logic modeling.

Common Mistakes with Continuous Assignment Statements

  • Using procedural statements such as if-else or case statements within continuous assignments.
  • Missing the 'assign' keyword before the continuous assignment statement, leading to syntax errors.
  • Attempting to use continuous assignments for modeling sequential logic, which is not their intended use.
  • Using continuous assignments for outputs in modules with procedural assignments, leading to unexpected behavior.
  • Not considering the propagation delays of combinational logic when using continuous assignments, which may affect simulation results.

Frequently Asked Questions (FAQs)

  • Q: Can I use continuous assignments inside an always block? A: No, continuous assignments are not allowed inside always blocks. They are used outside procedural blocks to model combinational logic.
  • Q: What is the difference between continuous assignments and procedural assignments? A: Continuous assignments are evaluated continuously for combinational logic, while procedural assignments in always blocks are used for modeling sequential logic that executes based on clock edges or event triggers.
  • Q: Can I use continuous assignments for bidirectional signals? A: No, continuous assignments can only be used for assigning values to output or wire signals, not bidirectional signals or registers.
  • Q: How do continuous assignments affect the simulation time of a Verilog design? A: Continuous assignments add negligible overhead to the simulation time as they represent combinational logic and are evaluated in parallel with no explicit sequencing.
  • Q: Can I use continuous assignments for modeling arithmetic operations? A: Yes, continuous assignments can be used to model arithmetic operations in combinational logic. For example, you can use continuous assignments to describe the addition or subtraction of signals.
  • Verilog tutorial
  • GitLab tutorial
  • Codelgniter tutorial
  • IntelliJ Idea tutorial
  • Embedded tutorial
  • Grafana tutorial
  • CouchDB tutorial
  • Azure Kubernetes Service tutorial
  • Hubot tutorial
  • DBMS tutorial
  • Deep Learning tutorial

Using Continuous Assignment to Model Combinational Logic in Verilog

In this post, we talk about continuous assignment in verilog using the assign keyword. We then look at how we can model basic logic gates and multiplexors in verilog using continuous assignment.

There are two main classes of digital circuit which we can model in verilog – combinational and sequential .

Combinational logic is the simplest of the two, consisting solely of basic logic gates, such as ANDs, ORs and NOTs. When the circuit input changes, the output changes almost immediately (there is a small delay as signals propagate through the circuit).

In contrast, sequential circuits use a clock and require storage elements such as flip flops . As a result, output changes are synchronized to the circuit clock and are not immediate.

In this post, we talk about the techniques we can use to design combinational logic circuits in verilog. In the next post, we will discuss the techniques we use to model basic sequential circuits .

Continuous Assignment in Verilog

We use continuous assignment to drive data onto verilog net types in our designs. As a result of this, we often use continuous assignment to model combinational logic circuits.

We can actually use two different methods to implement continuous assignment in verilog.

The first of these is known as explicit continuous assignment. This is the most commonly used method for continuous assignment in verilog.

In addition, we can also use implicit continuous assignment, or net declaration assignment as it is also known. This method is less common but it can allow us to write less code.

Let's look at both of these techniques in more detail.

  • Explicit Continuous Assignment

We normally use the assign keyword when we want to use continuous assignment in verilog. This approach is known as explicit continuous assignment.

The verilog code below shows the general syntax for continuous assignment using the assign keyword.

The <variable> field in the code above is the name of the signal which we are assigning data to. We can only use continuous assignment to assign data to net type variables.

The <value> field can be a fixed value or we can create an expression using the verilog operators we discussed in a previous post. We can use either variable or net types in this expression.

When we use continuous assignment, the <variable> value changes whenever one of the signals in the <value> field changes state.

The code snippet below shows the most basic example of continuous assignment in verilog. In this case, whenever the b signal changes states, the value of a is updated so that it is equal to b.

  • Net Declaration Assignment

We can also use implicit continuous assignment in our verilog designs. This approach is also commonly known as net declaration assignment in verilog.

When we use net declaration assignment, we place a continuous assignment in the statement which declares our signal. This can allow us to reduce the amount of code we have to write.

To use net declaration assignment in verilog, we use the = symbol to assign a value to a signal when we declare it.

The code snippet below shows the general syntax we use for net declaration assignment.

The variable and value fields have the same function for both explicit continuous assignment and net declaration assignment.

As an example, the verilog code below shows how we would use net declaration assignment to assign the value of b to signal a.

Modelling Combinational Logic Circuits in Verilog

We use continuous assignment and the verilog operators to model basic combinational logic circuits in verilog.

To show we would do this, let's look at the very basic example of a three input and gate as shown below.

To model this circuit in verilog, we use the assign keyword to drive the data on to the and_out output. This means that the and_out signal must be declared as a net type variable, such as a wire.

We can then use the bit wise and operator (&) to model the behavior of the and gate.

The code snippet below shows how we would model this three input and gate in verilog.

This example shows how simple it is to design basic combinational logic circuits in verilog. If we need to change the functionality of the logic gate, we can simply use a different verilog bit wise operator .

If we need to build a more complex combinational logic circuit, it is also possible for us to use a mixture of different bit wise operators.

To demonstrate this, let's consider the basic circuit shown below as an example.

To model this circuit in verilog, we need to use a mixture of the bit wise and (&) and or (|) operators. The code snippet below shows how we would implement this circuit in verilog.

Again, this code is relatively straight forward to understand as it makes use of the verilog bit wise operators which we discussed in the last post.

However, we need to make sure that we use brackets to model more complex logic circuit. Not only does this ensure that the circuit operates properly, it also makes our code easier to read and maintain.

Modelling Multiplexors in Verilog

Multiplexors are another component which are commonly used in combinational logic circuits.

In verilog, there are a number of ways we can model these components.

One of these methods uses a construct known as an always block . We normally use this construct to model sequential logic circuits, which is the topic of the next post in this series. Therefore, we will look at this approach in more detail the next blog post.

In the rest of this post, we will look at the other methods we can use to model multiplexors.

  • Verilog Conditional Operator

As we talked about in a previous blog, there is a conditional operator in verilog . This functions in the same way as the conditional operator in the C programming language.

To use the conditional operator, we write a logical expression before the ? operator which is then evaluated to see if it is true or false.

The output is assigned to one of two values depending on whether the expression is true or false.

The verilog code below shows the general syntax which the conditional operator uses.

From this example, it is clear how we can create a basic two to one multiplexor using this operator.

However, let's look at the example of a simple 2 to 1 multiplexor as shown in the circuit diagram below.

The code snippet below shows how we would use the conditional operator to model this multiplexor in verilog.

  • Nested Conditional Operators

Although this is not common, we can also write code to build larger multiplexors by nesting conditional operators.

To show how this is done, let's consider a basic 4 to 1 multiplexor as shown in the circuit below.

To model this in verilog using the conditional operator, we treat the multiplexor circuit as if it were a pair of two input multiplexors.

This means one multiplexor will select between inputs A and B whilst the other selects between C and D. Both of these multiplexors use the LSB of the address signal as the address pin.

To create the full four input multiplexor, we would then need another multiplexor.

This takes the outputs from the first two multiplexors and uses the MSB of the address signal to select between them.

The code snippet below shows the simplest way to do this. This code uses the signals mux1 and mux2 which we defined in the last example.

However, we could easily remove the mux1 and mux2 signals from this code and instead use nested conditional operators.

This reduces the amount of code that we would have to write without affecting the functionality.

The code snippet below shows how we would do this.

As we can see from this example, when we use conditional operators to model multiplexors in verilog, the code can quickly become difficult to understand. Therefore, we should only use this method to model small multiplexors.

  • Arrays as Multiplexors

It is also possible for us to use verilog arrays to build simple multiplexors.

To do this we combine all of the multiplexor inputs into a single array type and use the address to point at an element in the array.

To get a better idea of how this works in practise, let's consider a basic four to one multiplexor as an example.

The first thing we must do is combine our input signals into an array. There are two ways in which we can do this.

Firstly, we can declare an array and then assign all of the individual bits, as shown in the verilog code below.

Alternatively we can use the verilog concatenation operator , which allows us to assign the entire array in one line of code.

To do this, we use a pair of curly braces - { } - and list the elements we wish to include in the array inside of them.

When we use the concatenation operator we can also declare and assign the variable in one statement, as long as we use a net type.

The verilog code below shows how we can use the concatenation operator to populate an array.

As verilog is a loosely typed language , we can use the two bit addr signal as if it were an integer type. This signal then acts as a pointer that determines which of the four elements to select.

The code snippet below demonstrates this method in practise. As the mux output is a wire, we must use continuous assignment in this instance.

What is the difference between implicit and explicit continuous assignment?

When we use implicit continuous assignment we assign the variable a value when we declare. When we use explicit continuous assignment we use the assign keyword to assign a value.

Write the code for a 2 to 1 multiplexor using any of the methods discussed we discussed.

Write the code for circuit below using both implicit and explicit continuous assignment.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

Table of Contents

Sign up free for exclusive content.

Don't Miss Out

We are about to launch exclusive video content. Sign up to hear about it first.

Verilog Continuous Assignments

Verilog Continuous Assignments

⚡ simple assignments.

In Verilog, continuous assignments are used to drive values onto nets. This is done using the assign statement, which keeps the right-hand side expression continuously evaluated and the left-hand side net driven with the evaluated value. This mechanism is fundamental for combinatorial logic modeling, where the output is a direct function of the input at all times.

🔧 Delay Specification

Continuous assignments can also include delay specifications to model propagation delays, a vital aspect in timing analysis. By using the # symbol followed by a time value, designers can introduce an artificial delay in the assignment, allowing for more realistic simulations that take into account the non-instantaneous nature of real-world signal propagation.

🚌 Bus Structure

In Verilog, a bus is a collection of related wires that can be driven and read as a single unit. Continuous assignments can be applied to entire buses or individual bits within a bus, providing flexibility in manipulating wide data paths and simplifying the design of complex digital circuits. This capability is crucial for efficiently modeling data pathways in hardware descriptions.

Continuous Assignment

LRM §6.1.

A continuous assignment drives a value into a net.

Description:

Continuous assignments model combinational logic. Each time the expression changes on the right-hand side, the right-hand side is re-evaluated, and the result is assigned to the net on the left-hand side.

The implicit continuous assignment combines the net declaration (see Net data type) and continuous assignment into one statement. The explicit assignment require two statements: one to declare the net (see Net data type), and one to continuously assign a value to it.

Continuous assignments are not the same as procedural continuous assignments. Continuous assignments are declared outside of procedural blocks. They automatically become active at time zero, and are evaluated concurrently with procedural blocks, module instances, and primitive instances.

Net data type , Procedural continuous assignment

   

   

  Continuous Assignment Statements

Continuous assignment statements drive nets (wire data type). They represent structural connections.

assign (strength, strength) net = expression;

   

  Example - One bit Adder
   

adder_using_assign (); 2 a, b; 3 sum, carry; 4 5 {carry,sum} a+b; 6 7 8 ( ,a,b,carry,sum); 9 a 0; 10 b 0; 11 a 1; 12 b 1; 13 a 0; 14 b 0; 15 ; 16 17 18
   

   

  Example - Tri-state buffer
   

tri_buf_using_assign(); 2 data_in, enable; 3 pad; 4 5 pad (enable) data_in 1'bz; 6 7 8 ( , 9 , enable, data_in, pad); 10 enable 0; 11 data_in 1; 12 enable 1; 13 data_in 0; 14 enable 0; 15 ; 16 17 18
   

  Propagation Delay

Continuous Assignments may have a delay specified; only one delay for all transitions may be specified. A minimum:typical:maximum delay range may be specified.

   

  Example - Tri-state buffer
   

tri_buf_using_assign_delays(); 2 data_in, enable; 3 pad; 4 5 #(1:2:3) pad (enable) data_in 1'bz; 6 7 8 ( ,enable, data_in,pad); 9 enable 0; 10 data_in 1; 11 enable 1; 12 data_in 0; 13 enable 0; 14 ; 15 16 17
   

   

   

   

verilog continuous assignment with delay

Modeling Concurrent Functionality in Verilog

  • First Online: 01 March 2019

Cite this chapter

verilog continuous assignment with delay

  • Brock J. LaMeres 2  

84k Accesses

This chapter presents a set of built-in operators that will allow basic logic expressions to be modeled within a Verilog module. This chapter then presents a series of combinational logic model examples.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

  • Get 10 units per month
  • Download Article/Chapter or Ebook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
  • Available as EPUB and PDF

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and affiliations.

Department of Electrical & Computer Engineering, Montana State University, Bozeman, MT, USA

Brock J. LaMeres

You can also search for this author in PubMed   Google Scholar

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this chapter

LaMeres, B.J. (2019). Modeling Concurrent Functionality in Verilog. In: Quick Start Guide to Verilog. Springer, Cham. https://doi.org/10.1007/978-3-030-10552-5_3

Download citation

DOI : https://doi.org/10.1007/978-3-030-10552-5_3

Published : 01 March 2019

Publisher Name : Springer, Cham

Print ISBN : 978-3-030-10551-8

Online ISBN : 978-3-030-10552-5

eBook Packages : Engineering Engineering (R0)

Share this chapter

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • Publish with us

Policies and ethics

  • Find a journal
  • Track your research

Verilog Assignments

Variable declaration assignment, net declaration assignment, assign deassign, force release.

  • Procedural continuous

Legal LHS values

An assignment has two parts - right-hand side (RHS) and left-hand side (LHS) with an equal symbol (=) or a less than-equal symbol (<=) in between.

Assignment typeLeft-hand side
Procedural
Continuous
Procedural Continous

The RHS can contain any expression that evaluates to a final value while the LHS indicates a net or a variable to which the value in RHS is being assigned.

Procedural Assignment

Procedural assignments occur within procedures such as always , initial , task and functions and are used to place values onto variables. The variable will hold the value until the next assignment to the same variable.

The value will be placed onto the variable when the simulation executes this statement at some point during simulation time. This can be controlled and modified the way we want by the use of control flow statements such as if-else-if , case statement and looping mechanisms.

An initial value can be placed onto a variable at the time of its declaration as shown next. The assignment does not have a duration and holds the value until the next assignment to the same variable happens. Note that variable declaration assignments to an array are not allowed.

If the variable is initialized during declaration and at time 0 in an initial block as shown below, the order of evaluation is not guaranteed, and hence can have either 8'h05 or 8'hee.

Procedural blocks and assignments will be covered in more detail in a later section.

Continuous Assignment

This is used to assign values onto scalar and vector nets and happens whenever there is a change in the RHS. It provides a way to model combinational logic without specifying an interconnection of gates and makes it easier to drive the net with logical expressions.

Whenever b or c changes its value, then the whole expression in RHS will be evaluated and a will be updated with the new value.

This allows us to place a continuous assignment on the same statement that declares the net. Note that because a net can be declared only once, only one declaration assignment is possible for a net.

Procedural Continuous Assignment

  • assign ... deassign
  • force ... release

This will override all procedural assignments to a variable and is deactivated by using the same signal with deassign . The value of the variable will remain same until the variable gets a new value through a procedural or procedural continuous assignment. The LHS of an assign statement cannot be a bit-select, part-select or an array reference but can be a variable or a concatenation of variables.

These are similar to the assign - deassign statements but can also be applied to nets and variables. The LHS can be a bit-select of a net, part-select of a net, variable or a net but cannot be the reference to an array and bit/part select of a variable. The force statment will override all other assignments made to the variable until it is released using the release keyword.

DMCA.com Protection Status

Delay in Assignment (#) in Verilog

Syntax : #delay

It delays execution for a specific amount of time, ‘delay’.

There are two types of delay assignments in Verilog:

Delayed assignment: #Δt variable = expression; // “ expression”  gets evaluated after the time delay Δt and assigned to the “variable” immediately Intra-assignment delay: variable = #Δt expression;  // “expression” gets evaluated at time 0 but gets assigned to the “variable” after the time delay Δt

Delay_Assignment

Note: #(delay) can not be synthesized. So we do not use #(delay) in RTL module to create delay. There are other methods which can be used to create delays in RLT module. #(delay) can be used in testbench files to create delays.

Spread the Word

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to email a link to a friend (Opens in new window)
  • Click to print (Opens in new window)

Related posts:

  • Blocking (immediate) and Non-Blocking (deferred) Assignments in Verilog
  • Ports in Verilog Module
  • Synthesis and Functioning of Blocking and Non-Blocking Assignments.
  • Module Instantiation in Verilog

Post navigation

Leave a reply cancel reply.

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

Notify me of follow-up comments by email.

Notify me of new posts by email.

Inertial & transport delays

Inertial delay.

Inertial delay models are simulation delay models that filter pulses that are shorted than the propagation delay of Verilog gate primitives or continuous assignments ( assign #5 y = ~a; )

​ COMBINATIONAL LOGIC ONLY !!!

Inertial delays swallow glitches sequential logic implemented with procedure assignments DON'T follow the rule

continuous assignments


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
1ns/100ps
module tb;

reg in;
/////////////////////////////////////////////////////
wire out;
assign #2.5 out = in;
/////////////////////////////////////////////////////
initial begin
in = 0;
#16;
in = 1;
#2;
in = 0;
#10;
in = 1;
#4;
in = 0;
end

initial begin
#50;
$finish();
end

endmodule

procedure assignment - combinational logic


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
1ns/100ps
module tb;

reg in;
reg out;

//////////// combination logic ////////////////////////
always @(*)
#2.5 out = in;
///////////////////////////////////////////////////////
/* the above code is same with following code
always @(*) begin
#2.5;
out = in;
end
*/
initial begin
in = 0;
#16;
in = 1;
#2;
in = 0;
#10;
in = 1;
#4;
in = 0;
end

initial begin
#50;
$finish();
end

endmodule

procedure assignment - sequential logic


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
1ns/100ps
module tb;
reg clk;

reg in;
reg out;

always begin
clk = 0;
#5;
forever begin
clk = ~clk;
#5;
end
end
//////////// sequential logic //////////////////
always @(posedge clk)
#2.5 out <= in;
///////////////////////////////////////////////
initial begin
in = 0;
#16;
in = 1;
#2;
in = 0;
#10;
in = 1;
end

initial begin
#50;
$finish();
end

endmodule
As shown above, sequential logic DON'T follow inertial delay

Transport delay

Transport delay models are simulation delay models that pass all pulses, including pulses that are shorter than the propagation delay of corresponding Verilog procedural assignments

Transport delays pass glitches, delayed in time Verilog can model RTL transport delays by adding explicit delays to the right-hand-side (RHS) of a nonblocking assignment

2
@(*)
y <= #5 ~a;

nonblocking assignment


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1ns/100ps
module tb;

reg in;
reg out;
/////////////// nonblocking assignment ///
always @(*) begin
out <= #2.5 in;
end
/////////////////////////////////////////
initial begin
in = 0;
#16;
in = 1;
#2;
in = 0;
#10;
in = 1;
#4;
in = 0;
end

initial begin
#50;
$finish();
end

endmodule

blocking assignment


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1ns/100ps
module tb;

reg in;
reg out;
/////////////// blocking assignment ///
always @(*) begin
out = #2.5 in;
end
/////////////////////////////////////////
initial begin
in = 0;
#16;
in = 1;
#2;
in = 0;
#10;
in = 1;
#4;
in = 0;
end

initial begin
#50;
$finish();
end

endmodule
It seems that new event is discarded before previous event is realized.

Verilog Nonblocking Assignments With Delays, Myths & Mysteries

Correct Methods For Adding Delays To Verilog Behavioral Models

Article (20488135) Title: Selecting Different Delay Modes in GLS (RAK) URL: https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1O3w000009bdLyEAI

Article (20447759) Title: Gate Level Simulation (GLS): A Quick Guide for Beginners URL: https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1Od0000005xEorEAE

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Continuous assignment with 0 delay not getting the expected value after a signal positive edge

I have implemented an 8 bit serial-in parallel-out register in SystemVerilog and I'm trying to test it. I'm using Icarus Verilog as simulator.

In the test bench, I send 8 bits and wait for the rising edge of a signal, then check the obtained parallel buffer. The problem is that, after waiting for the rising edge, the parallel buffer has not the expected value. However, if I add a #0 delay to the assert it does work.

The signal on which I'm waiting the rising edge, and the buffer that should contain the expected value are assigned as:

I know buff contains the right value, then, how is that on the rising edge of rdy , rdy is effectively 1 but out_data is still 0 ?

enter image description here

Note: See how when rdy goes high out_data is 0xaa .

Serial-in parallel-out register

Test bench:

I have tried to replace these lines

because I suspected the simulator was 'calculating' out_data after rdy because the former depends on the latter. However, they are still continuous assignments with 0 delay, I would expect them to get their value at the exact same time (unless a delay is added).

Would it be a good design practice to add a few picoseconds of delay after each @(posedge signal) to make sure everything is settled by the simulator?

  • system-verilog
  • digital-design

user11989081's user avatar

2 Answers 2

You have a race condition in your testbench because you are trying to sample a signal at a time where it is changing. All digital systems have inherent race conditions, and the way to deal with them is to only sample your signals when you know they are stable.

In your case, you could use a small numeric delay as you have suggested. However, since you have a clock signal, if you know that changes to signals only occur on the posedge of the clock, you could sample signals at the negedge:

This is a more robust approach than using a numeric delay since it scales better (no need to worry about picking the best numeric delay value).

toolic's user avatar

This is a synchronous design and your assertion should synchronous as well. That means only using one edge , the (positive) clock edge. Once you start using other signal edges, you run into race conditions between statements waiting for the signal to change, which includes both the @(posedge rdy) procedural delay and the assign out_data = {8{rdy}} & buff; continuous assignment.

There are two approaches to fixing this in your testbench:

Do not use @(posedge rdy) in your prodedural code. Use

Since i and was_enabled are both updated with nonblocking assignments, rdy gets sampled with its old value, as well as out_data in the assertion that follows.

Another option is using a concurrent assertion which is outside of any procedural code

This reads "When rdy has risen, this implies on the same cycle that out_data must be 8'haa "

dave_59's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged testing system-verilog digital-design or ask your own question .

  • Featured on Meta
  • Upcoming sign-up experiments related to tags
  • The return of Staging Ground to Stack Overflow
  • Should we burninate the [lib] tag?
  • Policy: Generative AI (e.g., ChatGPT) is banned
  • What makes a homepage useful for logged-in users

Hot Network Questions

  • How to produce this table: Probability datatable with multirow
  • Why did Geordi have his visor replaced with ocular implants between Generations and First Contact?
  • Are positions with different physical pieces on two squares but same kind and same color, considered the same?
  • Why was William Tyndale executed but nothing happened to Miles Coverdale?
  • What kind of sequence is between an arithmetic and geometric sequence?
  • Tombs of Ancients
  • Why only Balmer series of hydrogen spectrum is visible?
  • How will the ISS be decommissioned?
  • How to model an optimization problem with mutual exclusivity of two variables, without introducing integer variables?
  • Montreal Airport US arrival to International Departure
  • Less ridiculous way to prove that an Ascii character compares equal with itself in Coq
  • Algorithm to evaluate "connectedness" of a binary matrix
  • What does this symbol do? Box with 1
  • Co-authors with little contribution
  • what is the difference between prayer (προσευχῇ) and prayer also translated as supplication (δέησις) in Philippians 4:6?
  • GND plane between tracks or tracks closer enough to remove the GND tracks
  • Sets of algebraic integers whose differences are units
  • Which numbers are sums of finite numbers of reciprocal squares?
  • Tubeless tape width?
  • In By His Bootstraps (Heinlein) why is Hitler's name Schickelgruber?
  • Could a transparent frequency-altering material be possible?
  • Why can Ethernet NICs bridge to VirtualBox and most Wi-Fi NICs don't?
  • What could explain that small planes near an airport are perceived as harassing homeowners?
  • What actual purpose do accent characters in ISO-8859-1 and Windows 1252 serve?

verilog continuous assignment with delay

IMAGES

  1. Using continuous assignment statements, write a Verilog description of

    verilog continuous assignment with delay

  2. Delays in verilog

    verilog continuous assignment with delay

  3. Verilog Continuous Assignment

    verilog continuous assignment with delay

  4. Introduction to Verilog

    verilog continuous assignment with delay

  5. Introduction to Verilog

    verilog continuous assignment with delay

  6. PPT

    verilog continuous assignment with delay

VIDEO

  1. DIGITAL DESIGN WITH VERILOG ASSIGNMENT 1 2024 KEY

  2. Digital Design With Verilog @NPTEL 2024 Assignment 10 Solutions

  3. Verilog HDL (18EC56)

  4. #digital design with verilog NPTEL ASSIGNMENT 7. answers NPTEL subscribe your channel

  5. Verilog HDL (18EC56)

  6. Digital Design With Verilog Week 1 Assignment Answers #nptel #nptelcourseanswers #nptelquiz

COMMENTS

  1. Continuous Assigns

    Continuous assign statements are used to drive values on to wires. For example: assign a = b & c; This is referred to as a continuous assign because the wire on the left-hand side of the assignment operator is continuously driven with the value of the expression on the right hand side. The target of the assign statement must be a wire.

  2. verilog

    I have this system verilog code, that does continuous assignment for some simple operations with delays and a simple testbench with clocks. ... This is defined in section 10.3.3 Continuous assignment delays in the IEEE 1800-2017 SystemVerilog LRM. There other kinds of delay models to choose from using a variety of different constructs.

  3. Verilog Inter and Intra Assignment Delay

    An intra-assignment delay is one where there is a delay on the RHS of the assignment operator. This indicates that the statement is evaluated and values of all signals on the RHS is captured first. Then it is assigned to the resultant signal only after the delay expires. module tb;

  4. Verilog Continuous Assignment Statement

    In verilog, continuous assignment statement is implemmented with assign statement or with wire declaration. We will first consider the assign statement. The left-hand side of an assignment is a variable to which the right-side value is to be assigned. The left hand side must be a scalar or vector net or concatenation of both.

  5. PDF Correct Methods For Adding Delays To Verilog Behavioral Models

    Adding delays to the left hand side (LHS) of any sequence of blocking assignments to model combinational logic is also flawed. The adder_t7a example shown in Figure 4 places the delay on the first blocking assignment and no delay on the second assignment. This will have the same flawed behavior as the adder_t1 example.

  6. Verilog Continuous Assignment Statements Tutorial

    Steps to Use Continuous Assignment Statements. To use continuous assignment statements in Verilog, follow these steps: Identify the combinational logic relationship between input and output signals. Use the 'assign' keyword to create a continuous assignment statement. Specify the output signal on the left-hand side and the combinational logic ...

  7. Using Continuous Assignment to Model Combinational Logic in Verilog

    The verilog code below shows the general syntax for continuous assignment using the assign keyword. assign <variable> = <value>; The <variable> field in the code above is the name of the signal which we are assigning data to. We can only use continuous assignment to assign data to net type variables.

  8. Verilog Continuous Assignments

    Continuous assignments can also include delay specifications to model propagation delays, a vital aspect in timing analysis. By using the # symbol followed by a time value, designers can introduce an artificial delay in the assignment, allowing for more realistic simulations that take into account the non-instantaneous nature of real-world signal propagation.

  9. Continuous Assignment

    Description: Continuous assignments model combinational logic. Each time the expression changes on the right-hand side, the right-hand side is re-evaluated, and the result is assigned to the net on the left-hand side. The implicit continuous assignment combines the net declaration (see Net data type) and continuous assignment into one statement.

  10. Verilog

    Continuous assignments provide a way of modeling combinational logic at a higher level of abstraction than Gate-Level logic. It allows the use of Boolean logic rather than gate connections. The left-hand side of an assignment is a variable to which the right-side value is to be assigned and must be a scalar or vector net or concatenation of both.

  11. Modeling Concurrent Functionality in Verilog

    Section 3.4: Continuous Assignment with Delay. 3.4.1. Design a Verilog model to implement the behavior described by the 3-input minterm list shown in Fig. 3.1. Use continuous assignment with logical operators and give each logic operation 1 ns of delay. Declare your module and ports to match the block diagram provided. Use the type wire for ...

  12. Verilog Behavioral Modeling Part-IV

    This page contains Verilog tutorial, Verilog Syntax, Verilog Quick Reference, PLI, modelling memory and FSM, Writing Testbenches in Verilog, ... Propagation Delay: Continuous Assignments may have a delay specified; only one delay for all transitions may be specified. A minimum:typical:maximum delay range may be specified. ...

  13. PDF Chapter 3: Modeling Concurrent Functionality in Verilog

    3.4 Design a Verilog model for a combinational logic circuit using continuous assignment with delay. 3.1 Verilog Operators There are a variety of predefined operators in the Verilog standard. It is important to note that operators are defined to work on specific data types and that not all operators are synthesizable.

  14. Delay after and before assignment in SV

    The intra-assignment delay statement is left over from very early Verilog before non-blocking assignments were added to the language. They no longer should be used. ... begin temp = B; #delay A = temp; end You ahould instead use A <= Delay B; which delays the assignment to A without blocking the flow of procedural statements. jaswanth_b August ...

  15. ASSIGNMENTS IN VERILOG

    Continuous assignments model combinational logic. Each time the expression changes on the right-hand side, the right-hand side is re-evaluated, and the result is assigned to the net on the left ...

  16. Verilog Assignments

    This is used to assign values onto scalar and vector nets and happens whenever there is a change in the RHS. It provides a way to model combinational logic without specifying an interconnection of gates and makes it easier to drive the net with logical expressions. // Example model of an AND gate. wire a, b, c;

  17. Delay in Assignment (#) in Verilog

    Syntax: #delay. It delays execution for a specific amount of time, 'delay'. There are two types of delay assignments in Verilog: Delayed assignment: #Δt variable = expression; // " expression" gets evaluated after the time delay Δt and assigned to the "variable" immediately. Intra-assignment delay: variable = #Δt expression ...

  18. Inertial & transport delays

    Transport delay models are simulation delay models that pass all pulses, including pulses that are shorter than the propagation delay of corresponding Verilog procedural assignments. Transport delays pass glitches, delayed in time. Verilog can model RTL transport delays by adding explicit delays to the right-hand-side (RHS) of a nonblocking ...

  19. Continuous assignment verilog

    1. There will be a few more issues in your code. 1. assign l1 = a & b; assign l2 = a | b; The primary rule with continuous assignments is that the LHS must be a net. The reason for this rule is that registers get values at discrete times, but nets are always driven by a value. Changes to a net may happen asynchronously.

  20. testing

    Once you start using other signal edges, you run into race conditions between statements waiting for the signal to change, which includes both the @(posedge rdy) procedural delay and the assign out_data = {8{rdy}} & buff; continuous assignment. There are two approaches to fixing this in your testbench: Do not use @(posedge rdy) in your ...