0% found this document useful (0 votes)
44 views13 pages

Experiment VHDL

1. The document describes designing and implementing a vending machine using a finite state machine. 2. The vending machine will have 9 states (S1, S2, etc.) to track the transaction and item dispensing process. 3. The state transitions and outputs are programmed based on the current state and inputs for depositing money (D) and selecting an item (N).

Uploaded by

Rishabh Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views13 pages

Experiment VHDL

1. The document describes designing and implementing a vending machine using a finite state machine. 2. The vending machine will have 9 states (S1, S2, etc.) to track the transaction and item dispensing process. 3. The state transitions and outputs are programmed based on the current state and inputs for depositing money (D) and selecting an item (N).

Uploaded by

Rishabh Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Date :- - - 2017

Experiment No :-7(A)

Aim :-To design and perform Melay Machine.

Apparatus Required :-
i. Xilinx Software 9.2i
ii. Computer System
iii. Power Supply

Theory :-
Mealy machine is a finite-state machine whose output values are determined both by its
current state and the current inputs. (This is in contrast to a Moore machine,whose output
values are determined solely by its current state.) A Mealy machine is a deterministic finite-
state transducer:- for each state and input, at most one transition is possible.

The state diagram for a Mealy machine associates an output value with each transition edge
(in contrast to the state diagram for a Moore machine, which associates an output value with
each state).

Program :-
library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

entitymelay is

port ( Clock,w : in STD_LOGIC;

Resetn : in STD_LOGIC;

z : out STD_LOGIC);

endmelay;

architecture Behavioral of melay is

TYPE State_type IS (A, B) ;

SIGNAL y :State_type ;

64
BEGIN

PROCESS ( Resetn, Clock )

BEGIN

IF Resetn = '0' THEN

y <= A ;

ELSIF (Clock'EVENT AND Clock = '1') THEN

CASE y IS

WHEN A =>

IF w = '0' THEN y <= A ;

ELSE y <= B ;

END IF ;

WHEN B =>

IF w = '0' THEN y <= A ;

ELSE y <= B ;

END IF ;

END CASE ;

END IF ;

END PROCESS ;

PROCESS ( y, w )

BEGIN

CASE y IS

WHEN A =>

z <= '0' ;

WHEN B =>

z <= w ;

END CASE ;

65
END PROCESS ;

end Behavioral;

Block Diagarm

RTL View

66
Technology View

Waveform

Result :-I have successfully designedMelay Machine .

67
Date :- - - 2017

Experiment No :-7(B)

Aim :-To design and perform Moore Machine.

Apparatus Required :-
i. Xilinx Software 9.2i
ii. Computer System
iii. Power Supply

Theory :-
Moore machine is a finite-state machine whose output values are determined only by its
current state. This is in contrast to a Mealy machine, whose output values are determined
both by its current state and by the values of its inputs. The Moore machine is named
after Edward F. Moore, who presented the concept in a 1956 paper, “Gedanken-
experiments on Sequential Machines.

Program :-
library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;

use IEEE.STD_LOGIC_UNSIGNED.ALL;

entitymoore is

Port ( clock : in STD_LOGIC;

resetn : in STD_LOGIC;

w : in STD_LOGIC;

z : out STD_LOGIC);

endmoore;

architecture Behavioral of moore is

TYPE State_type IS (A, B, C) ;

SIGNAL y :State_type ;

68
begin

PROCESS ( Resetn, Clock )

begin

IF Resetn = '0' THEN

y <= A ;

ELSIF (Clock'EVENT AND Clock = '1') THEN

CASE y IS

WHEN A =>
IF w = '0' THEN
y <= A ;
ELSE
y <= B ;
END IF ;

WHEN B =>
IF w = '0' THEN
y <= A ;
ELSE
y <= C ;
END IF ;

WHEN C =>
IF w = '0' THEN
y <= A ;
ELSE
y <= C ;
END IF ;

END CASE ;

END IF ;

END PROCESS ;

z <= '1' WHEN y = C ELSE '0' ;

end Behavioral;

69
RTL View

70
Technology View

Waveform

Result :-I have successfully designed Moore Machine .

71
Date :- - - 2017

Experiment No :-8

Aim :-To design and perform Vending Machine.

Apparatus Required :-
i. Xilinx Software 9.2i
ii. Computer System
iii. Power Supply

Theory :-
A vending machine is an automated machine that provides items such
as snacks, beverages, alcohol, cigarettes and lottery tickets to consumers after money or
a credit card is inserted into the machine. The first modern vending machines were developed
in England in the early 1880s that dispensed postcards. Vending machines exist in many
countries, and in more recent times, specialized vending machines that provide less common
products compared to traditional vending machine items have been created and provided to
consumers.

Program :-
LIBRARY ieee ;

USE ieee.std_logic_1164.all ;

ENTITY VM_AV IS

PORT (CLK, D , N , RESET : IN std_logic ;

z : OUT std_logic) ;

END ;

ARCHITECTURE BEHAVIOR OF VM_AV IS

-- State variables for machine sreg

SIGNAL S1 , next_S1 , S2 , next_S2 , S3 , next_S3 , S4 , next_S4 , S5 ,


next_S5 , S6 ,

next_S6 , S7 , next_S7 , S8 , next_S8 , S9 , next_S9 : std_logic ;

SIGNAL next_z :std_logic ;

BEGIN

72
PROCESS (CLK, next_S1 , next_S2 , next_S3 , next_S4 , next_S5 , next_S6
, next_S7 ,

next_S8 , next_S9 , next_z)

BEGIN

IF CLK= '1' AND CLK'event THEN

S1 < = next_S1 ;

S2 < = next_S2 ;

S3 < = next_S3 ;

S4 < = next_S4 ;

S5 < = next_S5 ;

S6 < = next_S6 ;

S7 < = next_S7 ;

S8 < = next_S8 ;

S9 < = next_S9 ;

z < = next_z ;

END IF ;

END PROCESS ;

PROCESS ( D , N , RESET , S1 , S2 , S3 , S4 , S5 , S6 , S7 , S8 , S9)

BEGIN

IF ( ( D = '1' AND N = '1' AND (S1 = '1') ) OR ( D = '0' AND N = '0' AND
(S1 = '1') ) OR

( D = '0' AND N = '0' AND (S4 = '1') ) OR ( D = '0' AND N = '0' AND (S7 =
'1') ) OR ( (

S8 = '1') ) OR ( RESET= '1' ) ) THEN next_S1 < = '1' ;

ELSE next_S1 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '1' AND N = '0' AND (S1 = '1') ) OR ( D = '1'
AND N = '1' AND

73
RESET= '0' AND (S2 = '1') ) OR ( N = '0' AND D = '0' AND RESET= '0'
AND (S2 = '1') ) )

