Beruflich Dokumente
Kultur Dokumente
Table of Contents
1 OBJECTIVE...........................................................................................................................2
2 INTRODUCTION...................................................................................................................2
2.1 Digital Systems.................................................................................................................2
2.1.1 Sequential Circuit..........................................................................................................4
2.1.2 Combinational circuit....................................................................................................6
2.1.3 ADVANTAGE OF DIGITAL SYSTEM OVER ANALOG SYSTEM.........................9
2.2 VHDL...............................................................................................................................9
2.2.1 HISTORY OF VHDL..............................................................................................10
2.2.2 Uses of VHDL.........................................................................................................11
3 RESEARCH IDEA AND CONCEPT...................................................................................11
3.1 Research Idea..................................................................................................................11
3.2 SEQUENCE DETECTOR.............................................................................................12
3.3 STATE MACHINE.........................................................................................................12
3.3.1 ASM (Algorithmic State Machine)..........................................................................13
3.3.2 FSM (finite state machine)......................................................................................14
3.3.3 DIFFERENCE BETWEEN ASM AND FSM.........................................................15
3.3.4 MEALY MACHINE................................................................................................16
3.3.5 MOORE MACHINE...............................................................................................18
3.3.6 DIFFRANCE BETWEEN MEALY MACHINE AND MOORE MACHINE........19
3.3.7 USES OF SEQUENCE DETECTOR......................................................................20
4 THEORY...............................................................................................................................20
4.1 VHDL THEORY............................................................................................................20
5 STATE TRANSITION DIAGRAM......................................................................................23
5.1 STATE TABLE...............................................................................................................24
6 VHDL PROGRAM AND SIMULATION............................................................................27
7 RESULT................................................................................................................................34
8 CONCLUSION.....................................................................................................................34
9 REFRENCES........................................................................................................................35
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 2 of
1 OBJECTIVE
The objective of this assignment is to design & simulate a state machine in VHDL for
detection of Sequence, assuming the sequence to be detected is pre-decided. The predefine
sequence is to be detected as assumed 0101101010101001.
2 INTRODUCTION
2.1 Digital Systems
Most modern electronic devices such as mobile telephones and computers depend on digital
electronics. In fact, most electronics about the home and in industry depend on digital
electronics to work. Digital electronics normally based on logic circuits. These circuits
depend on pulses of electricity to make the circuit work. For instance, if current is present -
this is represented as 1. If current is not present, this is represented as 0. Digital
electronics is based on a series of 1s and 0s. A good example of a digital electronic system is
a mobile phone. As anybody speak into the phone, the digital electronic circuits it contains
converts your voice into a series of electronic pulses (or 1s and 0s). These are transmitted and
the receiving mobile phone then converts the digital pulses back into your voice. Digital
electronics are those electronics systems that use a digital signal instead of an analog signal.
Digital electronics are the most common representation of Boolean algebra and are the basis
of all digital circuits for computers, mobile phones, and numerous other consumer products.
Digital circuits are used because they are efficient and work well, also, digital signals are
easier to transmit than actual sound. The various parts of a computer communicate through
the use of electronic pulses (1s and 0s). Consequently digital logic circuits are ideal for the
internal electronics. The main part of the computer is the motherboard. This is a complex
piece of electronics that processes all the important data. For instance, when word processing,
it is very important to display letters and words on the monitor. The motherboard generates
the individual letters on the monitor by sending a series of 1s and 0s to the screen.
A digital system is one that is with two well-defined states. Systems based on digital circuits
touch all aspects our present day lives. The present day home products including electronic
games and appliances, communication and office automation products, industrial
instrumentation and control systems, electro medical equipment, and defenses and aerospace
systems are heavily dependent on digital system. This growth is powered by the emerging
new technology, which enables the introduction of more and complex integrated circuits. The
complexity of an integrated circuit is measured in terms of the number of transistors that can
be integrated into a single unit. The number of transistors in a single integrated circuit has
been doubling every eighteen months (Moore Law) for several decades and reached the
figure of almost one billion transistors per chip. This allowed the circuit designers to provide
more and more complex functions in a single unit.
Block diagram
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 5 of
Circuit diagram
1 S = R = 0 : No change
If S = R = 0 then output of NAND gates 3 and 4
are forced to become 1.Hence R' and S' both will
be equal to 1. Since S' and R' are the input of the
basic S-R latch using NAND gates, there will be
no change in the state of outputs.
2 S = 0, R = 1, E = 1
Since S = 0, output of NAND-3 i.e. R' = 1 and E =
1 the output of NAND-4 i.e. S' = 0.Hence Qn+1 = 0
and Qn+1 bar = 1. This is reset condition.
3 S = 1, R = 0, E = 1
Output of NAND-3 i.e. R' = 0 and output of
NAND-4 i.e. S' = 1.Hence output of S-R NAND
latch is Qn+1 = 1 and Qn+1 bar = 0. This is the reset
condition.
4 S = 1, R = 1, E = 1
As S = 1, R = 1 and E = 1, the output of NAND
gates 3 and 4 both are 0 i.e. S' = R' = 0.Hence
the Race condition will occur in the basic NAND
latch.
the same output regardless of the order the inputs are changed. Example of combinational
circuit are encoder, decoder, multiplexer and DE multiplexer, Adder, sub-tractor etc.
Circuit do not use any memory. The previous state of input does not have any effect
on the present state of the circuit.
Block diagram
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 8 of
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 9 of
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 10 of
Digital signals do not get corrupted by noise etc. You are sending a series of numbers
that represent the signal of interest (i.e. audio, video etc.)
Digital signals typically use less bandwidth. This is just another way to say you can
cram more information (audio, video) into the same space.
Digital can be encrypted so that only the intended receiver can decode it (like pay per
view video, secure telephone etc.)
Enables transmission of signals over a long distance.
Transmission is at a higher rate and with a wider broadband width.
It is more secure.
It is also easier to translate human audio and video signals and other messages into
machine language.
There is minimal electromagnetic interference in digital technology.
It enables multi-directional transmission simultaneously
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 11 of
The VHDL representation can be viewed as a text file that describes a digital system. The
digital system may be represented in different ways, such as a behavioral model or a
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 12 of
structural model. More commonly known as levels of abstraction, these levels help the
designer to develop complex systems efficiently.
The VHDL programming starts with some header file that include the library IEEE and etc,
after the header file the declaration of the entity is done by describing the signal which
connect the hardware to the outside that are also called as ports i.e. the input and the output
port. The entity declares the port signals, their directions and the data types, this signal are
latter used by an architecture associated with this entity.
example, it is important to identify the beginning and ending of a message. This is the job of
special bit sequences called flags. A flag is simply a pre-defined bit sequence (1101) that
serves as a marker in the bit stream. To detect a flag in a bit stream a sequence detector is
used. To detect a flag in a bit stream a sequence detector is used. It can detect the beginning
of a packet of asynchronous data, like that coming in over wireless or a serial port. A
sequence detector could also be used on a remote control, such as for a TV or garage door
opener. 1011 might correspond to a particular key being pressed.
ASM
FSM
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 14 of
'Algorithm State Machine 'or simply state machine is the another name given to sequential
network is used to control a digital system which carries out a step by a step procedure. .It
should be noted that ASM charts represent physical hardware and offers several advantages.
Figure 11 (ASM)
3.3.2 FSM (finite state machine)
A finite state machine is one that has a limited or finite number of possible states. A finite
state machine can be used both as a development tool for approaching and solving problems
and as a formal way of describing the solution for later developers and system maintainers.
There are a number of ways to show state machines. Finite state machines may sound like a
very dry and boring topic but they reveal a lot about the power of different types of
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 15 of
computing machine. Every Turing machine includes a finite state machine so there is a sense
in which they come first. They also turn out to be very useful in practice. The simplest type of
computing machine that is worth considering is called a finite state machine. The finite state
machine is also a useful approach to many problems in software architecture, only in this case
you dont build one you simulate it. When a symbol, a character from some alphabet say, is
input to the machine it changes state in such a way that the next state depends only on the
current state and the input symbol. State machines have long been a popular and effective
way of modeling the dynamic behavior of software systems at many different levels. The
previous section explicitly deals with a very low-level representation of a system, with the
understanding that the binary representation can be scaled up to more complex languages and
representations.
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 16 of
Figure 12 (FSM)
3.3.3 DIFFERENCE BETWEEN ASM AND FSM
ASM FSM
2 Diagram 2 Diagram
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 17 of
3 The detecting performance as to only text 3 The detecting performance as to only text
typing in ASM was significantly lower than in typing in FSM was significantly higher than
FSM. in ASM.
4 In the case of ASM each condition was 4 As for FSM, the subjects could change
changed automatically every 30 seconds. each condition at their own speed.
Mealy machine
Moore machine
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 18 of
q0 is the initial state from where any input is processed (q0 Q).
A Mealy machine has outputs that are a function of state and input, that is That is, z = f (qk -
1... q0, xm-1... x0). We usually indicate that the output is dependent on current state and input by
drawing the output on the edge. In the example below, look at the edge from state 00 to state
01. This edge has the value 1/1. This means, that if you are in state 00, and you see an input
of 1, then you output a 1, and transition to state 01. Thus, 1/1 is short hand for x = 1 / z = 1.
Here's a sample Mealy machine.
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 19 of
q0 is the initial state from where any input is processed (q0 Q).
Output depends both upon present Output depends only upon the present state.
state and present input.
Generally, it has fewer states than Generally, it has more states than Mealy Machine.
Moore Machine.
Output changes at the clock edges. Input change can cause change in output change as
soon as logic is done.
Mealy machines react faster to In Moore machines, more logic is needed to decode
inputs. the outputs since it has more circuit delays.
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 21 of
4 THEORY
A sequence can be defined as a string of objects, like numbers, that follow a particular
pattern. In a sequence structure, an action, or event, leads to the next ordered action in a
predetermined order. The sequence can contain any number of actions, but no actions can be
skipped in the sequence. The program, when run, must perform each action in order with no
possibility of skipping an action or branching off to another action. All logic problems in
programming can be solved by forming algorithms using only the three logic structures, and
they can be combined in an infinite number of ways. The more complex the computing need,
the more complex the combination of structures. A sequence detector accepts as input a string
of bits: either 0 or 1. Its output goes to 1 when a target sequence has been detected. There are
two basic types: overlap and non-overlap. In a sequence detector that allows overlap, the final
bits of one sequence can be the start of another sequence. Our example will be an 1101
sequence detector. It raises an output of 1 when the last 4 binary bits received are 1101. At
this point, a detector with overlap will allow the last two 1 bits to serve at the first of a next
sequence
In VHDL an entity is used to describe a hardware module. An entity can be described using
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 22 of
1 Entity declaration
The entity declaration should starts with entity and ends with end keywords. And the ports
are interfaces through which an entity can communicate with its environment. Each port must
have a name direction and a type. An entity may have no port declaration also. The direction
will be input, output. It defines the names input output signals and modes of a hardware
module.
Syntax:
entity entity_name is
port declaration;
end entity_name
2 Architecture
The architecture describes the internal description of design. Each entity has atleast one
architecture and an entity can have many architecture. Architecture defines what is in our
black box that we described using ENTITY. We can use either behavioral or structural models
to describe our system in the architecture. In Architecture we will have interconnections,
processes, components, etc
Syntax:
architecturearchitecture_name of entity_name
architecture_declaration_part;
begin
Statements;
end architecture_name;
3. Package body
The package body is used to declare the definitions and procedures that are declared in
corresponding package. Values can be assigned to constants declared in package in package
body.
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 23 of
Syntax:
function_procedure definitions;
end package_name
The internal details of entity are specified by an architecture body using following different
modeling styles:
The one of the primary reasons to use VHDL is its power as a test stimulus language. As
logic designs become more complex, comprehensive, up-front verification becomes critical to
the success of a design project. In fact, as you become proficient with simulation, it will
quickly find that your VHDL simulator becomes your primary design development tool. To
simulate project, you will need to develop an additional VHDL program called a test bench.
Test benches emulate a hardware breadboard into which you will "install" synthesizable
design description for the purpose of verification. Test benches can be quite simple, applying
a sequence of inputs to the circuit over time. They can also be quite complex, perhaps even
reading test data from a disk file and writing test results to the screen and to a report file. A
comprehensive test bench can, in fact, be more complex and lengthy (and take longer to
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 24 of
develop) than the synthesizable circuit being tested. As you will begin to appreciate while
reading this chapter, test bench development will be where you make use of the full power of
VHDL and your own skills as a VHDL "coder". Depending on your needs (and whether
timing information related to your target device technology is available), you may develop
one or more test benches to verify the design functionally (with no delays), to check your
assumptions about timing relationships (using estimates or unit delays), or to simulate with
annotated post-route timing information so you can verify that your circuit will operate in-
system at speed. During simulation, the test bench will be the top level of a design hierarchy.
To the simulator, there is no distinction between those parts of the design that are being tested
and the test bench itself.
flops should be used when things are to be remembered by the circuit. When 1 arrives when
in state S1, then it goes to next state S2 and it remembers that 1 was received which is part of
the sequence 1101 which is to be detected.
State S2
When in state S2, when 1 arrives, since it is part of the sequence it goes to next state S3,
meaning it remembers 1. When 0 is received it cannot go to next state S3 (since 1 received
has occupied the transition condition and because 0 is not part of the sequence and there is
nothing to remember), and it cannot remain in the same state S2 because this would mean
010 indefinite loop while in state S2, therefore it goes back to the initial state S1. Consider
100 is received and machine remains in S2 when 0 is received, then because of 1 the state
changes from S1 to S2, then 0 is received then the machine stays in S2 and when another 0 is
received then it stays again in S2. But consider when 100 is received and machine goes back
to S1, then when 1 is received it changes state from S1 to S2, when 0 is received then goes
back to S1 and when another 0 is received it stays in S1.
State S3
When in state S3, when 0 is received then since it is part of the sequence 1101 it goes to new
state S4 because the machine has to remember the new bit 0 as part of the sequence detection
algorithm. When 1 is received it stays in the same state.
State S4
When in state S4, when 1 is received then since it is part of the sequence 1101 to be detected
it goes to S2. And when 0 is received then it goes back to initial state S1. At this point the
machine outputs 1.
transition diagrams were around long before object modeling. They give an explicit, even a
formal definition of behavior. A big disadvantage for them is that they mean that you have to
define all the possible states of a system. Whilst this is all right for small systems, it soon
breaks down in larger systems as there is an exponential growth in the number of states. This
state explosion problem leads to state transition diagrams becoming far too complex for much
practical use. A state diagram shows the behavior of classes in response to external output.
Specifically a state diagram describes the behavior of a single object in response to a series of
events in a system. Sometimes it's also known as a state machine diagram. This diagram
models the dynamic flow of control from state to state of a particular object within a system
A B X An+1 Bn+1 Y Da Db
0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 1
0 1 0 0 0 0 0 0
0 1 1 1 0 0 1 0
1 0 0 1 1 0 1 1
1 0 1 1 0 0 1 0
1 1 0 0 0 0 0 0
1 1 1 0 1 1 0 1
BA
00 01 11 10
X
By solving the K-Map we have got the Boolean expression for output
Y = BAX
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 27 of
BA
00 01 11 10
X
(0) (1) (3) (2)
0 0 0 1 0
(4) (5) (7) (6)
1 1 1 0 0
By solving the K-Map for input of the D flip flop we get the expression for Da as
B X BA X
Da =
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 28 of
K-map for Db
BA
00 01 11 10
X
0 0 (0) (1)
1 (1)
0 (3)
0 (2)
Boolean expression
By solving the K-Map for input of the D flip flop we get the expression for Db as
ABX X A B X A B
Db =
end sequence_detector;
architecture sequence_detector_arch of sequence_detector is
type seq_detect_type is (
a, b, c, d
);
signal seq_detect: seq_detect_type;
begin
seq_detect_machine: process (clk)
begin
if clk'event and clk = '1' then
if rst='1' then
seq_detect <= a;
else
case seq_detect is
when a =>
if x = '1' then
seq_detect <= b;
elsif x = '0' then
seq_detect <= a;
end if;
when b =>
if x = '1' then
seq_detect <= c;
elsif x = '0' then
seq_detect <= a;
end if;
when c =>
if x = '1' then
seq_detect <= c
elsif x = '0' then
seq_detect <= d;
end if;
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 30 of
when d =>
if x = '1' then
seq_detect <= b;
elsif x = '0' then
seq_detect <= a;
end if;
when others =>
null;
end case;
end if;
end if;
end process;
z_assignment:
z <= '0' when (seq_detect = a and x = '1') else
'0' when (seq_detect = a and (x = '0' and not (x = '1'))) else
'0' when (seq_detect = b and x = '1') else
'0' when (seq_detect = b and (x = '0' and not (x = '1'))) else
'0' when (seq_detect = c and x = '1') else
'0' when (seq_detect = c and (x = '0' and not (x = '1'))) else
'1' when (seq_detect = d and x = '1') else
'0' when (seq_detect = d and (x = '0' and not (x = '1'))) else
'0';
end sequence_detector_arch;
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 31 of
clk : in STD_LOGIC;
rst : in STD_LOGIC;
x : in STD_LOGIC;
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 33 of
z : out STD_LOGIC );
end component;
signal clk : STD_LOGIC;
signal rst : STD_LOGIC;
signal x : STD_LOGIC;
signal z : STD_LOGIC;
begin
UUT : sequence_detector
port map (
clk => clk,
rst => rst,
x => x,
z => z
);
clk_process : process
begin
clk <= '0';
wait for 10 ns;
clk <= '1';
end process;
sti_process: process
begin
x <= '1';
wait for 20 ns;
x <= '0';
wait for 20 ns;
x <= '0';
x <= '0';
wait for 20 ns;
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 34 of
x <= '1';
wait for 20 ns;
x <= '0';
wait for 20 ns;
x <= '1';
wait for 20 ns;
x <= '1';
wait for 20 ns;
x <= '0';
wait for 20 ns;
x <= '1';
wait for 20 ns;
x <= '0';
wait for 20 ns;
x <= '1';
wait for 20 ns;
x <= '0';
wait for 20 ns;
x <= '0';
wait for 20 ns;
x <= '1';
wait for 20 ns;
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 35 of
x <= '0';
wait for 20 ns;
end process;
end TB_ARCHITECTURE;
configuration TESTBENCH_FOR_sequence_detector of sequence_detector_tb is
for TB_ARCHITECTURE
for UUT : sequence_detector
use entity work.sequence_detector(sequence_detector_arch);end for;
end for;
end TESTBENCH_FOR_sequence_detector;
7 RESULT
8 CONCLUSION
The design implemented in VHDL Hardware Description Language. It was simulated using
Xilinx simulator. State machines are such a general formalism, that a huge class of discrete-
time systems can be described as state machines. The system of defining primitive machines
and combinations gives us one discipline for describing complex systems. It will turn out that
there are some systems that are conveniently defined using this discipline, but that for other
kinds of systems, other disciplines would be more natural. State machines are such a general
class of systems that although it is a useful framework for implementing systems, we cannot
generally analyze the behavior of state machines. It has learnt about all the basic knowledge
of the digital circuit the design of Sequence detector was a full of knowledge with a live
operation on the software.
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 36 of
9 REFRENCES
Ee.surrey.ac.uk. (2016). Introduction to Sequential Circuits. [online] Available at:
http://www.ee.surrey.ac.uk/Projects/Labview/Sequential/Course/03-Seq_Intro/Intro.html
[Accessed 12 Apr. 2016].
Mealy, G. (1955). A method for synthesizing sequential circuits. Bell Syst. Tech. J., 34(5),
pp.1045-1079.
Safari. (2016). 9.7 Finite-State Machine Analysis [Book]. [online] Available at:
https://www.safaribooksonline.com/library/view/introduction-to-
digital/9780470900550/chap9-sec015.html [Accessed 4 Apr. 2016].
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016
CE00057-6 Digital Systems Individual Assignment Page 37 of
WhatIs.com. (2016). What is digital? - Definition from WhatIs.com. [online] Available at:
http://whatis.techtarget.com/definition/digital [Accessed 11 Apr. 2016].
__________________________________________________________________________________________
Level 3 Asia Pacific Institute of Information Technology 2016