Professional Documents
Culture Documents
INTRODUCTION TO VHDL
What is VHDL?
VHDL is the VHSIC Hardware Description Language. VHSIC is an abbreviation for Very
High Speed Integrated Circuit. It can describe the behavior and structure of electronic
systems, but is particularly suited as a language to describe the structure and behavior
of digital electronic hardware designs, such as ASICs and FPGAs as well as
conventional digital circuits.
VHDL is a notation, and is precisely and completely defined by the Language Reference
Manual (LRM). This sets VHDL apart from other hardware description languages, which
are to some extent defined in an ad hoc way by the behavior of tools that use them.
VHDL is an international standard, regulated by the IEEE. The definition of the language
is non-proprietary.
Simulation and synthesis are the two main kinds of tools which operate on the VHDL
language. The Language Reference Manual does not define a simulator, but
unambiguously defines what each simulator must do with each part of the language.
VHDL does not constrain the user to one style of description. VHDL allows designs to be
described using any methodology - top down, bottom up or middle out! VHDL can be
used to describe hardware at the gate level or in a more abstract way. Successful high
level design requires a language, a tool set and a suitable methodology. VHDL is the
language, you choose the tools, and the methodology... well, I guess that's where
Doulos come in to the equation!
ECADLAB(VHDL) 1
ELCTRONICS AND COMMUNICATION ENGINEERING
The development of VHDL was initiated in 1981 by the United States Department of
Defense to address the hardware life cycle crisis. The cost of reprocuring electronic
hardware as technologies became obsolete was reaching crisis point, because the
function of the parts was not adequately documented, and the various components
making up a system were individually verified using a wide range of different and
incompatible simulation languages and tools. The requirement was for a language with a
wide range of descriptive capability that would work the same on any simulator and was
independent of technology or design methodology.
Standardization
The standardization process for VHDL was unique in that the participation and feedback
from industry was sought at an early stage. A baseline language (version 7.2) was
published 2 years before the standard so that tool development could begin in earnest in
advance of the standard. All rights to the language definition were given away by the
DoD to the IEEE in order to encourage industry acceptance and investment.
ASIC Mandate
DoD Mil Std 454 mandates the supply of a comprehensive VHDL description with every
ASIC delivered to the DoD. The best way to provide the required level of description is to
use VHDL throughout the design process.
ECADLAB(VHDL) 2
ELCTRONICS AND COMMUNICATION ENGINEERING
VHDL '93
As an IEEE standard, VHDL must undergo a review process every 5 years (or sooner) to
ensure its ongoing relevance to the industry. The first such revision was completed in
September 1993, and tools conforming to VHDL '93 are now available.
1987 - Mil Std 454 requires comprehensive VHDL descriptions to be delivered with
ASICs
ECADLAB(VHDL) 3
ELCTRONICS AND COMMUNICATION ENGINEERING
Levels of Abstraction
Algorithm
ECADLAB(VHDL) 4
ELCTRONICS AND COMMUNICATION ENGINEERING
RTL
An RTL description has an explicit clock. All operations are scheduled to occur in
specific clock cycles, but there are no detailed delays below the cycle level.
Commercially available synthesis tools do allow some freedom in this respect. A single
global clock is not required but may be preferred. In addition, retiming is a feature that
allows operations to be re-scheduled across clock cycles, though not to the degree
permitted in behavioral synthesis tools.
Gates
A gate level description consists of a network of gates and registers instanced from a
technology library, which contains technology-specific delay information for each gate.
In the diagram above, the RTL level of abstraction is highlighted. This is the ideal level of
abstraction at which to design hardware given the state of the art of today's synthesis
tools. The gate level is too low a level for describing hardware - remember we're trying to
move away from the implementation concerns of hardware design, we want to abstract
to the specification level - what the hardware does, not how it does it. Conversely, the
algorithmic level is too high a level, most commercially available synthesis tools cannot
produce hardware from a description at this level.
In the future, as synthesis technology progresses, we will one day view the RTL level of
abstraction as the “dirty” way of writing VHDL for hardware and writing algorithmic (often
called behavioral) VHDL will be the norm.
ECADLAB(VHDL) 5
ELCTRONICS AND COMMUNICATION ENGINEERING
Scope of VHDL
VHDL is suited to the specification, design and description of digital electronic hardware.
System level
VHDL is not ideally suited for abstract system-level simulation, prior to the hardware-
software split. Simulation at this level is usually stochastic, and is concerned with
modeling performance, throughput, queuing and statistical distributions. VHDL has been
used in this area with some success, but is best suited to functional and not stochastic
simulation.
Digital
VHDL is suitable for use today in the digital hardware design process, from specification
through high-level functional simulation, manual design and logic synthesis down to
gate-level simulation. VHDL tools usually provide an integrated design environment in
this area.
VHDL is not suited for specialized implementation-level design verification tools such as
analog simulation, switch level simulation and worst case timing simulation. VHDL can
be used to simulate gate level fan-out loading effects providing coding styles are
adhered to and delay calculation tools are available. The standardization effort named
VITAL (VHDL Initiative toward ASIC Libraries) is active in this area, and is now bearing
fruit in that simulation vendors have built-in VITAL support. More importantly, many ASIC
vendors have VITAL-compliant libraries, though not all are allowing VITAL-based sign-
off - not yet anyway.
Analogue
In 1999, the IEEE approved Standard 1076.1, which is informally known as VHDL-AMS.
It is a true super-set of VHDL, and includes analog and mixed-signal extensions.
ECADLAB(VHDL) 6
ELCTRONICS AND COMMUNICATION ENGINEERING
Design process
The diagram below shows a very simplified view of the electronic system design process
incorporating VHDL. The central portion of the diagram shows the parts of the design
process which are most impacted by VHDL.
The diagram below summarizes the high level design flow for an ASIC (ie. gate array,
standard cell) or FPGA. In a practical design situation, each step described in the
following sections may be split into several smaller steps, and parts of the design flow
will be iterated as errors are uncovered.
System-level Verification
As a first step, VHDL may be used to model and simulate aspects of the complete
system containing one or more devices. This may be a fully functional description of the
system allowing the FPGA/ASIC specification to be validated prior to commencing
detailed design. Alternatively, this may be a partial description that abstracts certain
properties of the system, such as a performance model to detect system performance
bottle-necks.
ECADLAB(VHDL) 7
ELCTRONICS AND COMMUNICATION ENGINEERING
Once the overall system architecture and partitioning is stable, the detailed design of
each FPGA/ASIC can commence. This starts by capturing the design in VHDL at the
register transfer level, and capturing a set of test cases in VHDL. These two tasks are
complementary, and are sometimes performed by different design teams in isolation to
ensure that the specification is correctly interpreted. The RTL VHDL should be
synthesizable if automatic logic synthesis is to be used. Test case generation is a major
task that requires a disciplined approach and much engineering ingenuity: the quality of
the final FPGA/ASIC depends on the coverage of these test cases.
RTL verification
The RTL VHDL is then simulated to validate the functionality against the specification.
RTL simulation is usually one or two orders of magnitude faster than gate level
simulation, and experience has shown that this speed-up is best exploited by doing more
simulation, not spending less time on simulation. In practice it is common to spend 70-
80% of the design cycle writing and simulating VHDL at and above the register transfer
level, and 20-30% of the time synthesizing and verifying the gates.
Look-ahead Synthesis
Although some exploratory synthesis will be done early on in the design process, to
provide accurate speed and area data to aid in the evaluation of architectural decisions
and to check the engineer's understanding of how the VHDL will be synthesized, the
main synthesis production run is deferred until functional simulation is complete. It is
pointless to invest a lot of time and effort in synthesis until the functionality of the design
is validated.
ECADLAB(VHDL) 8
ELCTRONICS AND COMMUNICATION ENGINEERING
Executable specification
It is often reported that a large number of ASIC designs meet their specifications first
time, but fail to work when plugged into a system. VHDL allows this issue to be
addressed in two ways: A VHDL specification can be executed in order to achieve a high
level of confidence in its correctness before commencing design, and may simulate one
to two orders of magnitude faster than a gate level description. A VHDL specification for
a part can form the basis for a simulation model to verify the operation of the part in the
wider system context (eg. printed circuit board simulation). This depends on how
accurately the specification handles aspects such as timing and initialization. Behavioral
simulation can reduce design time by allowing design problems to be detected early on,
avoiding the need to rework designs at gate level. Behavioral simulation also permits
design optimization by exploring alternative architectures, resulting in better designs.
ECADLAB(VHDL) 9
ELCTRONICS AND COMMUNICATION ENGINEERING
To see the list of available toolbars, select Tools > Customize > Toolbars.
Once a toolbar is opened, it can be moved using the mouse. To see the
command associated with an icon, position the mouse over the icon and a
tooltip will appear that displays the command name.It is possible to modify
the appearance of the display in Figure 2 in many ways.
ECADLAB(VHDL) 10
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 11
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 12
ELCTRONICS AND COMMUNICATION ENGINEERING
Choose addersubtractor as the name for both the project and the top-level
entity, as shown in Figure 4. Press Next. Since we have not yet created the
directory quartus_tutorial, the Quartus® II software displays the pop-up box
in Figure 5 asking if it should create the desired directory. Click Yes, which
leads to the window in Figure 6.
ECADLAB(VHDL) 13
ELCTRONICS AND COMMUNICATION ENGINEERING
3. This window makes it easy to specify which existing files (if any) should
be included in the project. Assuming that we do not have any existing files,
click Next, which leads to the window in Figure 7.
ECADLAB(VHDL) 14
ELCTRONICS AND COMMUNICATION ENGINEERING
5. In this window we can specify any third-party tools that should be used. A
commonly used term for CAD software for electronic circuits is EDA tools,
where the acronym stands for Electronic Design Automation.
This term is used in the Quartus® II messages that refer to third-party tools,
which are the tools developed and marketed by companies other than
Altera®; Since we will rely solely on the Quartus® II tools, we will not
choose any other tools. Press Next. Now, a summary of the chosen settings
appears in the screen shown in Figure 9. Press Finish, which returns to the
main Quartus® II display. Note that addersubtractor is now specified as the
current project, as indicated in the title bar at the top of the display. The
screen should look similar to that of Figure 10.
ECADLAB(VHDL) 15
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 16
ELCTRONICS AND COMMUNICATION ENGINEERING
2. The first step is to specify a name for the file that will be created. Select
File > Save As to open the pop-up box shown in Figure 14. In the field
labeled Save as type choose VHDL File. In the field labeled File name type
addersubtractor. Put a checkmark in the box Add file to current project.
Click Save, which puts the file into the directory quartus_tutorial and leads
to the Text Editor window shown in Figure 15. Type the name in the box
under Type the workspace name: and press ok
ECADLAB(VHDL) 17
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 18
ELCTRONICS AND COMMUNICATION ENGINEERING
3. Enter the VHDL code into the Text Editor Window, which is located on
the right side of the screen. Save the file by going to File > Save, or by
typing the shortcut Ctrl-s.
ECADLAB(VHDL) 19
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 20
ELCTRONICS AND COMMUNICATION ENGINEERING
the left side of its window. Figure 20 shows the Compiler Flow Summary
section, which indicates that only a miniscule amount of chip resources are
needed to implement this tiny circuit on the selected FPGA chip.
Simulation:
1. Add simulator file by clicking File>New>vector
Waveform File then click OK. As shown in fig.21
2. Right click on area as show in fig go to insert node or
bus. As show in fig 22.
3. On the pop-up window click on node finder press in the
need finder window click on list click on the signals
required for simulation. Fig 23.
4. From the Node found window move the signals into
selected node window by pressing > and to select all
signals press >>. As show in fig 24.
5. Save and give name to wave form file as
addersubtractor.vwf.
ECADLAB(VHDL) 21
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 22
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 23
ELCTRONICS AND COMMUNICATION ENGINEERING
Fig .25 wave form window with all signals required for simulation
ECADLAB(VHDL) 24
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 25
ELCTRONICS AND COMMUNICATION ENGINEERING
AIM: To simulate internal structure of all gates using VHDL and verify their operation.
APPARATUS:
S.NO COMPONENT QUANTITY
1. IC 7400 1
2. IC 7402 1
3. IC 7404 1
4. IC 7408 1
5. IC 7436 1
6. IC 7486 1
7. IC CD74HC7266 1
8. Digital Trainer Board 1
THEORY:
Logic gates: Digital systems are said to be constructed by using logic gates. These
gates are the AND, OR, NOT, NAND, NOR, EXOR and EXNOR gates. The basic
operations are described below with the aid of truth tables.
AND gate
The AND gate is an electronic circuit that gives a high output (1) only if all
its inputs are high. A dot (.) is used to show the AND operation i.e. A.B
for a two input (A & B) AND gate, Y = A.B. Bear in mind that this dot is
sometimes omitted i.e. written as AB
OR gate
ECADLAB(VHDL) 26
ELCTRONICS AND COMMUNICATION ENGINEERING
The OR gate is an electronic circuit that gives a high output (1) if one or
more of its inputs are high. A plus (+) is used to show the OR operation.
E.g. output of a 2-input OR gate is Y=A+B.
NOT gate
The NOT gate is an electronic circuit that produces an inverted version of the
input at its output. It is also known as an inverter. If the input variable is A, the
inverted output is known as NOT A. This is also shown as A', or A with a bar
over the top, as shown at the output, i.e., Y= A'
NAND gate
NOR gate
ECADLAB(VHDL) 27
ELCTRONICS AND COMMUNICATION ENGINEERING
The 'Exclusive-OR' gate is a circuit which will give a high output if either,
but not both, of its two inputs are high. An encircled plus sign ( ) is used
to show the EOR operation.When inputs are A and B,output Y of EXOR
gate is Y=A B
EXNOR gate
The 'Exclusive-NOR' gate circuit does the opposite to the EOR gate. It
will give a low output if either, but not both, of its two inputs are high.
The symbol is an EXOR gate with a small circle on the output. The small
circle represents inversion.The output Y of a EXNOR gate with inputs
A&B is given by Y=( A B)′ .
The NAND and NOR gates are called universal gates since with either one the
AND and OR functions and NOT can be generated.
ECADLAB(VHDL) 28
ELCTRONICS AND COMMUNICATION ENGINEERING
Table 1 is a summary truth table of the input/output combinations for the NOT gate
together with all possible input/output combinations for the other gate functions. Also
note that a truth tables with 'n' inputs has 2n rows. You can compare the outputs of
different gates.
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
ECADLAB(VHDL) 29
ELCTRONICS AND COMMUNICATION ENGINEERING
entity gates is
port ( a: in STD_LOGIC;
b: in STD_LOGIC;
and1: out STD_LOGIC;
or1: out STD_LOGIC;
nor1: out STD_LOGIC;
nand1: out STD_LOGIC;
xor1: out STD_LOGIC;
xnor1: out STD_LOGIC);
end gates;
architecture gates of gates is
begin
and1 <= a and b;
or1 <= a or b;
nor1 <= a nor b;
nand1 <= a nand b;
xor1 <= a xor b;
xnor1 <= a xnor b;
end gates;
DE2 PIN ASSIGNMENTS :
SIGNAL NAME PIN NAME TYPE
A SW[0] PIN_N25 Toggle Switch[0]
B SW[1] PIN_N26 Toggle Switch[1]
AND1 LEDR[0] PIN_AE23 LED Red[0]
OR1 LEDR[1] PIN_AF23 LED Red[1]
NOR1 LEDR[2] PIN_AB21 LED Red[2]
NAND1 LEDR[3] PIN_AC22 LED Red[3]
XOR1 LEDR[4] PIN_AD22 LED Red[4]
XNOR1 LEDR[5] PIN_AD23 LED Red[5]
ECADLAB(VHDL) 30
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUT
INPUTS OUTPUT
A B Y
A B Y
0V 0V 0V 0V 0V 0V
0V 5V 0V 0V 5V 5V
5V 0V 0V 5V 0V 5V
5V 5V 5V 5V 5V 5V
ECADLAB(VHDL) 31
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUT
INPUTS OUTPUT
A B Y
A B Y
0V 0V 5V
0V 0V 0V
0V 5V 0V
0V 5V 5V
5V 0V 0V
5V 0V 5V
5V 5V 5V
5V 5V 0V
AND GATE : when all inputs are high output should be high.
OR GATE : when any of input is high output should be high.
NAND GATE : when any of input is low output should be high.
NOR GATE : when any of input is high output should be low.
EX-OR GATE: when input combination contains odd number of
Ones then only output should be high.
EX-NOR GATE: when input combination contains even number of
ones then only output should be high.
ECADLAB(VHDL) 32
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (SOFTWARE):
INPUTS OUTPUT
INPUTS OUTPUT
A B LED
A B LED
0 0 OFF 0 0 OFF
0 1 OFF 0 1 ON
1 0 OFF 1 0 ON
1 1 ON 1 1 ON
ECADLAB(VHDL) 33
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUT
INPUTS OUTPUT
A B LED
A B LED
0 0 ON
0 0 ON
0 1 OFF
0 1 ON
1 0 OFF
1 0 ON
1 1 OFF
1 1 OFF
INPUTS OUTPUT
INPUTS OUTPUT
A B LED
A B LED 0 0 ON
0 0 OFF
0 1 OFF
0 1 ON
1 0 OFF
1 0 ON
1 1 ON
1 1 OFF
RESULT:
ALL GATES Internal Structures are Simulated and Verified Using Quartus-IISoftware
and in Hardware Lab Respectively.
ECADLAB(VHDL) 34
ELCTRONICS AND COMMUNICATION ENGINEERING
INFERENCE:
Theoretical and Practical Results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t Forget to instantiate IEEE Libraries At the starting of
the code
3) Follow Syntax and Semantics of the VHDL code throughout
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data
Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
Ans:
ECADLAB(VHDL) 35
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (SOFTWARE):
PROCEDURE (HARDWARE):
ECADLAB(VHDL) 36
ELCTRONICS AND COMMUNICATION ENGINEERING
AIM: To Simulate internal structure of D FLIP FLOP(IC 7474) using VHDL and verify
Its operation.
APPARATUS:
ECADLAB(VHDL) 37
ELCTRONICS AND COMMUNICATION ENGINEERING
inputs. 74LS74 is a dual positive edge triggered D-type FF. It’s features are individual
data Clock Set and reset inputs and Complementary Q and Q΄outputs .The clock input is
level-sensitive. The positive transition of clock pulse between 0.8V and 2.0V should be
equal.
PIN DIAGRAM:
TRUTH TABLE:
INPUTS OUTP
UTS
PR CL CL D Q Q*
R K
L H X X H L
H L X X L H
L L X X H H
H H H H L
H H L L H
H H L X Q0 Q0
*
H = HIGH Logic Level X = Either LOW or HIGH Logic Level Clear
L = LOW Logic Level ↑ = Positive-going transition of the clock.
ECADLAB(VHDL) 38
ELCTRONICS AND COMMUNICATION ENGINEERING
Q0 = The output logic level of Q before the indicated input conditions were and
established.
INTERNAL DIAGRAM:
D = Qt+1
ECADLAB(VHDL) 39
ELCTRONICS AND COMMUNICATION ENGINEERING
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity dff is
port (
d: in STD_LOGIC;
clk: in STD_LOGIC;
clr: in STD_LOGIC;
pr: in STD_LOGIC;
q: out STD_LOGIC;
qbar: out STD_LOGIC);
end dff;
architecture dff of dff is
signal clr1,pr1:std_logic;
begin
clr1<=not clr;
pr1<=not pr;
process(clk,clr1,pr1)
begin
if(pr1='1'and clr1='1')then q<='1';qbar<='1';
elsif(pr1='1'and clr1='0')then q<='1';qbar<='0';
elsif(pr1='0'and clr1='1')then q<='0';qbar<='1';
elsif(clk'event and clk='1')then q<=d;qbar<=not d;
end if;
end process;
end dff;
ECADLAB(VHDL) 40
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUTS
PR CLR CLK D Q Q*
0 1 X X 5V 0V
1 0 X X 0V 5V
0 0 X X 5V 5V
1 1 1 5V 0V
1 1 0 0V 5V
1 1 0 X Q0 Q0*
ECADLAB(VHDL) 41
ELCTRONICS AND COMMUNICATION ENGINEERING
Q0 = The output logic level of Q before the indicated input conditions were and
established.
When
pr =
0, clr
= 0
ECADLAB(VHDL) 42
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUTS
PR CLR CLK D Q LED Q* LED
0 1 X X ON OFF
1 0 X X OFF ON
0 0 X X ON ON
1 1 1 ON OFF
1 1 0 OFF ON
1 1 0 X Q0 Q0*
RESULT:
ECADLAB(VHDL) 43
ELCTRONICS AND COMMUNICATION ENGINEERING
INFERENCE:
Theoretical and Practical Results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t Forget to instantiate IEEE Libraries at the starting of
the code
3) Follow Syntax and Semantics of the VHDL code throughout
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data
Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4)Take the outputs at appropriate pins.
ECADLAB(VHDL) 44
ELCTRONICS AND COMMUNICATION ENGINEERING
In master-slave FF if the master respond for positive edge then slave responds for
negative
edge.
4. What is a Flip-Flop?
Ans: Flip-Flop is a one bit storage device. It is having two outputs one for normal value
and one for the complement value of the bit stored in it.
5. Explain the operation of D Flip-Flop?
Ans: The binary information present at the data input of the D Flip-Flop is transferred to
Q output when clock pulse input is enabled.
6. What is the advantage of D Flip-Flop when compared with RS Flip-Flop?
Ans: The undesirable condition of indeterminate state in RS Flip-Flop is eliminated in
D Flip-Flop
7. Why D Flip-Flop sometimes called as gated D latch?
Ans: The D Flip-Flop receives the designation from its ability to hold data into its internal
storage such a type of Flip-Flop sometimes called as gated D latch.
PROCEDURE (SOFTWARE):
PROCEDURE (HARDWARE):
ECADLAB(VHDL) 45
ELCTRONICS AND COMMUNICATION ENGINEERING
APPARATUS: HARDWARE:
S.NO COMPONENT QUANTITY
1. IC 7490 1
2. Digital Trainer Board 1
SOFTWARE: Quartus-II
THEORY:
7490 is a 4-bit ripple type decade counter.
Features are:
Output QA is connected to input B for BCD count. Output QD is connected
to input A for qi-binary count. This counter has a gated ‘O’ reset. This
counter contains 4 master-slave FF’s and additional gating to provide a
divide by two counter.
TRUTH TABLE:
COUNT OUTPUT
QD QC QB QA
0 L L L L
1 L L L H
2 L L H L
3 L L H H
4 L H L L
5 L H L H
6 L H H L
7 L H H H
8 H L L L
9 H L L H
H = HIGH; L = LOW
INTERNAL DIAGRAM:
ECADLAB(VHDL) 46
ELCTRONICS AND COMMUNICATION ENGINEERING
VHDL CODE:
ECADLAB(VHDL) 47
ELCTRONICS AND COMMUNICATION ENGINEERING
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
entity dcounter is
port (
clk: in STD_LOGIC;
ro: in STD_LOGIC_VECTOR (2 downto 1):="00";
rg: in STD_LOGIC_VECTOR (2 downto 1):="00";
q:out unsigned(3 downto 0):="0000"
);
end dcounter;
architecture dcounter of dcounter is
begin
process(clk,rg,ro)
variable vq : unsigned(3 downto 0);
begin
if(ro(1)='1'and ro(2)='1'and rg(1)='0')then vq:="0000";
end if;
ECADLAB(VHDL) 48
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 49
ELCTRONICS AND COMMUNICATION ENGINEERING
COUNT OUTPUT
QD QC QB QA
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
L X L X COUNT
L X X L COUNT
X L L X COUNT
RESULTS (SOFTWARE):
ECADLAB(VHDL) 50
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (HARDWARE):
COUNT OUTPUT
QD LED QC LED QB LED QA LED
0 OFF OFF OFF OFF
1 OFF OFF OFF ON
2 OFF OFF ON OFF
3 OFF OFF ON ON
4 OFF ON OFF OFF
ECADLAB(VHDL) 51
ELCTRONICS AND COMMUNICATION ENGINEERING
5 OFF ON OFF ON
6 OFF ON ON OFF
7 OFF ON ON ON
8 ON OFF OFF OFF
9 ON OFF OFF ON
RESULT:
INFERENCE:
Theoretical and Practical Results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of
the code.
3) Follow Syntax and Semantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
ECADLAB(VHDL) 52
ELCTRONICS AND COMMUNICATION ENGINEERING
Ans: A decade counter is also known as mod-10 counter or BCD counter. It is used
In frequency counter, digital voltmeter, digital voltmeter, wrist watches etc.
6. Applications of counter?
Ans: Digital system use counter in a variety of applications, such as digital clocks,
special sequence generators, time-delay circuits, pulse counters, control
state counters, program counters etc.
PROCEDURE (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of the code.
PROCEDURE (HARDWARE):
ECADLAB(VHDL) 53
ELCTRONICS AND COMMUNICATION ENGINEERING
AIM: To Simulate Internal structure of Four Bit Counter (IC 7493) using VHDL and
Verify its operation.
APPARATUS:
ECADLAB(VHDL) 54
ELCTRONICS AND COMMUNICATION ENGINEERING
THEORY:
PIN DIAGRAM:
ECADLAB(VHDL) 55
ELCTRONICS AND COMMUNICATION ENGINEERING
TRUTH TABLE:
COUNT OUTPUT
QO Q1 Q2 Q3
0 0 0 0 0
1 1 0 0 0
2 0 1 0 0
3 1 1 0 0
4 0 0 1 0
5 1 0 1 0
6 0 1 1 0
7 1 1 1 0
8 0 0 0 1
9 1 0 0 1
10 0 1 0 1
11 1 1 0 1
12 0 0 1 1
13 1 0 1 1
14 0 1 1 1
15 1 1 1 1
INTERNAL DIAGRAM:
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
entity counter4 is
ECADLAB(VHDL) 56
ELCTRONICS AND COMMUNICATION ENGINEERING
port (
clk: in STD_LOGIC;
r: in STD_LOGIC_VECTOR (1 downto 0);
q: out unsigned(3 downto 0):="0000" );
end counter4;
Architecture counter4 of counter4 is
begin
process (clk)
variable vq : unsigned(3 downto 0);
begin
if(r(0)='1'and r(1)='1')then vq:="0000";
elsif (clk'event and clk='1') then vq:=vq+1;
end if;
q<=vq;
end process;
end counter4;
PIN ASSIGNMENTS :
ECADLAB(VHDL) 57
ELCTRONICS AND COMMUNICATION ENGINEERING
COUNT OUTPUT
QO Q1 Q2 Q3
0 0V 0V 0V 0V
1 5V 0V 0V 0V
2 0V 5V 0V 0V
3 5V 5V 0V 0V
4 0V 0V 5V 0V
5 5V 0V 5V 0V
6 0V 5V 5V 0V
7 5V 5V 5V 0V
8 0V 0V 0V 5V
9 5V 0V 0V 5V
10 0V 5V 0V 5V
11 5V 5V 0V 5V
12 0V 0V 5V 5V
13 5V 0V 5V 5V
14 0V 5V 5V 5V
15 5V 5V 5V 5V
ECADLAB(VHDL) 58
ELCTRONICS AND COMMUNICATION ENGINEERING
else if any one of the input is high count will be increased by one.
COUNT OUTPUT
QOLED Q1LED Q2LED Q3LED
0 OFF OFF OFF OFF
1 ON OFF OFF OFF
2 OFF ON OFF OFF
3 ON ON OFF OFF
4 OFF OFF ON OFF
5 ON OFF ON OFF
6 OFF ON ON OFF
7 ON ON ON OFF
8 OFF OFF OFF ON
9 ON OFF OFF ON
10 OFF ON OFF ON
11 ON ON OFF ON
12 OFF OFF ON ON
13 ON OFF ON ON
14 OFF ON ON ON
15 ON ON ON ON
ECADLAB(VHDL) 59
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULT:
Four Bit Counter internal structure is Simulated and verified using Quartus-IISoftware
and in Hardware Lab Respectively.
INFERENCE:
Theoretical and Practical results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries At the starting of
the code.
3) Follow Syntax and Semantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data
Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
ECADLAB(VHDL) 60
ELCTRONICS AND COMMUNICATION ENGINEERING
Ans: In asynchronous counter flip flops are connected in such a way that output of first
flip flop drives the clock for next flip flop.
In synchronous counter there is no connection between output of first flip flop and clock
input of next flip flop.
2. Which type of counter is preferred when there are more number of flip flops and why
such a type of counter is preferred?
Ans: synchronous counter is preferred because clock is simultaneously given to all flip
flops there is no problem of propagation delay
3. If a four-bit synchronous counter is designed with 4 flip flops and two AND gates then
determine f max if t pd (propagation delay time ) for each flip flop is 50ns and t pd for each
AND gate is 20ns?
Ans: For a synchronous counter total delay that must be allowed between input clock
pulses is equal to flip flop t pd + AND gate t pd .Thus Tclk 50 + 20 = 70ns and so counter
has f max = 1/ 70ns = 14.3Mhz.
4. A counter has 14 stable states 0000 through 1101 .If input frequency is 50khz what
will be its output frequency?
PROCEDURE (SOFTWARE):
ECADLAB(VHDL) 61
ELCTRONICS AND COMMUNICATION ENGINEERING
the code.
PROCEDURE (HARDWARE):
AIM: To Simulate Internal structure of Universal Shift Register (IC 74194/195) using
VHDL and Verify its operation.
APPARATUS:
S.NO COMPONENT QUANTITY
1. IC 74194/195 1
2. Digital Trainer Board 1
THEORY (HARDWARE):
The 74194 is a bidirectional shift register designed to incorporate virtually all of the
features a system designer want in a shift register. The circuit contains 46 equivalent
gates and features parallel inputs, parallel outputs, right-shift and left-shift serial inputs,
operating mode control inputs and a direct overriding clear line. The register has four
distinct modes of operation namely;
Parallel (Broadside) Load
Shift Right (In the direction of QA toward QD)
Shift Left (In the direction of QD toward QA)
Inhibit Clock (Do nothing)
ECADLAB(VHDL) 62
ELCTRONICS AND COMMUNICATION ENGINEERING
Synchronous parallel loading is accomplished by applying the four bits of data and
taking both mode control inputs, S0 and S1, high. The data is loaded into the associated
flip flop and appears at the outputs after the positive transition of the clock input. During
loading, serial data flow is inhibited.
Shift right is accomplished synchronously with the rising edge of the clock pulse when S0
is high and S1 is low. Serial data for this mode is entered at the shift-left serial input.
Clocking of the flip flop is inhibited when both mode control inputs are low. The mode
controls should be changed only while the clock input is high.
PIN DIAGRAM:
TRUTH TABLE:
INPUTS OUTPUTS
CLEAR MODE CLOCK SERIAL PARALLEL QA QB QC QD
S1 S0 LEFT RIGHT A B C D
L X X X X X X X X X L L L L
H X X L X X X X X X QA0 QB0 QC0 QD0
H H H X X a b c d a b c d
ECADLAB(VHDL) 63
ELCTRONICS AND COMMUNICATION ENGINEERING
INTERNAL DIAGRAM:
ECADLAB(VHDL) 64
ELCTRONICS AND COMMUNICATION ENGINEERING
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity pshift is
ECADLAB(VHDL) 65
ELCTRONICS AND COMMUNICATION ENGINEERING
port (
clr: in STD_LOGIC;
ro: in STD_LOGIC;
lo: in STD_LOGIC;
clk: in STD_LOGIC;
s: in STD_LOGIC_VECTOR (0 to 1);
ip: in STD_LOGIC_VECTOR (0 to 3);
q: out STD_LOGIC_VECTOR (0 to 3)
);
end pshift;
architecture pshift of pshift is
signal qin:std_logic_vector(0 to 3);
begin
process(clk,clr,ip,ro,lo,s)
variable vq:std_logic_vector(0 to 3);
begin
elsif(s="01")then vq:=ro&vq(0)&vq(1)&vq(2);
elsif(s="10")then vq(0):=vq(1);vq(1):=vq(2);vq(2):=vq(3);vq(3):=lo;
elsif(s="00")then vq:=ip;
end if;
end if;
q<=vq;
end process;
end pshift;
ECADLAB(VHDL) 66
ELCTRONICS AND COMMUNICATION ENGINEERING
0 0 0 0
1 0 0 0
1 1 0 0
0 1 1 0
1 0 1 1
0 1 0 1
0 0 1 0
0 0 0 1
0 0 0 0
RESULTS (SOFTWARE):
ECADLAB(VHDL) 67
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 68
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (HARDWARE):
ECADLAB(VHDL) 69
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUTS
CLEAR MODE CLOCK SERIAL PARALLEL QA QB QC QD
S1 S0 LEFT RIGHT A B C D
0 X X X X X X X X X 0 0 0 0
1 X X 0 X X X X X X QA0 QB0 QC0 QD0
1 1 1 X X a b c d a b c d
clock= 1 ; input e= 1; input l= 1 output q = r ; output q(0) = q(1); q(1) = q(2); and so
on up to q(n-2) = q(n-1). q(n-1) = input w;
RESULTS (HARDWARE):
INPUTS OUTPUTS
CLEAR MODE CLOCK SERIAL PARALLEL QA QB QC QD
ECADLAB(VHDL) 70
ELCTRONICS AND COMMUNICATION ENGINEERING
S1 S0 LEFT RIGHT A B C D
0 X X X X X X X X X 0 0 0 0
1 X X 0 X X X X X X QA0 QB0 QC0 QD0
1 1 1 X X a b c d a b c d
Universal Shift Register internal structure is simulated and verified using QUARTUS II
Software and in Hardware Lab Respectively.
INFERENCE:
Theoretical and Practical Results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of the code.
3) Follow Syntax and Semantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
QUESTIONS & ANSWERS:
ECADLAB(VHDL) 71
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (SOFTWARE):
PROCEDURE (HARDWARE):
ECADLAB(VHDL) 72
ELCTRONICS AND COMMUNICATION ENGINEERING
AIM: To Simulate the internal structure of a 3- to-8 decoder (IC 74138) using VHDL
and verify its operation.
ECADLAB(VHDL) 73
ELCTRONICS AND COMMUNICATION ENGINEERING
APPARATUS:
THEORY:
The “Absolute Maximum Ratings” are those values beyond which the safety of the
device cannot be guaranteed. The device should not be operated at these limits. The
parametric values defined in the Electrical Characteristics tables are not guaranteed at
the absolute maximum ratings. The “Recommended Operating Conditions” table will
define the conditions for actual device operation. An N-bit decoder has 2N outputs, only
ECADLAB(VHDL) 74
ELCTRONICS AND COMMUNICATION ENGINEERING
one of which may be activated at a given time. If the device is active-HIGH, then only
one output may be HIGH at any time. If the device is active-LOW, then only one output
may be LOW at any time.
DECODER DETAILS:
TRUTH TABLE:
INPUTS OUTPUTS
G1 G2* C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
X L X X X H H H H H H H H
H X X X X H H H H H H H H
L H L L L H L L L L L L L
L H L L H L H L L L L L L
L H L H L L L H L L L L L
L H L H H L L L H L L L L
L H H L L L L L L H L L L
L H H L H L L L L L H L L
L H H H L L L L L L L H L
L H H H H L L L L L L L H
INTERNAL DIAGRAM:
ECADLAB(VHDL) 75
ELCTRONICS AND COMMUNICATION ENGINEERING
Y1 = X2 ` X1 `X0 Y5 = X2 X1 `X0
Y2 = X2 ` X1 X0` Y6 = X2 X1X0`
Y3 = X2 ` X1X0 Y7 = X2 X1X0
VHDL CODE:
ECADLAB(VHDL) 76
ELCTRONICS AND COMMUNICATION ENGINEERING
Library IEEE;
use IEEE.Std_Logic_1164.All;
ENTITY decoder IS
ECADLAB(VHDL) 77
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 78
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUTS OUTPUTS
C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
0 0 0 5V 0V 0V 0V 0V 0V 0V 0V
0 0 1 0V 5V 0V 0V 0V 0V 0V 0V
0 1 0 0V 0V 5V 0V 0V 0V 0V 0V
0 1 1 0V 0V 0V 5V 0V 0V 0V 0V
1 0 0 0V 0V 0V 0V 5V 0V 0V 0V
1 0 1 0V 0V 0V 0V 0V 5V 0V 0V
1 1 0 0V 0V 0V 0V 0V 0V 5V 0V
1 1 1 0V 0V 0V 0V 0V 0V 0V 5V
RESULTS (SOFTWARE):
ECADLAB(VHDL) 79
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (HARDWARE):
INPUTS OUTPUTS
G1 G2* C B A Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
LED LED LED LED LED LED LED LED
X L X X X ON ON ON ON ON ON ON ON
H X X X X ON ON ON ON ON ON ON ON
L H L L L ON OFF OFF OFF OFF OFF OFF OFF
L H L L H OFF ON OFF OFF OFF OFF OFF OFF
L H L H L OFF OFF ON OFF OFF OFF OFF OFF
L H L H H OFF OFF OFF ON OFF OFF OFF OFF
L H H L L OFF OFF OFF OFF ON OFF OFF OFF
L H H L H OFF OFF OFF OFF OFF ON OFF OFF
L H H H L OFF OFF OFF OFF OFF OFF ON OFF
L H H H H OFF OFF OFF OFF OFF OFF OFF ON
INFERENCE:
ECADLAB(VHDL) 80
ELCTRONICS AND COMMUNICATION ENGINEERING
Theoretical and Practical results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of
the code.
3) Follow Syntax and Symantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
ECADLAB(VHDL) 81
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of the code.
ECADLAB(VHDL) 82
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (HARDWARE):
AIM: To Simulate internal structure of 4 Bit Comparator(IC 7485) using VHDL and
Verify its operation.
APPARATUS:
ECADLAB(VHDL) 83
ELCTRONICS AND COMMUNICATION ENGINEERING
THEORY:
This four-bit magnitude comparator performs comparison of straight binary or BCD
codes. Three fully-decoded decisions about two, 4-bit words {A, B} are made and are
externally available at three outputs. This device is fully expandable to any number of
bits without external gates. Words of greater length may be compared by connecting
comparators in cascade. The A>B, A<B, and A=B outputs of a stage handling less
significant bits are connected to the corresponding inputs of the next stage handling
more-significant bits. The stage handling the least-significant bits must
have a high level voltage applied to the A=B input.
TRUTH TABLE:
ECADLAB(VHDL) 84
ELCTRONICS AND COMMUNICATION ENGINEERING
A3=B3 A2>B2 X X X X X X X H L L
A3=B3 A2<B2 X X X X X X X L H L
A3=B3 A2=B2 A1>B1 X X X X X H L L
A3=B3 A2=B2 A1<B1 X X X X X L H L
A3=B3 A2=B2 A1=B1 AO>BO X X X H L L
INTERNAL DIAGRAM:
ECADLAB(VHDL) 85
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 86
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 87
ELCTRONICS AND COMMUNICATION ENGINEERING
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity bit4 is
ECADLAB(VHDL) 88
ELCTRONICS AND COMMUNICATION ENGINEERING
port (
a: in STD_LOGIC_vector(3 downto 0);
b: in STD_LOGIC_vector(3 downto 0);
cg: in STD_LOGIC; -- Cascading input greater
ce: in STD_LOGIC; -- Cascading input equal
cl: in STD_LOGIC; -- Cascading input less than
agb: out STD_LOGIC; --output A greater than B
aeb: out STD_LOGIC; --output A equal to B
alb: out STD_LOGIC); ----output A less than B
end bit4;
architecture bit4 of bit4 is
begin
process(a,b,cg,ce,cl)
variable cas : std_logic_vector(2 downto 0);
begin
cas:= cg&ce&cl;
if cas="010" then
if a(3)<b(3) then agb<='0'; alb<='1';aeb<='0';
elsif a(3)>b(3) then agb<='1'; alb<='0';aeb<='0';
elsif a(2)>b(2) then agb<='1'; alb<='0';aeb<='0';
elsif a(2)<b(2) then agb<='0'; alb<='1';aeb<='0';
elsif a(1)>b(1) then agb<='1';alb<='0';aeb<='0';
elsif a(1)<b(1) then agb<='0';alb<='1';aeb<='0';
elsif a(0)>b(0) then agb<='1';alb<='0';aeb<='0';
elsif a(0)<b(0) then agb<='0';alb<='1';aeb<='0';
else agb<='0'; alb<='0';aeb<='1';
end if;
else if cas="100" then agb<='1';alb<='0';aeb<='0';
else if cas="001" then agb<='0'; alb<='1';aeb<='0';
end if;
end if;
end if;
ECADLAB(VHDL) 89
ELCTRONICS AND COMMUNICATION ENGINEERING
end process;
end bit4;
ECADLAB(VHDL) 90
ELCTRONICS AND COMMUNICATION ENGINEERING
A3=B3 A2>B2 X X X X X X X 5V 0V 0V
A3=B3 A2<B2 X X X X X X X 0V 5V 0V
A3=B3 A2=B2 A1>B1 X X X X X 5V 0V 0V
A3=B3 A2=B2 A1<B1 X X X X X 0V 5V 0V
A3=B3 A2=B2 A1=B1 AO>BO X X X 5V 0V 0V
ECADLAB(VHDL) 91
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 92
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (HARDWARE):
ECADLAB(VHDL) 93
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULT:
Four bit Comparator internal structure is Simulated and verified using Quartus-
IISoftware and in Hardware Lab Respectively.
INFERENCE:
Theoretical and Practical results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of
the code.
ECADLAB(VHDL) 94
ELCTRONICS AND COMMUNICATION ENGINEERING
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data
Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
Ans:
PROCEDURE (SOFTWARE):
ECADLAB(VHDL) 95
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (HARDWARE):
1) Connect the circuit as per the pin diagram.
2) Give proper VCC voltage to the IC.
3) Supply the inputs according to truth table and verify outputs.
AIM: To Simulate internal structure of 8X1 MULTIPLEXER (IC 74151) using VHDL and
verify its operation.
APPARATUS:
THEORY:
ECADLAB(VHDL) 96
ELCTRONICS AND COMMUNICATION ENGINEERING
INTERNAL DIAGRAM:
OUTPUT EQUATIONS:
D0 = A`B`C` D1 = AB`C` D2 = A`BC` D3 = ABC` D4 = A`B`C
D5 = AB`C D6 = A`BC D7 = ABC
ECADLAB(VHDL) 97
ELCTRONICS AND COMMUNICATION ENGINEERING
VHDL CODE:
library IEEE;
use IEEE.std_logic_1164.all;
entity mux is
port ( a: in STD_LOGIC;
b: in STD_LOGIC;
c: in STD_LOGIC;
input: in STD_LOGIC_VECTOR(7 downto 0);
en: in STD_LOGIC;
output: out STD_LOGIC );
end mux;
Architecture mux of mux is
signal sel: std_logic_vector(2 downto 0);
begin
sel<=c&b&a;
process (sel,input,en)
begin
if(en='0')then output<='Z';
else
case sel is
ECADLAB(VHDL) 98
ELCTRONICS AND COMMUNICATION ENGINEERING
end if;
end process;
end mux;
ECADLAB(VHDL) 99
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUT OUTPUT
SELECT STROBE W Y
C B A S
X X X 1 1 0
0 0 0 0 A+B+C A`B`C`
0 0 1 0 A`+B+C AB`C`
0 1 0 0 A+B`+C A`BC`
0 1 1 0 A`+B`+C ABC`
1 0 0 0 A+B+C` A`B`C
1 0 1 0 A`+B+C` AB`C
1 1 0 0 A+B`+C` A`BC
1 1 1 0 A`+B`+C` ABC
ECADLAB(VHDL) 100
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (HARDWARE):
ECADLAB(VHDL) 101
ELCTRONICS AND COMMUNICATION ENGINEERING
INPUT OUTPUT
SELECT STROBE
C B A S
W Y
X X X 1 1 0
0 0 0 0 A+B+C A`B`C`
0 0 1 0 A`+B+C AB`C`
0 1 0 0 A+B`+C A`BC`
0 1 1 0 A`+B`+C ABC`
1 0 0 0 A+B+C` A`B`C
1 0 1 0 A`+B+C` AB`C
1 1 0 0 A+B`+C` A`BC
1 1 1 0 A`+B`+C` ABC
RESULT:
INFERENCE:
Theoretical and Practical results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1)Follow Getting Started Procedure for the Software you are using.
2)Don’t forget to instantiate IEEE Libraries at the starting of
the code.
3)Follow Syntax and Semantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
ECADLAB(VHDL) 102
ELCTRONICS AND COMMUNICATION ENGINEERING
1 X 0
0 0 Select input A
0 1 Select input B
Ans: The multiplexer include data selection and routing, operation sequencing, parallel
to serial conversion, wave form generation and logic function generation.
6. Applications of demultiplexers?
Ans: The demultiplexer include serial to parallel conversion, logic function generation,
operation sequencing.
ECADLAB(VHDL) 103
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are
using.
2) Don’t forget to instantiate IEEE Libraries at the starting of
the code.
PROCEDURE (HARDWARE):
1) Connect the circuit as per the pin diagram.
2) Give proper VCC voltage to the IC.
3) Supply the inputs according to truth table and verify outputs.
AIM: To Simulate internal structure of 2X4 DEMULTIPLEXER (IC 74155) using VHDL
and Verify its operation.
APPARATUS:
THEORY:
The LS155 and LS156 are Dual 1-of-4 Decoder/Demultiplexers with common Address
inputs and separate gated Enable inputs. When enabled, each decoder section accepts
the binary weighted Address inputs (A0, A1) and provides four mutually exclusive active
LOW outputs (O0–O3). If the Enable requirements of each decoder are not met, all
outputs of that decoder are HIGH.
Each decoder section has a 2-input enable gate. The enable gate for Decoder “a”
requires one active HIGH input and one active LOW input (Ea•Ea). In demultiplexing
ECADLAB(VHDL) 104
ELCTRONICS AND COMMUNICATION ENGINEERING
applications, Decoder “a” can accept either true or complemented data by using the Ea
or Ea inputs respectively. The enable gate for Decoder “b” requires two active LOW
inputs (Eb•Eb). The LS155 or LS156 can be used as a 1-of-8 Decoder/Demultiplexer by
tying Ea to Eb and relabeling the common connection
as (A2). The other Eb and Ea are connected together to form the common enable.The
LS155 and LS156 can be used to generate all four minterms of two variables. These
four minterms are useful in some applications replacing multiple gate functions.
INTERNAL DIAGRAM:
ECADLAB(VHDL) 105
ELCTRONICS AND COMMUNICATION ENGINEERING
OUTPUT EQUATIONS:
VHDL CODE:
library ieee;
use ieee.std_logic_1164.all;
entity DeMUX is
port( X: in std_logic;
sel: in std_logic_vector (1 downto 0);
A: out std_logic;
B: out std_logic;
C: out std_logic;
D: out std_logic);
end DeMUX;
ECADLAB(VHDL) 106
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 107
ELCTRONICS AND COMMUNICATION ENGINEERING
0 0 1 0 0V 5V 5V 5V 0 0 0V 5V 5V 5V
1 0 1 0 5V 0V 5V 5V 0 0 5V 0V 5V 5V
0 1 1 0 5V 5V 0V 5V 0 0 5V 5V 0V 5V
1 1 1 0 5V 5V 5V 0V 0 0 5V 5V 5V 0V
When SELECT = 00
A =1; B = '0'; C = '0'; D = '0';
When SELECT = 01
B =1; A ='0'; C ='0'; D ='0';
when SELECT =10
C <=1; A = 0; B = 0; D = 0;
When SELECT = 11
D =1; A = 0; B = 0; C = 0;
RESULTS (SOFTWARE):
ECADLAB(VHDL) 108
ELCTRONICS AND COMMUNICATION ENGINEERING
RESULTS (HARDWARE):
A0 A1 Ea Ea` O0` O1` O2` O3` Eb` Eb` O0` O1` O2` O3`
X X 0 X ON ON ON ON 1 X ON ON ON ON
X X X 1 ON ON ON ON X 1 ON ON ON ON
0 0 1 0 OFF ON ON ON 0 0 OFF ON ON ON
1 0 1 0 ON OFF ON ON 0 0 ON OFF ON ON
0 1 1 0 ON ON OFF ON 0 0 ON ON OFF ON
1 1 1 0 ON ON ON OFF 0 0 ON ON ON OFF
RESULT:
INFERENCE:
Theoretical and Practical results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
ECADLAB(VHDL) 109
ELCTRONICS AND COMMUNICATION ENGINEERING
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries At the starting of
the code.
3) Follow Syntax and Semantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1) Apply the voltages to the IC as per the details given in the data
Sheets.
2) Apply the inputs to the respective pins.
3) First decide which one is MSB and LSB.
4) Take the outputs at appropriate pins.
3. Draw the block diagram for full subtractor using 1:8 Demultiplexer
Ans:
ECADLAB(VHDL) 110
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (SOFTWARE):
1. Follow Getting Started Procedure for the Software you are
using.
2) Don’t forget to instantiate IEEE Libraries at the starting of
the code.
PROCEDURE (HARDWARE):
ECADLAB(VHDL) 111
ELCTRONICS AND COMMUNICATION ENGINEERING
AIM: To Simulate Internal structure of 16X4 RAM(IC 74189) using VHDL and
Verify its operation.
APPARATUS:
THEORY:
The CY7C189 and CY7C190 are extremely high performance 64-bit static RAM’s
organized as 16 words by 4 bits. Easy memory expansion n is provided by an active low
chip select (CS) input and three- state outputs. The devices are provided with inverting
(CY7C189) and non inverting (CY7C190) outputs. Writing to the device is accomplished
when the chip select (CS) and write enable (WE) inputs are both low. Data on the four
data inputs (D0 through D3) is written into the memory location specified on the address
pins(A0 through A3). The outputs are preconditioned such that the correct data is present
at the data outputs (O0 through O3) when the write cycle is complete. This precondition
operation insures minimum write recovery times by eliminating the “write recovery
glitch.” Reading the device is accomplished by taking chip select (CS) LOW, while write
enable(WE) remains HIGH. Under these conditions, the contents of the memory location
specified on the address pins will appear on the four output pins (O0 through O3) in
inverted (CY7C189) or non-inverted (CY7C190) format. The four output pins remain in
high-impedance state when chip select (CS) is HIGH or write enable (WE) is LOW.
ECADLAB(VHDL) 112
ELCTRONICS AND COMMUNICATION ENGINEERING
CS΄ WE΄
L L WRITE HIGH
IMPEDENCE
L H READ COMPLEMENT
OF STORED
DATA
H X INHIBIT HIGH
IMPENDENCE
INTERNAL DIAGRAM:
ECADLAB(VHDL) 113
ELCTRONICS AND COMMUNICATION ENGINEERING
Write = CS`WE`
READ = CS`WE
INHIBIT = CS WE
VHDL CODE:
ECADLAB(VHDL) 114
ELCTRONICS AND COMMUNICATION ENGINEERING
library IEEE;
use IEEE.std_logic_1164.all;
entity ram is
port (
cs: in STD_LOGIC;
we: in STD_LOGIC;
re: in STD_LOGIC;
mr: out STD_LOGIC;
mw: out STD_LOGIC
);
end ram;
architecture ram of ram is
begin
process (cs,we,re)
begin
if (cs='0'and we='1'and re='0')then
mr<='0';
mw<='1';
elsif (cs='0'and we='0'and re='1')then
mr<='1';
mw<='0';
end if;
end process;
end ram;
ECADLAB(VHDL) 115
ELCTRONICS AND COMMUNICATION ENGINEERING
CS΄ WE΄
Data is written Tristate
0v 0v Into specified
location
0v +5v Data is read COMPLEMENT OF
from specified STORED DATA
location
+5v X No write or read Tristate
X = don’t care
RESULTS (HARDWARE):
CS΄ WE΄
0v 0v Data is available Tristate
In specified
location
0v +5v Data is retrieved Complement Of
ECADLAB(VHDL) from specified stored data is 116
location available
+5v X INHIBIT Tristate
ELCTRONICS AND COMMUNICATION ENGINEERING
X = don’t care
RESULTS (SOFTWARE):
RESULT:
16X4 RAM internal structure is simulated and verified using Quartus-IISoftware and
in Hardware Lab Respectively.
ECADLAB(VHDL) 117
ELCTRONICS AND COMMUNICATION ENGINEERING
INFERENCE:
Theoretical and Practical results are according to the expected results both for Software
and Hardware.
PRECAUTIONS (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of the code.
3) Follow Syntax and Semantics of the VHDL code throughout.
PRECAUTIONS (HARDWARE):
1)Apply the voltages to the IC as per the details given in the data sheets.
2)Apply the inputs to the respective pins.
3)First decide which one is MSB and LSB.
4)Take the outputs at appropriate pins.
ECADLAB(VHDL) 118
ELCTRONICS AND COMMUNICATION ENGINEERING
Ans: Memory cell organized in the form of array, in which each cell is capable of
storing one bit information
4) Differentiate between Static and Dynamic RAM.
Ans: Static RAM: Memories that consists of circuits capable of retaining their
state as long as power is applied are known as static memories. These are Random
Access Memories, hence combinely called Static RAM.
Dynamic RAM: Memories that store data as a charge on the capacitor are
called as Dynamic RAM’s.
5) Implement 256x2 Ram using 256x1 RAM?
ECADLAB(VHDL) 119
ELCTRONICS AND COMMUNICATION ENGINEERING
Ans:
ECADLAB(VHDL) 120
ELCTRONICS AND COMMUNICATION ENGINEERING
Ans:
ECADLAB(VHDL) 121
ELCTRONICS AND COMMUNICATION ENGINEERING
PROCEDURE (SOFTWARE):
1) Follow Getting Started Procedure for the Software you are using.
2) Don’t forget to instantiate IEEE Libraries at the starting of the code.
PROCEDURE (HARDWARE):
ECADLAB(VHDL) 122
ELCTRONICS AND COMMUNICATION ENGINEERING
ECADLAB(VHDL) 123