THEN next_S2 < = '1' ;

ELSE next_S2 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '0' AND N = '1' AND (S1 = '1') ) OR ( D = '0'
AND N = '0' AND

RESET= '0' AND (S3 = '1') ) OR ( N = '1' AND D = '1' AND RESET= '0'
AND (S3 = '1') )

OR ( RESET= '0' AND D = '0' AND N = '1' AND (S5 = '1') ) OR ( RESET=
'0' AND D = '0'

AND N = '1' AND (S9 = '1') ) ) THEN next_S3 < = '1' ;

ELSE next_S3 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '0' AND N = '1' AND (S2 = '1') ) OR ( D = '1'
AND RESET= '0'

AND (S4 = '1') ) OR ( N = '1' AND RESET= '0' AND (S4 = '1') ) ) THEN
next_S4 < = '1' ;

ELSE next_S4 < = '0' ;

END IF ;

AND (S5 = '1') ) OR ( N = '0' AND RESET= '0' AND (S5 = '1') ) ) THEN
next_S5 < = '1' ;

ELSE next_S5 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '0' AND N = '1' AND (S3 = '1') ) OR ( D = '1'
AND N = '1' AND

RESET= '0' AND (S6 = '1') ) OR ( N = '0' AND D = '0' AND RESET= '0'
AND (S6 = '1') ) )

THEN next_S6 < = '1' ;

ELSE next_S6 < = '0' ;

74
END IF ;

IF ( ( RESET= '0' AND D = '1' AND N = '0' AND (S3 = '1') ) OR ( D = '1'
AND RESET= '0'

AND (S7 = '1') ) OR ( N = '1' AND RESET= '0' AND (S7 = '1') ) ) THEN
next_S7 < = '1' ;

ELSE next_S7 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '0' AND N = '1' AND (S6 = '1') ) ) THEN
next_S8 < = '1' ;

ELSE next_S8 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '1' AND N = '0' AND (S6 = '1') ) OR ( D = '1'
AND RESET= '0'

AND (S9 = '1') ) OR ( N = '0' AND RESET= '0' AND (S9 = '1') ) ) THEN
next_S9 < = '1' ;

ELSE next_S9 < = '0' ;

END IF ;

IF ( ( RESET= '0' AND D = '0' AND N = '1' AND (S2 = '1') ) OR ( D = '1'
AND RESET= '0'

AND (S4 = '1') ) OR ( N = '1' AND RESET= '0' AND (S4 = '1') ) OR (
RESET= '0' AND

D = '1' AND N = '0' AND (S2 = '1') ) OR ( D = '1' AND RESET= '0' AND
(S5 = '1') ) OR (

N = '0' AND RESET= '0' AND (S5 = '1') ) OR ( RESET= '0' AND D = '1'
AND N = '0' AND (

S3 = '1') ) OR ( D = '1' AND RESET= '0' AND (S7 = '1') ) OR ( N = '1' AND
RESET= '0' AND

(S7 = '1') ) OR ( RESET= '0' AND D = '0' AND N = '1' AND (S6 = '1') ) OR
( RESET= '0'

AND D = '1' AND N = '0' AND (S6 = '1') ) OR ( D = '1' AND RESET= '0'
AND (S9 = '1') ) OR

( N = '0' AND RESET= '0' AND (S9 = '1') ) ) THEN next_z< = '1' ;

75
ELSE next_z< = '0' ;

END IF ;

END PROCESS ;

END BEHAVIOR ;

Result :-I have successfully designed Vending Machine .

76

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy