Final DE + VHDL Lab B18EC3080 As On 31 July 2019
Final DE + VHDL Lab B18EC3080 As On 31 July 2019
Charitable Trust
www.reva.edu.in
Campus Address: Rukmini Knowledge Park, Kattigenahalli, Yelahanka, Bengaluru - 560 064
REVA University School of ECE
CONTENTS
Sl. Experiment / Page
Description
No. Program No No.
Part A Digital Electronics
1. Course Objectives & Syllabus 02
2. Syllabus / Lab Experiments: 03
3. Introduction 04
4. Front Panel of Digital IC Trainer Kit 32
5. Realization of Logic gates 39
6. 1 Realization of Parallel Adder / Subtractor using IC 7483 43
7. 2 4 Bit Binary to Gray Code conversion and Vice-Versa 55
8. 3 Realization of 4:1 Multiplexer and 1:4 De-multiplexer 60
Arithmetic Circuit realization (Half/Full Adder/ Full Subtractor)
9. 4 75
using Mux
Construction and verification of JK Master-Slave, T type & D type
10. 5 84
Flip-Flops using logic gates
Construction and realization of 3 bit ripple up/down counter using
11. 6 90
IC 7476 and other logic gates
Design and verification of mod-n, 3bit synchronous counter using
12. 7 101
7476 JK FF.
13. Challenge Experiments 104
14. Frequently Asked Viva Questions 105
15. Digital IC’s PIN Details 107
Part B VHDL
1. VHDL Language Overview 113
2. To write a VHDL Code to realize all the Logic gates. 121
3. 1a To write a VHDL Code to realize a 2 to 4 Decoder. 125
4. 1b To write a VHDL Code to realize an 8 to 3 Encoder. 129
5. 1c To write a VHDL Code to realize an 8 to 1 Multiplexer. 133
6. 1d Write VHDL code for 1 TO 4 DEMUX. 135
7. 1e Write VHDL code for N-BIT COMPARATOR. N<3. 137
Write a VHDL code to describe a FULL ADDER using different
8. 2 140
Styles/Types of Description.
To write a VHDL code for a 4 bit binary and 4bit BCD counters
9. 3 144
with Synchronous and Asynchronous reset using Clock Division.
10. 4 Write a VHDL code to control speed, direction of Stepper motor. 148
Write a VHDL code to control speed, direction of DC Motor
5. 154
(PWM Technique).
11. I/O PIN details. 157
12. Model viva questions. 158
13. Viva question and answers. 160
B18EC3080 L T P C
Digital Electronics and VHDL Lab
Duration :16Wks 0 0 2 2
Prerequisites:
Course Objectives:
Course Outcomes:
Syllabus
Digital Electronics and VHDL Lab - B18EC3080
Lab Experiments:
Introduction
In 1854 George Boole introduced a systematic treatment of logic and developed an algebraic
system now known as Boolean algebra. In 1938, C.E. Shannon introduced a two valued
Boolean algebra called switching algebra, which demonstrated that, the properties of bi-stable
electrical switching circuits could be represented through this algebra. With passage of time
Boolean algebra has emerged as a powerful tool and forms the foundation of many theories
of computer science and engineering.
Boolean algebra like any other mathematical system may be defined with a set of elements, a
set of operators and number of axioms or postulates. A set of element is a collection of
objects having a common property.
A logic gate is an elementary building block of a digital circuit. Most logic gates have two
inputs and one output. At any given moment, every terminal is in one of the two binary
conditions low (0) or high (1), represented by different voltage levels. The logic state of a
terminal can, and generally does, change often, as the circuit processes data. In most logic
gates, the low state is approximately zero volts (0 V), while the high state is approximately
five volts positive (+5 V).
There are three basic logic gates: AND, OR, & NOT, and two Universal logic gates NAND
and NOR other logic gates are emerged from basic gates such as X-OR and X-NOR.
Comparing Boolean algebra with arithmetic and ordinary algebra we note the following
differences:
Boolean algebra does not have additive or multiplicative inverses; hence there are no
subtraction or division operations.
Boolean algebra defines an operator called complement which is not available in
normal algebra.
Normal algebra deals with real number, which constitute an infinite set of elements
where as Boolean algebra deals with a set of only two elements 0 and 1 (defined as
two valued Boolean algebra).
The distributive law of '+' over '.' i.e., x + (y. z) = (x + y). (x + z) is valid for Boolean
algebra but not for normal algebra.
Using combinations of logic gates, complex operations can be performed. In theory, there is
no limit to the number of gates that can be arrayed together in a single device. But in practice,
there is a limit to the number of gates that can be packed into a given physical space. Arrays
of logic gates are found in digital integrated circuits (lC’s).
As IC technology advances, the required physical volume for each individual logic gate
decreases and digital devices of the same or smaller size become capable of performing ever-
more complicated operations at ever-increasing speeds.
They are called universal gates because all of the other gates may be constructed using only
those two gates. That is important because it's a lot cheaper in practice to make lots of similar
things than a bunch of different things (different gates).
All other gates/functions can be implemented by NOR or NAND gates. So they are called
universal gates. In fact, in chips, entire logic maybe built using only NAND or NOR gates.
Implementing with NAND is easier when considering power and area of the chip. They are
called universal gates as they can be used to design all other logic circuit. Elements like X-
OR, NOR etc. Also these gates can be realized through easy combination of diodes thus
making them easy to use base elements in any chip designing project.
NAND, NOR gates are called universal gates because they can be used to create all the
remaining logical gates. Like sending the same input to the inputs of the NAND or NOR will
make it a NOT gate. Because from them you can create any other one! You can make any
other gate using NAND and NOR. Any other gate i.e. AND, OR, XOR etc can be created
using these basic gates i.e. it needs only NAND and NOR gates to create logical circuits.
NAND Gate
In digital electronics, a NAND gate (NOT-AND) is a logic gate which produces an output
which is false only if all its inputs are true; thus its output is complement to that of an AND
gate. A LOW (0) output results only if all the inputs to the gate are HIGH (1); if any input is
LOW (0), a HIGH (1) output results. A NAND gate is made using transistors and junction
diodes. By De Morgan's theorem, a two-input NAND gate's logic may be expressed
as AB=A+B, making a NAND gate equivalent to inverters followed by an OR gate.
The NAND gate is significant because any Boolean function can be implemented by using a
combination of NAND gates. This property is called functional completeness. It shares this
property with the NOR gate. Digital systems employing certain logic circuits take advantage
of NAND's functional completeness.
The function NAND (a1, a2, ..., an) is logically equivalent to NOT(a1 AND a2 AND ...
AND an).
NAND gates with two or more inputs are available as integrated circuits in transistor-
transistor logic, CMOS, and other logic families.
Truth Table
Input Output
A B Y
0 0 1
0 1 1
1 0 1
1 1 0
NOR Gate
The NOR gate is a digital logic gate that implements logical NOR - it behaves according to
the truth table to the right. A HIGH output (1) results if both the inputs to the gate are LOW
(0); if one or both input is HIGH (1), a LOW output (0) results. NOR is the result of
the negation of the OR operator. It can also be seen as an AND gate with all the inputs
inverted. NOR is a functionally complete operation—NOR gates can be combined to
generate any other logical function. It shares this property with the NAND gate. By contrast,
the OR operator is monotonic as it can only change LOW to HIGH but not vice versa.
In most, but not all, circuit implementations, the negation comes for free—
including CMOS and TTL. In such logic families, OR is the more complicated operation; it
may use a NOR followed by a NOT. A significant exception is some forms of the domino
logic family.
Truth Table
Input Output
A B Y
0 0 1
0 1 0
1 0 0
1 1 0
AND Gate
The AND gate is a basic digital logic gate that implements logical conjunction - it behaves
according to the truth table to the right. A HIGH output (1) results only if all the inputs to the
AND gate are HIGH (1). If none or not all inputs to the AND gate are HIGH, a LOW output
results. The function can be extended to any number of inputs.
Truth Table
Input Output
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
OR Gate
The OR gate is a digital logic gate that implements logical disjunction – it behaves according
to the truth table to the right. A HIGH output (1) results if one or both the inputs to the gate
are HIGH (1). If neither input is high, a LOW output (0) results. In another sense, the
function of OR effectively finds the maximum between two binary digits, just as the
complementary AND function finds the minimum.
Truth Table
Input Output
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
NOT Gate
In digital logic, an inverter or NOT gate is a logic gate which implements logical negation.
The truth table is shown on the right.
Truth Table
Input Output
A Y
0 1
1 0
EXOR Gate
XOR gate (sometimes EOR, or EXOR and pronounced as Exclusive OR) is a digital logic
gate that gives a true (1 or HIGH) output when the number of true inputs is odd. An XOR
gate implements an exclusive or; that is, a true output results if one, and only one, of the
inputs to the gate is true. If both inputs are false (0/LOW) or both are true, a false output
results. XOR represents the inequality function, i.e., the output is true if the inputs are not
alike otherwise the output is false. A way to remember XOR is "one or the other but not
both".
XOR can also be viewed as addition modulo 2. As a result, XOR gates are used to implement
binary addition in computers. A half adder consists of an XOR gate and an AND gate. Other
uses include subtractors, comparators, and controlled inverters.
Truth Table
Input Output
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
Note: Use Patch chords smoothly & test Patch Chord Continuity for every circuit before
connecting.
To Test, connect Patch chord end A to Input Zero (GND) & B to output LED Indicator. If
LED Glows Green (0) then the patch chord is good or else Replace the patch chord.
Truth Table
Input Output
A B Y
0 0 0
0 1 0
1 0 0
1 1 1
2. OR Gate: IC 7432:
Truth Table
Input Output
A B Y
0 0 0
0 1 1
1 0 1
1 1 1
Truth Table
Input Output
A Y
0 1
1 0
Truth Table
Input Output
A B Y
0 0 0
0 1 1
1 0 1
1 1 0
7. Truth Table verification of Logic gates using NAND & NOR gates (Universal gates)
NOT
gate
AND
gate
OR gate
EX-OR
gate
Procedure:
1. The connections are made as shown in Circuit(by referring IC PIN diagram)
2. The input terminals are connected to the toggle switches & the output is connected to
the Output Connector (LED’s).
3. The power is applied between the VCC & Ground terminals.
4. The Logic levels are applied at the Input for all combinations indicated in Truth Table
& the Output is observed on LED’s.
Experiment – 1
Realization of Parallel Adder and Subtractor
Aim: Realization of Parallel Adder and Subtractor using IC 7483.
Parallel adder:
The 7483 IC is a 4-bit parallel adder chip. Note: the chip can also be listed as a 74LS83. The
LS signifies that the chip is a newer, lower-power, faster version. A binary parallel adder is a
digital function that produces the arithmetic sum of two binary numbers in parallel. It consists
of full adders connected in cascades with the output carry from one full adder connected to
input carry of the next full adder.
Components &equipments required: 7483, 7486 & 7404, Digital IC Trainer Kit, 4mm.
Patch cards etc.
PIN Diagram:
Circuit Diagram:
Note: A1, A2, A3, A4 & B1, B2, B3, B4 &Cin are the Inputs.
S1, S2, S3, S4 and Cout are the Outputs.
Here A1, B1 & S1 are the LSB Bits.
S is considered as selection Input to select for Addition or Subtraction.
For Addition S=0 & For Subtraction S=1.
Problems:
A := 1111 1111 1100 1100 0111
B := 0000 0000 0011 0011 1110
Cin : = 0 1 0 1 1
Sum = (Do it yourself)
II Step:
Adding 1’s complement of Subtrahend to the minuend
A4 ,A3, A2, A1 = 1 0 0 1 Given Larger Number
B4, B3, B2, B1 = + 1 1 0 0
=1 0101
Example 1: Subtract
A4 ,A3, A2, A1 = 1 0 0 1
B4, B3, B2, B1 = 0 0 1 1 Give this from Trainer Kit
II Step:
A4 ,A3, A2, A1 = 1 0 0 1 Given Larger Number
B4, B3, B2, B1 = + 1 1 0 1
1 0110
Carry generated
III Step:
Neglect the carry to get true Answer
Therefore Answer = 0 1 1 0 - Trainer Kit
II Step:
Adding 1’s complement of Subtrahend to the minuend
A4 ,A3, A2, A1 = 0 0 1 1 Given Larger Number
B4, B3, B2, B1 = +0 1 1 0
= 1 0 0 1 Trainer Kit Final Output
Example 1: Subtract
A4 ,A3, A2, A1 = 0 0 1 1 3
B4, B3, B2, B1 = 1 0 0 1 9 Give this from Trainer Kit
II Step:
A4, A3, A2, A1 = 0 0 1 1 Given Larger Number
B4, B3, B2, B1 = + 0 1 1 1
1 0 1 0 Trainr Kit Final Output
III Step: Here theoretically perform 2’s Compliment operation to get True Answer.
1 0 1 0 (Trainer Kit Output)
2’s Compliment
0 1 1 0 True Answer
Problems:
A := 0110 1100 0100 0111 1111
B := 0100 0111 0110 1100 1111
Procedure:
1. The connections are made as shown in Circuit(by referring IC PIN diagram)
2. The input terminals are connected to the toggle switches & the output is connected to
the Output Connector (LED’s).
3. The power is applied between the VCC & Ground terminals.
4. The Logic levels are applied at the Input for all combinations indicated in Truth Table
& the Output is observed on LED’s.
5. Given problems should be worked out & get the outputs.
Experiment – 2
4 Bit Binary to Gray Code Conversion & Vice Versa
Aim: Realization of 3bit Binary to Gray Code conversion and Vice-Versa using Basic /
Universal gates.
Binary Codes:
The usual way of expressing a decimal number in terms of a binary number is known as pure
binary coding. A number of other techniques can be used to represent a decimal number.
Gray Code:
Gray coding is an important code and is used for its speed, it is also relatively free from
errors. In pure binary coding or 8421 BCD then counting from 7 (0 1 1 1) to 8 (1000) requires
4 bits to be changed simultaneously. If this does not happen then various numbers could be
momentarily generated during the transition so creating spurious numbers which could be
read.
Gray coding avoids this since only one bit changes between subsequent numbers. To
construct the code there are two simple rules. First start with all 0s and then proceed by
changing the least significant bit (LSB) which will bring about a new state.
Components &equipments required: IC 7486, Digital IC Trainer Kit, 4mm. Patch cards etc.
K - Maps:
K - Maps:
Procedure:
1. The connections are made as shown in Circuit(by referring IC PIN diagram)
2. The input terminals are connected to the toggle switches & the output is connected to
the Output Connector (LED’s).
3. The power is applied between the VCC & Ground terminals.
4. The Logic levels are applied at the Input for all combinations indicated in Truth Table
& the Output is observed on LED’s.
Experiment – 3
4:1 Multiplexer / 1:4 De-multiplexer
Using Basic/universal gates
Aim: Realization of 4:1 Multiplexer and 1:4 De-multiplexer Using Basic/universal gates.
Multiplexer:
Multiplexer has many data input lines and one output line.
Multiplexer (MUX) places the data of one of its input lines on the output line.
MUX has a set of “n” address lines to select one of 2n input line
SOP realization is possible using MUX.
In other words, the multiplexer works like the input selector. Only one input is selected at a
time, and the selected input is transmitted to the single output.
Demultiplexer:
A demultiplexer (DEMUX) is a device which essentially performs the opposite operation to
the MUX. That is, it functions as an electronic switch (or data distributor) to route an
incoming data signal to one of several outputs.
The demultiplexer is the inverse of the multiplexer, in that it takes a single data input and n
address inputs. It has 2n outputs. Output is inverted in IC 74139 1:4 Demultiplixer.
Components &equipments required: IC 74153, 74139, 7404, 7408, 7432, 7400 & 7420.
Digital IC Trainer Kit, 4mm. Patch cards etc.
Connection Diagram MUX:
Truth Table:
Address
Enable
Select Data Inputs Output
Inputs Comments
Inputs
S1 S0 I0 I1 I2 I3 Y
0 0
0 0 0 X X X I0 Selected
1 1
0 0
0 0 1 X X X I1 Selected
1 1
0 0
0 1 0 X X X I2 Selected
1 1
0 0
0 1 1 X X X I3 Selected
1 1
1 X X X X X X X MUX Disabled
Circuit Diagram:
Circuit Diagram:
Truth Table:
Address
Data Input Select Data Outputs
Inputs Comments
S1 S0 Y0 Y1 Y2 Y3
(Da) (Db)
0 0 0 0 0 1 1 1 Y0 Selected
0 1 1 0 1 1 Y1 Selected
1 0 1 1 0 1 Y2 Selected
1 1 1 1 1 0 Y3 Selected
Circuit Diagram:
Procedure:
1. The connections are made as shown in Circuit(by referring IC PIN diagram)
2. The input terminals are connected to the toggle switches & the output is connected to
the Output Connector (LED’s).
3. The power is applied between the VCC & Ground terminals.
4. The Logic levels are applied at the Input for all combinations indicated in Truth Table
& the Output is observed on LED’s.
5. X in the truth table indicates Don’t care condition since depending on the selection
line the data line will be selected.
Experiment – 4
Arithmetic Circuit Realization
(Half/Full, Adder/Subtractor) using Mux.
Components &equipments required: IC 74153, 7404. Digital IC Trainer Kit, 4mm. Patch
cards etc.
Circuit Diagram:
OR
Truth Table:
Input Output
A B S C
S1 S0 Ia Ib
0 0 0 0 0
1 0 1 1 0
2 1 0 1 0
3 1 1 0 1
Circuit Diagram:
Circuit Diagram:
OR
Circuit Diagram:
Circuit Diagram:
OR
Truth Table:
Input Output
A B D B
S1 S0 Ia Ib
0 0 0 0 0
1 0 1 1 1
2 1 0 1 0
3 1 1 0 0
Circuit Diagram:
Circuit Diagram:
OR
Truth Table: Implementation Table:
Input Output
A B Bin D Bout
0 0 0 0 0 0
Bin Bin
1 0 0 1
1 1
2 0 1 0 1 1
Logic
3 0 1 1 0 1
1
4 1 0 0 1 0
Logic
5 1 0 1 0 0
0
6 1 1 0 0 0
Bin Bin
7 1 1 1
1 1
Circuit Diagram:
Procedure:
1. The connections are made as shown in Circuit(by referring IC PIN diagram)
2. The input terminals are connected to the toggle switches & the output is connected to
the Output Connector (LED’s).
3. The power is applied between the VCC & Ground terminals.
4. The Logic levels are applied at the Input for all combinations indicated in Truth Table
& the Output is observed on LED’s.
Experiment – 5
Master- Slave JK, T and D Flip-Flop
Aim: Construction and verification of JK Master-Slave, T type & D type Flip-Flops using
logic gates.
JK Flip-Flop: One way of overcoming the problem with oscillation that occurs with a JK
Flip-Flop when J= K = 1 is to use a so-called master-slave flip- flop which is illustrated in the
circuit diagram.
The master-slave flip-flop is essentially two back-to-back JKFFs, note however, that
feedback from this device is fed back both to the master FF and the slave FF.
Any input to the master-slave flip-flop at J and K is first seen by the master FF part of the
circuit while CLK is High (= 1). This behaviour effectively "locks" the input into the master
FF. An important feature here is that the complement of the CLK pulse is fed to the slave FF.
Therefore the outputs from the master FF are only "seen" by the slave FF when CLK is Low
(=0). Therefore on the High-to-Low CLK transition the outputs of the master are fed through
the slave FF. This means that at most one change of state can occur when J=K = 1 and so
oscillation between the states Q=O and Q= 1 during the same CLK pulse does not occur.
Master-Slave JK Flip-flop
The master-slave flip-flop eliminates all the timing problems by using two SR flip-flops
connected together in a series configuration. One flip-flop acts as the “Master” circuit, which
triggers on the leading edge of the clock pulse while the other acts as the “Slave” circuit,
which triggers on the falling edge of the clock pulse. This results in the two sections, the
master section and the slave section being enabled during opposite half-cycles of the clock
signal.
The TTL 74HC76 is a Dual JK flip-flop IC, which contains two individual JK type bistable’s
within a single chip enabling single or master-slave toggle flip-flops to be made. Other JK
flip flop IC’s include the 74LS107 Dual JK flip-flop with clear, the 74LS109 Dual positive-
edge triggered JK flip flop and the 74LS112 Dual negative-edge triggered flip-flop with both
preset and clear inputs.
The Master-Slave Flip-Flop is basically two gated SR flip-flops connected together in a series
configuration with the slave having an inverted clock pulse. The outputs from Q and Q from
the “Slave” flip-flop are fed back to the inputs of the “Master” with the outputs of the
“Master” flip flop being connected to the two inputs of the “Slave” flip flop. This feedback
configuration from the slave’s output to the master’s input gives the characteristic toggle of
the JK flip flop.
The input signals J and K are connected to the gated “master” SR flip flop which “locks” the
input condition while the clock (Clk) input is “HIGH” at logic level “1”. As the clock input of
the “slave” flip flop is the inverse (complement) of the “master” clock input, the “slave” SR
flip flop does not toggle. The outputs from the “master” flip flop are only “seen” by the gated
“slave” flip flop when the clock input goes “LOW” to logic level “0”.
When the clock is “LOW”, the outputs from the “master” flip flop are latched and any
additional changes to its inputs are ignored. The gated “slave” flip flop now responds to the
state of its inputs passed over by the “master” section.
Then on the “Low-to-High” transition of the clock pulse the inputs of the “master” flip flop
are fed through to the gated inputs of the “slave” flip flop and on the “High-to-Low”
transition the same inputs are reflected on the output of the “slave” making this type of flip
flop edge or pulse-triggered.
Then, the circuit accepts input data when the clock signal is “HIGH”, and passes the data to
the output on the falling-edge of the clock signal. In other words, the Master-Slave JK Flip
flop is a “Synchronous” device as it only passes data with the timing of the clock signal.
Components &equipments required: IC 7400, & 7410. Digital IC Trainer Kit, 4mm. Patch
cards etc.
Circuit Diagram:
Truth Table:
Inputs Outputs
CL Comments
J K Qn n
K
0 0 X X X 1 1 Indeterminate State
0 1 X X X 1 0 FF Preset(Set)
1 0 X X X 0 1 FF Cleared(Reset)
1 1 0 1 0 1 Reset
1 1 1 0 1 0 Set
Circuit Diagram:
Truth Table:
Inputs Outputs
Comments
T CLK Qn n
0 0 X X 1 1 Indeterminate State
0 1 X X 1 0 FF Preset(Set)
1 0 X X 0 1 FF Cleared(Reset)
1 1 0 X Q n-1 n-1 Previous
1 1 1 n-1 Q n-1 Toggle
Circuit Diagram:
Truth Table:
Inputs Outputs
Comments
D CLK Qn n
0 0 X X 1 1 Indeterminate State
0 1 X X 1 0 FF Preset(Set)
1 0 X X 0 1 FF Cleared(Reset)
1 1 0 0 1 Data transferred
1 1 1 1 0 Data transferred
Circuit Diagram:
Procedure:
1. The connections are made as shown in Circuit(by referring IC PIN diagram)
2. The input terminals (JK, T & D) are connected to the toggle switches & the output is
connected to the Output Connector (LED’s).
3. The power is applied between the VCC & Ground terminals.
4. Connect clock pin to the bounce less pulsar HIGH or LOW
5. The Logic levels are applied at the Inputs as indicated in Truth Table & the Output is
observed on LED’s.
6. X in the truth table indicates Don’t Care condition.
Experiment -6
3 Bit ripple up/down Counters
Aim: Construction and realization of 3 bit ripple up/down counter using IC 7476 and other
logic gates.
Counters: The synchronous design of any sequential circuit application for example counter
is a design in which all the flip-flops are connected to a common clock input that is, all the
flip-flops are clocked simultaneously. Therefore to get the next state of application actual
inputs of the flip-flop should be designed according to the requirement.
Hence excitation tables are used to design the actual inputs of the flip-flops to get the next
stage. The excitation table gives the combination of input for the required output condition
before and after the application of clock.
Ripple Counter
A ripple counter is an asynchronous counter where only the first flip-flop is clocked by an
external clock. All subsequent flip-flops are clocked by the output of the preceding flip-flop.
Asynchronous counters are also called ripple-counters because of the way the clock pulse
ripples it way through the flip-flops.
The MOD of the ripple counter or asynchronous counter is 2n if n flip-flops are used. For a 4-
bit counter, the range of the count is 0000 to 1111 (24-1). A counter may count up or count
down or count up and down depending on the input control. The count sequence usually
repeats itself. When counting up, the count sequence goes from 0000, 0001, 0010, ... 1110 ,
1111 , 0000, 0001, ... etc. When counting down the count sequence goes in the opposite
manner: 1111, 1110, ... 0010, 0001, 0000, 1111, 1110, ... etc.
The complement of the count sequence counts in reverse direction. If the uncomplemented
output counts up, the complemented output counts down. If the uncomplemented output
counts down, the complemented output counts up.
There are many ways to implement the ripple counter depending on the characteristics of the
flip flops used and the requirements of the count sequence.
Asynchronous counters are slower than synchronous counters because of the delay in the
transmission of the pulses from flip-flop to flip-flop. With a synchronous circuit, all the bits
in the count change synchronously with the assertion of the clock. Examples of synchronous
counters are the Ring and Johnson counter.
It can be implemented using D-type flip-flops or JK-type flip-flops.
The circuit below uses 2 D flip-flops to implement a divide-by-4 ripple counter (2n = 22 = 4).
It counts down.
Components &equipments required: IC 7476, 7400, 7404, 7408 & 7410. Digital IC Trainer
Kit, 4mm. Patch cards etc.
Circuit Diagram:
Note:
J & K inputs of Flip-Flops are connected to logic 1 or Keep it open to operate under
toggle mode.
When Preset = 1, Clear = 0; Counter is cleared Q0 = Q1 = Q2 = 0
When Preset = 0, Clear = 1; Counter is preset Q0 = Q1 = Q2 = 1
Keep Preset = 1, Clear = 1 for count mode.
Truth Table:
No. of Flip-Flop
Clock Outputs
Pulses Q2 Q1 Q0
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
8 0 0 0
Circuit Diagram:
Truth Table:
No. of Flip-Flop
Clock Outputs
Pulses Q2 Q1 Q0
0 1 1 1
1 1 1 0
2 1 0 1
3 1 0 0
4 0 1 1
5 0 1 0
6 0 0 1
7 0 0 0
8 1 1 1
Circuit Diagram:
Truth Table:
No. of Flip-Flop
Clock Outputs
Pulses Q2 Q1 Q0
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 0 0 0
Circuit Diagram:
Note:
When Mode control is at logic 1 counter works as an Up-counter.
When Mode control is at logic 0 counter works as a Down-counter.
Design and verification of mod-n, 3bit synchronous counter using 7476 JK, T & D flip flops.
Experiment -7
Design and verification of 3 Bit Synchronous Counters
Components &equipments required: IC 7476, 7400, 7404, & 7408. Digital IC Trainer Kit,
4mm. Patch cards etc.
Excitation Tables:
Q (n) Q (n+1) J K
0 0 0 X
0 1 1 X
1 0 X 1
1 1 X 0
PS NS Flip-Flop Inputs
Q2 Q1 Q0 Q2 Q1 Q0 J2 K2 J1 K1 J0 K0
0 0 0 0 0 0 1 0 X 0 X 1 X
1 0 0 1 0 1 0 0 X 1 X X 1
2 0 1 0 0 1 1 0 X X 0 1 X
3 0 1 1 1 0 0 1 X X 1 X 1
4 1 0 0 1 0 1 X 0 0 X 1 X
5 1 0 1 1 1 0 X 0 1 X X 1
6 1 1 0 1 1 1 X 0 X 0 1 X
7 1 1 1 0 0 0 X 1 X 1 X 1
Circuit Diagram:
Truth Table:
No. of Flip-Flop
Clock Outputs
Pulses Q2 Q1 Q0
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
8 0 0 0
K-Maps:
Circuit Diagram:
Note:
Carryout the design similarly
Assignment:
Design of T flip-flop 3 Bit Synchronous Counters
Design of D flip-flop 3 Bit Synchronous Counters
Procedure:
The connections are made as shown in Circuit(by referring IC PIN diagram)
The input terminals are connected to the toggle switches & the output is connected to
the Output Connector (LED’s).
The power is applied between the VCC & Ground terminals.
Connect clock pin to the bounce less pulsar LOW.
The clock input is applied as indicated in Truth Table & the Output is observed on
LED’s.
X in the truth table indicates irrelevant care condition.
Assignment:
Design and verification of random sequence counter, 3bit synchronous counter using
7476 JK, T & D flip flops.
Challenge experiments:
1. Design a digital circuit to turn on and turn off the bulb with respect to ambient light
availability.
2. Design a digital circuit to generate 10 clock pulses upon receiving the control signal.
6. Design and verification of mod-n, 3bit synchronous counter using 7476 T & D FF.
Language Overview
What is VHDL?
VHDL stands for VHSIC (Very High Speed Integrated Circuit) Hardware
Description Language. VHDL is a programming language that has been designed and
optimized for describing the behaviour of digital systems.
VHDL has many features appropriate for describing the behaviour of electronic
components ranging from simple logic gates to complete microprocessors and custom
chips. Features of VHDL allow electrical aspects of circuit behaviour (such as rise and
fall times of signals, delays through gates, and functional operation) to be precisely
described. The resulting VHDL simulation models can then be used as building blocks in
larger circuits (using schematics, block diagrams or system-level VHDL descriptions) for
the purpose of simulation.
A standard language
One of the most compelling reasons for you to become experienced with and
knowledgeable in VHDL is its adoption as a standard in the electronic design Community. Using
a standard language such as VHDL virtually guarantees that you will not have to throw away and
recapture design concepts simply because the design entry method you have chosen is not
supported in a newer generation of design tools. Using a standard language also means that you
are more likely to be able to take advantage of the most up-to-date design tools and that you will
have access to a knowledge base of thousands of other engineers, many of whom are solving
problems similar to your own.
simulation and synthesis product sold today. An enhanced and updated version of the language,
IEEE 1076-1993, was released in 1994, and VHDL tool vendors have been responding by
adding these new language features to their products.
Although IEEE Standard 1076 defines the complete VHDL language, there are aspects
of the language that make it difficult to write completely portable design descriptions
(descriptions that can be simulated identically using different vendors’ tools). The problem
stems from the fact that VHDL supports many abstract data types, but it does not address the
simple problem of characterizing different signal strengths or commonly used simulation
conditions such as unknowns and high-impedance.
Soon after IEEE 1076-1987 was adopted, simulator companies began enhancing VHDL
with new, non-standard types to allow their customers to accurately simulate complex electronic
circuits. This caused problems because design descriptions entered into one simulator were often
incompatible with other simulation environments. VHDL was quickly becoming a non-standard.
To get around the problem of non-standard data types, another standard was developed
by an IEEE committee. This standard, numbered 1164, defines a standard package (a VHDL
feature that allows commonly used declarations to be collected into an external library)
containing definitions for a standard nine-valued data type. This standard data type is called
std_logic, and the IEEE 1164 package is often referred to as the Standard Logic package.
The IEEE 1076-1987 and IEEE 1164 standards together form the complete VHDL
standard in widest use today. (IEEE 1076-1993 is slowly working its way into the VHDL
mainstream, but it does not add significant new features for synthesis users.)
Standard 1076.3 (often called the Numeric Standard or Synthesis Standard) defines standard
packages and interpretations for VHDL data types as they relate to actual hardware. This
standard, which was released at the end of 1995, is intended to replace the many custom (non-
standard) packages that vendors of synthesis tools have created and distributed with their
products.
IEEE Standard 1076.3 does for synthesis users what IEEE 1164 did for simulation
users: increase the power of Standard 1076, while at the same time ensuring compatibility
between different vendors’ tools. The 1076.3 standard includes, among other things:
The IEEE 1076.4 standard, published by the IEEE in late 1995, adds this capability to
VHDL as a standard package. A primary impetus behind this standard effort (which was dubbed
VITAL, for VHDL Initiative toward ASIC Libraries) was to make it easier for ASIC vendors and
others to generate timing models applicable to both VHDL and Verilog HDL. For this reason, the
underlying data formats of IEEE 1076.4 and Verilog’s SDF are quite similar.
The answer is yes, but probably not the first time you use it, and only if you apply
VHDL in a structured manner. VHDL (like a structured software design language) is most
beneficial when you use a structured, top-down approach to design. Real increases in
productivity will come later, when you have climbed higher on the VHDL learning curve and
have accumulated a library of reusable VHDL components.
Productivity increases will also occur when you begin to use VHDL to enhance
communication between team members and when you take advantage of the more powerful tools
for simulation and design verification that are available. In addition, VHDL allows you to design
at a more abstract level. Instead of focusing on a gate-level implementation, you can address the
behavioural function of the design.
How will VHDL increase your productivity? By making it easy to build and use libraries
of commonly-used VHDL modules. VHDL makes design reuse feel natural. As you discover the
benefits of reusable code, you will soon find yourself thinking of ways to write your VHDL
statements in ways that make them general purpose. Writing portable code will become an
automatic reflex.
Another important reason to use VHDL is the rapid pace of development in electronic
design automation (EDA) tools and in target technologies. Using a standard language such as
VHDL can greatly improve your chances of moving into more advanced tools (for example, from
a basic low-cost simulator to a more advanced one) without having to re-enter your circuit
descriptions. Your ability to retarget circuits to new types of device targets (for example, ASICs,
FPGAs, and complex PLDs) will also be improved by using a standard design entry method.
VHDL can describe a digital system at several different levels- Behavioral, Data-flow and
Structural.
A. Behavioral description: A digital circuit can be described at the behavioral level in terms of its
function or behavior, without giving any implementation details.
B. Data-flow description: A digital circuit can be described at the data-flow level by giving the logic
equation of that circuit.
C. Structural description: A digital circuit can be described at the structural level by specifying the
interconnection of the gates or flip-flops that comprise the circuit.
The basic design units used in VHDL are entity and architecture.
Entity:
Entity is the basic design unit used in VHDL.
It describes the external boundary of the hardware.
General syntax of the entity is
entity entity-name is
port (list of ports: mode type;
list of ports: mode type);
end [ entity ][entity-name];
Elsif statement:
Which is alternative way of writing nested IF statements.
This concurrent statement is executed whenever an event occurs on a signal used in one of
the expressions or conditions.If condition1 is true, signal_name is set equal to the value of the
expression1, else if condition2 is true, signal_name is set equal to the value of expression2, etc.,
Case statement:
The case statement has the general form
case expression is
when choice1 => sequential statements1
when choice2 => sequential statements2
…
[ when others => sequential statements ]
end case;
The expression is evaluated first. If it is equal to “choice1”, then “sequential
statements1” are executed. If it is equal to “choice2”, then “sequential statements2” are executed,
etc.
Note:
All the possible values of the expression must be included in the choices. If all the values are
not explicitly given, a “when others” clause is required in the case statement.
Variable:
Variable is a VHDL object and must be declared with in the process in which they are used and
are local to that process.
The variable declaration has the form
variable list_of_variable_names : type_name [ := initial value ];
Signal:
Signal is a VHDL object and it is declared in the declaration part of the architecture.
The signal declaration has the form
signal list_of_signal_names : type_name [ := initial value ];
Array:
The array type and array object declarations have the general forms
type array_type_name is array index_range of element_type;
signal array_name: array_type_name [ := initial_values ];
element_type: Which specifies integer or bit or bit_vector etc.
PROCEDURE:
The Procedure to be followed for Software and Hardware Programs are as follows:
Step 1: Go to Start Menu All Programs Xilinx ISE 9.1i and Select Project
Navigator.
Step 2: Go to File Menu and Close any previously opened project if any, and then Select New
Project.
Step 3: Enter the Project name and location and Select the Top level module type as HDL.
Step 4: Select the Device family and Device name as Spartan3 and xc3s400, pin density tq144,-
4 for FPGA.
Step 5: Right click on the source file and select new source speed followed by VHDL module
and Give the file name same as the name of the entity.
Step 6: Define the ports used and their respective directions in the next window that opens.
Step 7: Write the architecture body and the generics etc. in the incomplete VHDL code
that opens and save the file after completion of editing.
Step 8: Go to the Process view window and right click on the Synthesize - XST and Select
Run. Correct the errors if any.
Step 9: Select and Right click the source file and click on the New Source tab and then
select the Test Bench Waveform and give the appropriate file name for the same.
Step 10: Make the alterations in the Clock information and initial length of the test
bench if needed.
Step 11: Set or Reset the inputs as required and save the test bench waveform file.
Step 12: Go to Process view and under Xilinx ISE Simulator Right click on the Simulate
Behavioral model to see the output for the input conditions.
Step 13: Make the appropriate connections between the PC and the FPGA kit for the
observation of outputs in the FPGA kit and for other Hardware Programming.
Step 14: Select and Right click the source file and click on the New Source tab and then
select the Implementation Constraints file and give the appropriate file name for the
same.
Step 15: Go to Process view and under User Constraints, double click on the Edit
Constraints (Text).
Step 16: Write the code for the user constraints file as required and save the same.
Step 17: Select the main source file and right click on the Implement design in the process
view window and select run.
Step 18: Right click on the Generate Programming file in the process view window and
select run.
Step 19: Under the Generate Programming file tab, right click on the Configure device (Impact)
and click on the Run option.
Step 20: Select the appropriate mode and make changes in the jumper settings of the FPGA Kit
as required, select the appropriate .BIT extension file in the pop up window.
Step 21: Right click on the Chip picture in the pop up window and Select “Program”. Debug the
errors if it is there. Set the conditions for the inputs using Dip switch and observe the
outputs.
Pattern Generator:
Step 22: Click on the bit pattern generator icon on the desktop.
Step 24: Browse the UCF file and assign in and out pins.
Step 26: Enable Clock and continuous mode as suitable to the program.
Logic Gates
(2) OR Gate:
Truth Table: Logic Diagram:
A B C
0 0 0
0 1 1
1 0 1
1 1 1
VHDL Code :
library ieee;
use ieee.std_logic_1164.all;
entity orgate1 is
port ( a,b: in std_logic;
y: out std_logic);
end orgate1;
library ieee;
use ieee.std_logic_1164.all;
entity gate is
port ( ain,bin: in std_logic;
op_not: out std_logic;
op_or,op_nor: out std_logic;
op_xor,op_xnor: out std_logic;
op_and,op_nand: out std_logic);
end gate;
TRUTHTABLE:
WAVEFORMS:
RESULT:
Experiment No. 1a
DECODER
VHDL Code:
library ieee;
use ieee.std_logic_1164.all;
entity dec is
port (enable:in std_logic;
d_in:in std_logic_vector(1 downto 0);
d_out:out std_logic_vector(3 downto 0));
end dec;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity decoder2_4 is
Port ( i : in std_logic_vector(1 downto 0);
en : in std_logic;
y : out std_logic_vector(3 downto 0));
end decoder2_4;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity decoder2_4 is
Port(i0,i1,en : in std_logic;
y0,y1,y2,y3: out std_logic);
end decoder2_4;
component andgate
port(c,d,e:in std_logic;
f:out std_logic);
end component;
signal s1,s2:std_logic;
begin
entity andgate is
port(c,d,e:in std_logic;
f:out std_logic);
end andgate;
WAVEFORM:
RESULT:
Experiment No. 1b
ENCODER
BLOCK DIAGRAM:
VHDL Code:
library ieee;
use ieee.std_logic_1164.all;
entity enc1 is
port(enable:in
std_logic;
d_in: in std_logic_vector(7 downto 0);
d_out: out std_logic_vector(2 downto
0));
end enc1;
AIM: Write VHDL code for an 8 to 3 ENCODER with priority and without
priority.
TRUTH TABLE:
1. With priority
INPUT (I) OUTPUT (Y)
1XXXXXXX 111
01XXXXXX 110
001XXXXX 101
0001XXXX 100
00001XXX 011
000001XX 010
0000001X 001
00000001 000
2. without priority
INPUT (I) OUTPUT (Y)
00000001 000
00000010 001
00000100 010
00001000 011
00010000 100
00100000 101
01000000 110
10000000 111
entity prencoder8_3 is
Port ( i : in std_logic_vector(7 downto 0);
y : out std_logic_vector(2 downto 0));
end prencoder8_3;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity encoder8_3 is
Port ( i : in std_logic_vector(7 downto 0);
y : out std_logic_vector(2 downto 0));
end encoder8_3;
WAVEFORM:
RESULT:
VHDL Code:
library ieee;
use ieee.std_logic_1164.all;
entity mux1 is
port (sel:in std_logic_vector(2 downto 0);
a,b,c,d,e,f,g,h:in std_logic;
mux_out:out std_logic);
end mux1;
architecture mux2 of
mux1 is
begin
process(sel,a,b,c,d,e,f,g,
h)
begin
case sel is
when "000"=>mux_out<=a;
when "001"=>mux_out<=b;
when "010"=>mux_out<=c;
when "011"=>mux_out<=d;
when "100"=>mux_out<=e;
when "101"=>mux_out<=f;
when "110"=>mux_out<=g;
when "111"=>mux_out<=h;
when others=>null;
end case;
end process; end mux2;
WAVEFORM:
RESULT:
Experiment No. 1d
DE-MULTIPLEXER
entity demux4_1 is
Port ( i : in std_logic;
s : in std_logic_vector(1 downto 0);
y : out std_logic_vector(3 downto 0));
end demux4_1;
begin
process(s,i)
begin
y<="0000";
case s is
when "00"=>y(0)<=i;
when "01"=>y(1)<=i;
when "10"=>y(2)<=i;
when "11"=>y(3)<=i;
when others=>null;
end case;
end process;
end behavioural;
WAVEFORM:
RESULT:
Experiment No. 1e
Comparator
VHDL Code:
Library ieee ;
Use ieee.std_logic_1164.all;
entity comp1 is
port ( a,b: in std_logic;
g,e,l: out std_logic);
end comp1;
Logic diagram:
Block Diagram:
Truth Table:
INPUTS
A B G E L
OUTPUTS
(A>B) (A=B) (A<B)
00 00 0 1 0
00 01 0 0 1
00 10 0 0 1
00 11 0 0 1
01 00 1 0 0
01 01 0 1 0
01 10 0 0 1
01 11 0 0 1
10 00 1 0 0
10 01 1 0 0
10 10 0 1 0
10 11 0 0 1
11 00 1 0 0
11 01 1 0 0
11 10 1 0 0
11 11 0 1 0
Experiment No. 2
ADDERS
A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
TRUTH TABLE:
entity full_adder is
Port ( a,b,cin: in std_logic;
Sum,cout: out std_logic);
end full_adder;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity full_adder1 is
Port ( a,b,cin : in std_logic;
sum,cout : out std_logic);
end full_adder1;
Block Diagram:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity FullAdder is
Port ( Ain : in std_logic; --Input One
Bin : in std_logic; --Input Two
Cin : in std_logic; --Carry Input
Cout : out std_logic; --Carry Output
Sum : out std_logic); --Sum Output
end FullAdder;
Component orgate
Port ( Ain : in std_logic;
Bin : in std_logic;
y : out std_logic);
end Component;
entity Halfadder is
Port ( Ain, Bin : in std_logic; --2Bit Input
Sum, Carry : out std_logic); --sum& carry
end Halfadder;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity orgate is
Port ( Ain, Bin : in std_logic;
y : out std_logic);
end orgate;
WAVEFORM:
RESULT:
Experiment No. 3
AIM: To write VHDL code for a 4 bit binary, BCD counters with synchronous and
asynchronous reset (using clock division).
VHDL code for 4-bit BCD COUNTER with synchronous Reset(using clock
division)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity sbcdcounter is
Port ( sclk,reset: in std_logic;
count : inout std_logic_vector(3 downto 0):= "0000");
end sbcdcounter;
process(clk)
begin
if(rising_edge(clk)) then
if(reset='1')then count<="0000";
else
count<=count+1;
end if;
if(count="1001") then count<="0000";
end if;
end if;
end process;
end Behavioural;
VHDL code for 4-bit BCD COUNTER with asynchronous Reset(Using clock
division)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity asbcdcounter is
Port ( sclk,reset: in std_logic;
q : out std_logic_vector(3 downto 0):= "0000");
end asbcdcounter;
begin
process(sclk)
begin
if(rising_edge(sclk))then clkdiv<=clkdiv+1;
end if;
end process;
clk <=clkdiv(21);
process(clk,reset)
begin
if(reset='1')then count<="0000";
elsif(rising_edge(clk)) then
if(count="1001") then count<="0000";
else
count<=count+1;
end if;
end if;
end process;
q<=count;
end Behavioural;
VHDL code for 4-bit Binary synchronous COUNTER with Reset(using clock
division)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity sbincounter is
Port ( sclk,reset: in std_logic;
q : out std_logic_vector(3 downto 0) :="0000");
end sbincounter;
process(clk)
begin
if(rising_edge(clk)) then
if(reset='1')then count<="0000";
else
count<=count+1;
end if;
end if;
end process;
q<=count;
end Behavioural;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity asbincounter is
Port ( sclk,reset: in std_logic;
q : out std_logic_vector(3 downto 0) :="0000");
end asbincounter;
architecture Behavioural of asbincounter is
signal count:std_logic_vector(3 downto 0):="0000";
signal clkdiv:std_logic_vector(21 downto 0):="0000000000000000000000";
signal clk:std_logic;
begin
process(sclk)
begin
if(rising_edge(sclk))then clkdiv<=clkdiv+1;
end if;
end process;
clk <=clkdiv(21);
process(clk,reset)
begin
if(reset='1')then count<="0000";
elsif(rising_edge(clk)) then
count<=count+1;
end if;
end process;
q<=count;
end Behavioural;
INTERFACING EXPERIMENT
Experiment No. 4
STEPPER MOTOR
BLOCK DIAGRAM:
PROCEDURE:
1. Make the connection between FRC9 of the FPGA board to the Stepper motor
connector of the VTU card2.
2. Make the connection between FRC1 of the FPGA board to the Dip switch
connector of the VTU card2.
3. Connect the stepper motor to the VTU card2.
4. Connect the downloading cable and power supply to the FPGA board.
5. Then open the Xilinx iMPACT software (refer ISE flow) select the slave serial
mode and select the respective BIT file and click program.
6. Make the reset switch on.
7. Using Dip switches verify the speed changes.
VHDL CODE:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity STEPPERnew is
Port ( dout : out std_logic_vector(3 downto 0);
clk,reset : in std_logic;
row:in std_logic_vector(1 downto 0);
dir:in std_logic);
end STEPPERnew;
RESULT:
Experiment No. 5
DC motor
BLOCK DIAGRAM:
INTERFACING DIAGRAM:
PROCEDURE:
1. Make the connection between FRC9 of the FPGA board to the DC motor
connector of the VTU card2.
2. Make the connection between FRC7 of the FPGA board to the Keys connector
of the VTU card2.
3. Make the connection between FRC1 of the FPGA board to the Dip switch
connector of the VTU card2.
4. Connect the downloading cable and power supply to the FPGA board.
5. Then open the Xilinx iMPACT software (refer ISE flow) select the slave serial
mode and select the respective BIT file and click program.
VHDL CODE:
Library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
Library UNISIM;
use UNISIM.vcomponents.all;
entity dcmotor is
generic(bits : integer := 8 ); -- number of bits used for duty cycle.
-- Also determines pwm period.
port ( CLK: in STD_LOGIC; -- 4 MHz clock
RESET,DIR: in STD_LOGIC; -- dircntr
pwm : out std_logic_VECTOR(1 DOWNTO 0);
rly: out std_logic;
ROW: in STD_LOGIC_VECTOR(0 to 3) ); -- this are the row lines
end dcmotor;
end if;
end process;
DDCLK<=DIV_REG(12);
---------------------------- END OF CLOCK DIVIDER -------------------------------------------
-----
tick <= row(0) and row(1) and row(2) and row(3);
process(tick)
begin
if falling_edge(tick) then
case row is
when "1110" => duty_cycle <= 255 ; --motor speed 1
when "1101" => duty_cycle <= 200 ; --motor speed 2
when "1011" => duty_cycle <= 150 ; --motor speed 3
when "0111" => duty_cycle <= 100 ; --motor speed 4
when others => duty_cycle <= 100;
end case;
end if;
end process;
process(DDCLK, reset)
begin
if reset = '0' then
counter <= (others => '0');
pwm<="01";
elsif (DDCLK'event and DDCLK = '1') then
counter <= counter + 1;
if counter >= duty_cycle then
pwm(1) <= '0';
else
pwm(1) <= '1';
end if; end if;
end process;
rly<=DIR; --motor direction control
end dcmotor1;
FRC
FRC 5 FRC 8 FRC 9
10
FRC XF400 FRC XF400 FRC XF400 FRC XF400
1 1 1 93 1 60 1 5
2 12 2 95 2 56 2 4
3 13 3 97 3 41 3 2
4 14 4 98 4 40 4 141
5 15 5 99 5 36 9 Vcc
6 17 6 104 6 35 10 Gnd
7 18 7 125 7 32
8 21 8 122 8 10 CLK PIN
XF
9 23 9 129 9 11 52
400
10 24 10 132 10 8
11 26 11 135 11 7
12 27 12 140 12 6
13 5V 13 5V 13 5V
14 -5 14 _5 14 _5
15 Vcc 15 Vcc 15 Vcc
16 Gnd 16 Gnd 16 Gnd
Q. What is an I.C ?
Integrated circuit. A miniaturized electronic circuit that combines a variety of
components like transistors, resistors, capacitors, and diodes all into one
incredibly small piece.
Q. What is FPGA ?
Short for Field-Programmable Gate Array, a type of logic chip that can be
programmed. An FPGA is similar to a PLD, but whereas PLDs are generally
limited to hundreds of gates, FPGAs support thousands of gates. They are
especially popular for prototyping integrated circuit designs. Once the design is
set, hardwired chips are produced for faster performance.
FPGAs offer many design advantages, including:
Rapid prototyping
Shorter time to market
The ability to re-program in the field for debugging
Lower NRE costs
Long product life cycle to mitigate obsolescence risk
Q. xc3s400tq144-4 what xc stands for? what 3S stands for? what 400 stands
for? what tq144 stands for? what -4 stands for? What is the clock frequency of
xc3s400tq144-4 hardware ?
xc Xilinx component
3S Spartan 3
400 400K gate density { Logic gates are available in
this chip}
TQ144 Thin Quad 144 pin I.C.
-4 Speed for standard performance
Clock frequency 4.096MHz
Q. What is the IC number for DAC used in your FPGA-testing unit and it
is of how many bit?
The IC number for DAC used in FPGA-testing unit is IC-0808 and it is of 8bit.
Q. What is CPLD ?
(Complex PLD) A programmable logic device that is made up of several simple
PLDs (SPLDs) with a programmable switching matrix in between the logic
blocks. CPLDs typically use EEPROM, flash memory or SRAM to hold the
logic design interconnections.
Applications of Encoder:
1. Media:
Software for encoding audio, video, text into standardized formats:
A compressor encodes data (e.g., audio/video/images) into a smaller
form (see codec)
An audio encoder converts analog audio to digital audio signals
A video encoder converts analog video to digital video signals
An email encoder secures online email addresses from email harvesters
A PHTML encoder preserves script code logic in a secure format that is
transparent to visitors on a web site
2. Job positions:
A Data Entry Encoder may enter data from phone surveys in a coded
format into a database.
A Data Entry Encoder may enter payment amounts from legal tender
documents from financial institutions into a database.
3. Security:
A device or person that encodes or encrypts military messages, such as
the ADFGVX cipher in WWI or the Enigma device in WWII.
A Microchip hopping encoder integrated circuit for non-fixed-code
secured entry.
4. Medical encoding software:
Encoder Pro searches ICD-9-CM, CPT, and HCPCS Level II medical
codes, to increase accuracy and allow ease of auditing for compliance.
5. Transducers:
Transducers (such as optical or magnetic encoders) sense position or
Orientation for
use as a reference or active feedback to control position:
A rotary encoder converts rotary position to an analog (e.g., analog
quadrature) or digital (e.g., digital quadrature, 32-bit parallel, or USB)
electronic signal.
A linear encoder similarly converts linear position to an electronic
signal.
Applications of Decoder:
Audio decoder, converts analog audio to digital form
Binary decoder, digital circuits such as 1-of-N and seven-segment
decoders
Decompressor (compression decoder), converts compressed data (e.g.,
audio/video/images) to an uncompressed form
Instruction decoder, an electronic circuit that converts computer
instructions into CPU control signals
Video decoder, converts base-band analog video to digital form
Applications of Multiplexer:
Multiplexer are used in various fields where multiple data need to be
transmitted using a single line. Following are some of the applications of
multiplexers –
Communication system – Communication system is a set of system that
enable communication like transmission system, relay and tributary
station, and communication network. The efficiency of communication
system can be increased considerably using multiplexer. Multiplexer
allow the process of transmitting different type of data such as audio,
video at the same time using a single transmission line.
Telephone network – In telephone network, multiple audio signals are
integrated on a single line for transmission with the help of multiplexers.
In this way, multiple audio signals can be isolated and eventually, the
desire audio signals reach the intended recipients.
Computer memory – Multiplexers are used to implement huge amount
of memory into the computer, at the same time reduces the number of
copper lines required to connect the memory to other parts of the
computer circuit.
Transmission from the computer system of a satellite – Multiplexer
can be used for the transmission of data signals from the computer
system of a satellite or spacecraft to the ground system using the GPS
(Global Positioning System) satellites.
Applications of Comparator:
These are used in the address decoding circuitry in computers and
microprocessor based devices to select a specific input/output device for
the storage of data.
Applications of counter:
Digital clocks
Frequency counter
Binary Counter etc.
Q. What is a clock?
A clock is a signal that represents the time that a wave stays at a High or Low
state. The rising and falling edges of a clock square wave trigger the activity of
the circuits.
Q. What is a port?
A logical connector that associates signals across hierarchical boundaries. Port
location refers to a package pin on the IC.
Q. What is a vector?
The logical state of a set of nodes within a circuit as a function of time.
Q. In VHDL code if you are using (3 downto 0) what does “downto” refers
to ?
“downto” refers to little endian systems
Q. In VHDL code if you are using (0 to 3) what does “to” refers to?
“to” refers to Big endian systems
The Map process maps the logic defined by an NGD file into FPGA elements,
such as CLBs and IOBs. The output design is a Native Circuit Description
(NCD) file that physically represents the design mapped to the components in
the Xilinx FPGA.
Q. What is a bit?
A bit is a binary digit representing 0 or 1.
Q. What is a buffer?
A buffer is an element used to increase the current or drive of a weak signal
and, consequently, increase the fanout of the signal. It is a storage
element.
Q. What is a BUS?
A group of two or more signals that, carry closely-associated signals in an
electronic design.
Q. What is ASIC?
An Application-Specific Integrated Circuit (ASIC) is either a full-custom
circuit in which every mask is defined by the user or a semi-custom circuit (gate
array) where only a few masks are defined.
Q. Which software you are using for simulation? List any other software’s
used for simulation?
Xilinx ISE Simulator. The other software used is modelsim simulator.
Q. Explain DAC?
Digital-to-Analog converter (DAC) is a device that converts a digital (usually
binary) code to an analog signal (current, voltage, or electric charge). An analog-to-digital
converter (ADC) performs the reverse operation. Signals are easily stored and
transmitted in digital form, but a DAC is needed for the signal to be recognized
by human senses or other non-digital systems.
Q. Explain PWM?
Pulse Width Modulation, abbreviated as PWM, is a method of transmitting
information on
a series of pulses. The data that is being transmitted is encoded on the width of
these
pulses to control the amount of power being sent to a load. In other words, pulse
width modulation is a modulation technique for generating variable width pulses
to represent the amplitude of an input analog signal or wave. The popular
applications of pulse width modulation are in power delivery, voltage regulation
and amplification and audio effects.
Thus, a 60% duty cycle means the signal is on 60% of the time but off 40% of
the time.
FPGAs are great for more CPLDs are better for simpler
03
complex applications ones.
Q. What is a program?
A program is a sequence of instructions, written to perform a specified task with
a computer.
Q. What is software?
A software is a set of program which is the non-tangible component of computers.
Computer software contrasts with computer hardware, which is the physical
component of
computers.
Q. What is hardware?
Hardware, in the computer world, refers to the physical components that make
up a computer system. Some basic computer hardware includes the
motherboard, CPU, RAM,
Hard drive, etc.
Q. What is an instruction?
An instruction is an order given to a computer processor by a computer
program.
Hardware Software
Collection of instructions that enables a
user to interact with the computer.
Software is a program that enables a
Definition Devices that are required to store
computer to perform a specific task, as
and execute (or run) the software. opposed to the physical components of
the system (hardware).
Types Input, storage, processing, control, System software, Programming
and output devices. software, and Application software.
CD-ROM, monitor, printer, video Quick books, Adobe Acrobat, Winoms-
card, scanners, label makers, Cs, Internet Explorer , Microsoft Word
Examples
routers , and modems. , Microsoft Excel
Hardware serve as the delivery system
for software solutions. The hardware of To perform the specific task you need
a computer is infrequently changed, in to complete. Software is generally not
comparison with software and data, needed to for the hardware to perform
Function which are “soft” in the sense that they its basic level tasks such as turning on
are readily created, modified, or erased and responding to input.
on the computer.
Inter
Hardware starts functioning once To deliver its set of instructions,
dependen
software is loaded. Software is installed on hardware.
cy
Hardware failure is random. Software failure is systematic.
Hardware does have increasing Software does not have an increasing
Failure
failure at the last stage. failure rate.
Nature Hardware is physical in nature. Software is logical in nature.
first 128 combinations (0 to 127) represent positive numbers and next 128
combinations
(128 to 255) represent negative numbers.
The positive numbers are counted in a clockwise direction from 0 and the
negative numbers are counted in a counter-clockwise direction.
VHDL PART
VHDL LAB Simulated Waveforms
Logic gates:
Decoder:
Encoder:
8 to 1 Multiplexer.
1 to 4 Demultiplexer
Sec / Batch : …………….. Date :………………….. Sec / Batch : …………….. Date :…………………..
Name USN Name USN
Sec / Batch : …………….. Date :………………….. Sec / Batch : …………….. Date :…………………..
Name USN Name USN
Sec / Batch : …………….. Date :………………….. Sec / Batch : …………….. Date :…………………..
Name USN Name USN
Sec / Batch : …………….. Date :………………….. Sec / Batch : …………….. Date :…………………..
Name USN Name USN
Sec / Batch : …………….. Date :………………….. Sec / Batch : …………….. Date :…………………..
Name USN Name USN
Sec / Batch : …………….. Date :………………….. Sec / Batch : …………….. Date :…………………..
Name USN Name USN