Documente Academic
Documente Profesional
Documente Cultură
Ranga Rodrigo
Outline
Contents
1 Hardware Description Language 1
1.1 Module Declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Combinational Logic 8
2.1 Design Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Decoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Logic simulation displays the behavior of a digital system through a computer. The
simulation of the circuit predicts how the hardware will behave before it is
fabricated. The stimulus, the logic values of the inputs to a circuit, that tests
the functionality of the design is called a test bench.
1
Table 1: Verilog and VHDL1
VHDL Verilog
Commissioned in 1981 by Department of Created by Gateway Design Automation in
Defense; now an IEEE standard. 1985; now an IEEE standard.
Initially created for ASIC synthesis. Initially an interpreted language for gate-
level simulation.
Strongly typed; potential for verbose code. Less explicit typing (e.g., compiler will pad
arguments of different widths).
Strong support for package management No special extensions for large designs.
and large designs.
Logic synthesis is the process of deriving a list of physical components and their
interconnections (called a netlist) from the model of a digital system described
in HDL. The netlist can be used to fabricate an integrated circuit or to lay out
a printed circuit board with hardware counterparts of logic gates in the list.
Timing verification confirms that the fabricated integrated circuit will operate at a
specified speed. Timing verification checks each signal path to verify that it is
not compromised by propagation delay.
Fault simulation compares the behavior of an ideal circuit with the behavior of a
circuit that contains a process-induced flaw. Fault simulation is used to iden-
tify stimuli that can be used to identify the difference between the faulty cir-
cuit and the fault-free circuit.
Companies that design integrated circuits use proprietary and public HDLs. In
the public domain there are two standard HDLs that are supported by the IEEE:
VHDL and Verilog. Hardware structures can be modeled effectively in either VHDL
and Verilog. Verilog is similar to C and a bit easier to learn. Table 1 shows a brief
comparison of VHDL and Verilog.
3. a truth table.
The HDL description of the circuit of Figure 1 is given in Listing 1. We save the
module file with the extension, e.g., “ simplecct.v”. This is a module declaration. We
need to write another Verilog file called the test bench. Usually we name the test-
bench with the same filename as the module with a t prefixed, e.g., “ tsimplecct.v”
2
A w
G1
B G3 D
C E
G2
and G1(w, A , B ) ;
not G2( E , C ) ;
or G3(D, w, E ) ;
endmodule
module simplecct(A, B, C, D, E); Declaration of the module and the
ports. Note the semicolon.
output D, E; Specifying each port as input, out-
put, or inout.
input A, B, C;
wire w; Declaring internal connections.
and G1(w, A, B); Expressing the module behavior.
not G2(E,C); Each statement executes in paral-
lel.
or G3(D, w, E);
endmodule Concluding the module.
Test Bench
In order to simulate a circuit with an HDl, it is necessary to apply inputs to the
circuit so that the simulator will generate an output response. An HDl description
3
that provides the stimulus to the design is called a test bench. In its simplest form,
a test bench is a module containing a signal generator and an instantiation of the
model that is to be verified. Listing 2 shows a test bench for out simple circuit.
simplecct dut (A , B , C, D, E ) ;
initial
begin
A = 1 ’b0 ; B = 1 ’b0 ; C = 1 ’b0 ;
#100 A = 1 ’b1 ; B = 1 ’b1 ; C = 1 ’b1 ;
end
endmodule
This has no input or output ports. Within the test bench, the inputs to the circuit
are declared with the keyword reg and the outputs are declared with the keyword
wire. The module simplecct is instantiatiated with the instance name dut (device
under test). The initial keyword is used with a set of statements that begin execut-
ing when the simulation is initialized; initial statement terminates execution when
the last statement has finished executing. initial statements are usually used to de-
scribe waveforms in a test bench. The set of statements to be executes is called a
block statement and consists of several statements enclosed by the keywords begin
and end. The statements are executes in sequence from top to bottom. #100 speci-
fies a delay of 100 ns. In Verilog, the propagation delay of a gate is specified in terms
of time units and is specified by the symbol #.
Gate Delays
All physical circuits exhibit a propagation delay between the transition of an in-
put and the resulting transition of the output. As mentioned earlier, in Verilog, the
propagation delay of a gate is specified in terms of time units and is specified by
the symbol #. The numbers associated with time delays in Verilog are dimension-
less. The association of a time unit with physical time is made with the ‘timescale
compiler directive. For example, in the directive
‘ t i m e s c a l e 1ns/1000ps
the first number specifies the unit of measurement for time delay. The second num-
ber specifies the precision for which the delays are wounded off, in this case to 0.1
ns.
Listing 3 repeats the simple circuit with propagation delays specified for each
gate. Table 2 shows the output changes if the inputs change from ABC = 000 to
ABC = 111. The output of the inverter E changes from 1 to 0 after a 10-ns delay.
The output of AND gate at w changes from 1 to 0 after a 30-ns delay. The output
of the OR gate at D changes from 1 to 0 at t = 30 ns and then changes back to 1 at
t = 50 ns. In both the cases, the change in the output of the OR gate results from the
change in its input s 20 ns earlier. It is clear from this result that although output
D eventually returns to a final value of 1 after the input changes, the gate delays
produce a negative spike that lasts 20 ns before the final value is reached.
4
Table 2: Outputs of gates after a delay.
Time units Input Output
(ns) A B C E w D
Initial − 0 0 0 1 0 1
change − 1 1 1 1 0 1
10 1 1 1 0 0 1
20 1 1 1 0 0 1
30 1 1 1 0 1 0
40 1 1 1 0 1 0
50 1 1 1 0 1 1
We can use a test bench with the same content as in Listing 2 to test the new
module. In doing so, we will be able to observe the negative spike.
Example 1. Declare a module that describes a circuit that is specified with the fol-
lowing two Boolean expressions:
E = A + BC + B 0 D
F = B 0C + BC 0 D 0
5
The two assign statements describe the Boolean equations. The simulator de-
tects when the test bench changes a value of one or more of the inputs. When this
happens the simulator updates the values of the outputs. The continuous assign-
ment mechanism is so named because the relationship between the assigned value
and the variable is permanent. The mechanism acts just like combinational logic,
has a gate-level equivalent circuit, and is referred to as an implicit combinational
logic.
p r i m i t i v e udp_02467 (D, A , B , C ) ;
output D;
input A , B , C;
P
// Truth t a b l e f o r D = f (A, B,C ) = (0, 2, 4, 6, 7) ;
table
// A B C : D
0 0 0 : 1;
0 0 1 : 0;
0 1 0 : 1;
0 1 1 : 0;
1 0 0 : 1;
1 0 1 : 0;
1 1 0 : 1;
1 1 1 : 1;
endtable
endprimitive
// I n s t a n t i a t e p r i m i t i v e
// V e r i l o g model : C i r c u i t i n s t a n t i a t i o n of circuit_udp_02467
module circuit_udp_02467 ( e , f , a , b , c , d ) ;
output e , f ;
input a , b , c , d ;
udp_02467 ( e , a , b , c ) ;
6
and ( f , e , d ) ;
endmodule
Although Verilog HDL uses this kind of description for UDPs only, other HDLs
and computer-aided design (CAD) systems use other procedures to specify digital
circuits in tabular form. The tables can be processed by CAD software to derive an
efficient gate structure of the design.
None of the Verilog’s predefined primitives describe sequential logic. The model
for a sequential logic requires that its output be declared as a reg data type, and that
a column be added to the truth table to describe the next state. So the columns are
organized as inputs: state: next state.
7
Combinational
n inputs .. .. m outputs
circuit
. .
2 Combinational Logic
Logic circuits for digital systems may be combinational or sequential. A combina-
tional circuit consists of logic gates whose outputs at any time are determined from
only the present combination of inputs. A combinational circuit performs an op-
eration that can be specified logically as a set of Boolean functions. In contrast,
sequential circuits employ storage elements in addition to logic gates. Their out-
puts are functions of both the inputs and the state of the storage elements. Because
the state of the storage elements is a function of previous inputs, the outputs of a se-
quential circuit depends not only on present values of input, but also on past inputs,
and the circuit behavior must be specified by a time sequence of inputs and internal
states.
A combinational circuit consists of input variables, logic gates, and output vari-
ables. Combinational logic gates react to the values of the signals at the inputs and
produce the value of the output signal, transforming binary information from the
given input data to a required output data. Figure 2 shows a block diagram of a
combinational circuit. For n input variables, there are 2n possible binary input com-
binations. For each possible input combination, there is one possible output value.
Thus, a combinational circuit can be specified with a truth table that lists the out-
put values for each combination of input variables. A combinational circuit can also
be described by m Boolean functions, one for each output variable. Each output
function is expressed in terms of n input variables.
1. From the specifications of the circuit, determine the required number of in-
puts and outputs and assign a symbol to each.
2. Derive the truth table that defines the required relationship between inputs
and outputs.
3. Obtain the simplified Boolean function for each output as a function of the
input variables.
4. Draw a logic diagram and verify the correctness of the design (manually or by
simulation).
8
Table 3: Code conversion: BCD to Excess-3 (Example 3).
Input BCD Output
A B C D w x y z
0 0 0 0 0 0 1 1
0 0 0 1 0 1 0 0
0 0 1 0 0 1 0 1
0 0 1 1 0 1 1 0
0 1 0 0 0 1 1 1
0 1 0 1 1 0 0 0
0 1 1 0 1 0 0 1
0 1 1 1 1 0 1 0
1 0 0 0 1 0 1 1
1 0 0 1 1 1 0 0
A2
A1
A0
D0 D1 D2 D3 D4 D5 D6 D7
2.2 Decoders
A decoder is a combinational circuit that converts binary information from n input
lines to a maximum of 2n unique output lines. In the n-bit coded information has
unused combinations, the decoder may have fewer than 2n outputs. These decoders
are called n-tom-line decoders, where m ≤ 2n . Their purpose is to generate the 2n
(or fewer) minterms of n variables. Figure 3 shows a 3-to-8 decoder. Table 4 gives its
truth table.
Some decoders are constructed with NAND gates. Since a NAND gate produces
the AND operation with an inverted output, it becomes more economical to gen-
erate the decoder’s minterms in their complement form. Furthermore, decoders
include one or more enable inputs to control the circuit operation.
Example 4. Draw a 2-to-4-line decoder with an enable input constructed with NAND
gates.
9
Table 4: Truth table for 3-to-8 decoder.
Inputs Outputs
A2 A1 A0 D0 D1 D2 D3 D4 D5 D6 D7
0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
0 1 0 0 0 1 0 0 0 0 0
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
1 0 1 0 0 0 0 0 1 0 0
1 1 0 0 0 0 0 0 0 1 0
1 1 1 0 0 0 0 0 0 0 1
Some decoders are constructed with NAND gates. Since a NAND gate produces
the AND operation with an inverted output, it becomes more economical to gen-
erate the decoder’s minterms in their complement form. Furthermore, decoders
include one or more enable inputs to control the circuit operation.
Example 5. Draw a 2-to-4-line decoder with an enable input constructed with NAND
gates.
10
Example 6. Design a 2-to-4-line decoder with the enable input using HDL gate-level
description.
11