Professional Documents
Culture Documents
MODULE -5
USEFUL MODELING TECHNIQUES &
LOGIC SYNTHESIS WITH VERILOG
5.1: Objectives
To describe procedural continuous assignment statements assign, deassign, force, and release. Explain
their significance in modeling and debugging.
Understand how to override parameters by using the defparam statement at the time of module
instantiation.
In the below Example, we overrode the assignment on q and qbar and assigned new values to them when reset
signal went high. The register variables retain the continuously assigned value after the deassisn until they are
changed by a future procedural assignment.
A force on a register overrides any procedural assignments or procedural continuous assignments on the
register until the register is released. The register variables will continue to store the forced value after being
released but can then be changed by a future procedural assignment. To override the values of q and qbar in D
flip flop example for a limited period of time, we could do the following.
In the example above, a new expression is forced on the net from time 50 to time 100. From time 50 to time
100, when the force statement is active, the expression a | b & c will be reevaluated and assigned to out
whenever values of signals a or b or c change. Thus, the force statement behaves like a continuous assignment
except that it is active only for a limited period of time.
5. 3. Overriding Parameters
Parameters can be defined in a module definition. However, during compilation of Verilog modules, parameter
values can be altered separately for each module instance. This allows us to pass a distinct set of parameter
values to each module during compilation regardless of predefined parameter values. There are two ways to
override parameter values: through the defparam statement or through module instance parameter value
assignment.
Defparam Statement
module hello-world was defined with a default id-num = 0. When the module instances w1 and w2 of the type
hello-world are created, their id-num values are modified with the defparam statement. If we simulate the
above design, we would get the following output:
Multiple defparam statements can appear in a module. Any parameter can be overridden with the defparam
statement.
If multiple parameters are defined in the module, during module instantiation they can be overridden by
specifying the new values in the same order as the parameter declarations in the module. If an overriding value
is not specified, the default parameter declaration values are taken.
Module-instance, parameter value assignment is a very useful method used to override parameter values and to
customize module instances.
The ' ifdef statement can appear anywhere in the design. A designer can conditionally compile statements,
modules, blocks, declarations, and other compiler directives. The 'else statement is optional. A maximum of one
'else statement can accompany the 'ifdef. An 'ifdef is always closed by a corresponding ' endif. The conditional
compile flag can be set by using the 'define statement inside the Verilog file.
Closing files
Files can be closed with the system task $fclose.
Usage: $fclose(<file-handle>);
A file cannot be written to once it is closed. The corresponding bit in the multichannel descriptor is set to 0. The
next $fopen call can reuse the bit.
The output from the simulation will look like the following
5.5.3 Strobing
Strobing is done with the system task keyword $strobe.
If $strobe is used, it is always executed after all other assignment statements in the same time unit have
executed. Thus, $strobe provides a synchronization mechanism to ensure that data is displayed only after all
other assignment statements, which change the data in that time step, have executed.
In the above Example the values at positive edge of clock will be displayed only after statements a = b and c = d
execute. If $display was used, $display might execute before statements a = b and c = d, thus displaying
different values.
System tasks are provided for selecting module instances or module instance signals to dump ($dumpvars),
name of VCD file ($dumpfile), starting and stopping the dump process ($dumpon, $dumpoff), and generating
checkpoints ($dumpall).
The advent of computer-aided logic synthesis tools has automated the process of converting the high-level
description to logic gates. Instead of trying to do logic synthesis in their minds, designers can now concentrate
on the architectural trade-offs, high-level description of the design, accurate design constraints, and
optimization of cells in the standard cell library. These are fed to the compute raided logic synthesis tool, which
performs several iterations internally and generates the optimized gate-level description. Also, instead of
drawing the high level description on a screen or a piece of paper, designers describe the high-level design in
terms of HDLs.
Basic Computer-Aided Logic Synthesis Process
If a, b, c, and out are 2-bit vectors [1:0], then the above assign statement will frequently translate to two
identical circuits for each bit.
The for loops can be used to build cascaded combinational logic: For example, the following for loop builds an
8 bit full adder.
The always statement can be used to infer sequential and combinational logic. For sequential logic, the always
statement must be controlled by the change in the value of a clock signal clk.