Professional Documents
Culture Documents
Digital System Design Lecture No. 5
Digital System Design Lecture No. 5
LECTURE NO. 5
FOUR LEVELS OF ABSTRACTION
Verilog provides the designer with the following four levels of abstraction:
• Switch level.
• Gate level.
• Dataflow level.
• Behavioral or algorithmic level.
PORTS AND DATA TYPES (2.6.4.12)
• In Verilog, input ports of a module are always of type wire. An output, if assigned in a
procedural block, is declared as reg, and in cases where the assignment to the output is
made using a continuous assignment statement, then the output is defined as a wire.
• The inout is always defined as a wire. The data types are shown in Figure 2.15.
SIMULATION CONTROL (2.6.4.13)
• Verilog provides several system tasks that do not infer any hardware and are used for simulation control. All
system tasks start with the sign $. Some of the most frequently used tasks and the actions they perform are listed
here.
• $finish makes the simulator exit simulation.
• $stop suspends the simulation and the simulator enters an interactive mode, but the simulation can be resume
from the point of suspension.
• $display prints an output using a format similar to C and creates a new line for further printing.
• $monitor is similar to $display but it is active all the time. Only one monitor task can be active at any time in the
entire simulation. This task prints at the end of the current simulation time the entire list when one of the listed
values changes.
LOADING MEMORY DATA FROM A FILE (2.6.4.14)
• System tasks $readmemb and $readmemh are used to load data from a text
file written in binary or hexadecimal, respectively, into specified memory.
The example here illustrates the use of these tasks. First memory needs to
be defined as:
MACROS(2.6.4.15)
• Verilog supports several compiler directives. These directives are similar to C programming pre
compiler directives. Like #define in C, Verilog provides ‘define to assign a constant value to a tag:
• The tag can then be used instead of a constant in the code. This gives better readability to the code.
The use of the ‘define tag is shown here:
PREPROCESSING
COMMANDS (2.6.4.16)
• These are conditional pre compiler directives used to selectively execute a piece of code:
• The ‘include directive works like #include in C and copies the contents in the file at the location of the
statement. The statement copies the contents of filename.v at the location of the statement.
COMMENTS (2.6.4.17)
• Verilog supports C type comments. Their use is shown below:
• reg a; // One-line comment