COLab 4
COLab 4
Continuous Assignment
A continuous assignment is the most basic statement in dataflow modeling, used to drive a value
onto a net. This assignment replaces gates in the description of the circuit and describes the circuit
at a higher level of abstraction. The assignment statement starts with the keyword assign.
Continuous assignments have the following characteristics:
1. The left hand side of an assignment must always be a scalar or vector net or a concatenation of
scalar and vector nets. It cannot be a scalar or vector register.
2. Continuous assignments are always active. The assignment expression is evaluated as soon as
one of the right-hand-side operands changes and the value is assigned to the left-hand-side net.
3. The operands on the right-hand side can be registers or nets or function calls. Registers or nets
can be scalars or vectors.
4. Delay values can be specified for assignments in terms of time units. Delay values are used to
control the time when a net is assigned the evaluated value. This feature is similar to specifying
delays for gates. It is very useful in modelling timing behavior in real circuits.
Example-1: Examples of Continuous Assignment
Figure-1 Delays
Dataflow modeling describes the design in terms of expressions instead of primitive gates.
Expressions, operators, and operands form the basis of dataflow modeling.
Expressions
Expressions are constructs that combine operators and operands to produce a result.
Operands
Some constructs will take only certain types of operands. Operands can be constants, integers, real
numbers, nets, registers, times, bit-select (one bit of vector net or a vector register), part-select
(selected bits of the vector net or register vector), and memories
Operators
Operators act on the operands to produce desired results. Verilog provides various types of
operators.
Operator Types
Verilog provides many different operator types. Operators can be arithmetic, logical, relational,
equality, bitwise, reduction, shift, concatenation, or conditional. Some of these operators are
similar to the operators used in the C programming language. Each operator type is denoted by a
symbol. Table -1 shows the complete listing of operator symbols classified by category.
Table - 1
Arithmetic Operators
There are two types of arithmetic operators: binary and unary.
Binary operators
Binary arithmetic operators are multiply (*), divide (/), add (+), subtract (-), power (**), and
modulus (%). Binary operators take two operands.
Negative numbers are represented as 2's complement internally in Verilog. It is advisable to use
negative numbers only of the type integer or real in expressions. Designers should avoid negative
numbers of the type <sss> '<base> <nnn> in expressions because they are converted to unsigned
2's complement numbers and hence yield unexpected results.
Logical Operators:
Logical operators are logical-and (&&), logical-or (||) and logical-not (!). Operators && and || are
binary operators. Operator ! is a unary operator. Logical operators follow these conditions:
Equality Operators:
filling if the operands are of unequal length. Table – 2 lists the operators.
It is important to distinguish bitwise operators ~, &, and | from logical operators !, &&, ||. Logical
operators always yield a logical value 0, 1, x, whereas bitwise operators yield a bit-by-bit value.
Logical operators perform a logical operation, not a bit-by-bit operation.
Reduction Operators:
Shift Operators:
Concatenation Operators:
Replication Operators:
Conditional Operator
The conditional operator(?:) takes three operands.
The condition expression (condition_expr) is first evaluated. If the result is true (logical 1), then
the true_expr is evaluated. If the result is false (logical 0), then the false_expr is evaluated. If the
result is x (ambiguous), then both true_expr and false_expr are evaluated and their results are
compared, bit by bit, to return for each bit position an x if the bits are different and the value of
the bits if they are the same.
Conditional operators are frequently used in dataflow modeling to model conditional assignments.
The conditional expression acts as a switching control.
Conditional operations can be nested. Each true_expr or false_expr can itself be a conditional
operation. In the example that follows, convince yourself that (A==3) and control are the two select
signals of 4-to-1 multiplexer with n, m, y, x as the inputs and out as the output signal.
There is a more concise way to specify the 4-to-1 multiplexers. In this we will use this conditional
operator to write a 4-to-1 multiplexer.
Dataflow code:
Verilog Code for T-flipflop
Finally, we define the lowest level module D_FF (edge_dff ), using dataflow statement.
Output:
The output of the simulation is shown below. Note that the clear signal resets the count to zero.