IE1204 Digital Design. F11: Programmable Logic, VHDL for Sequential Circuits. Masoumeh (Azin) Ebrahimi

Similar documents
IE1204 Digital Design F11: Programmable Logic, VHDL for Sequential Circuits

Microprocessor Design

Chapter 7 Memory and Programmable Logic

DIGITAL CIRCUIT LOGIC UNIT 9: MULTIPLEXERS, DECODERS, AND PROGRAMMABLE LOGIC DEVICES

Level and edge-sensitive behaviour

COE328 Course Outline. Fall 2007

EE292: Fundamentals of ECE

FPGA Design with VHDL

Flip-flop and Registers

Field Programmable Gate Arrays (FPGAs)

Chapter Contents. Appendix A: Digital Logic. Some Definitions

RELATED WORK Integrated circuits and programmable devices

Computer Architecture and Organization

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Tajana Simunic Rosing. Source: Vahid, Katz

Why FPGAs? FPGA Overview. Why FPGAs?

L11/12: Reconfigurable Logic Architectures

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 3 Logistics

Ryerson University Department of Electrical and Computer Engineering EES508 Digital Systems

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

March 13, :36 vra80334_appe Sheet number 1 Page number 893 black. appendix. Commercial Devices

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

EECS150 - Digital Design Lecture 2 - CMOS

MUHAMMAD NAEEM LATIF MCS 3 RD SEMESTER KHANEWAL

L12: Reconfigurable Logic Architectures

CSE140L: Components and Design Techniques for Digital Systems Lab. CPU design and PLDs. Tajana Simunic Rosing. Source: Vahid, Katz

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

Lecture 6: Simple and Complex Programmable Logic Devices. EE 3610 Digital Systems

California State University, Bakersfield Computer & Electrical Engineering & Computer Science ECE 3220: Digital Design with VHDL Laboratory 7

Combinational vs Sequential

1. Convert the decimal number to binary, octal, and hexadecimal.

WEEK 10. Sequential Circuits: Analysis and Design. Page 1

VU Mobile Powered by S NO Group

Principles of Computer Architecture. Appendix A: Digital Logic

Final Exam review: chapter 4 and 5. Supplement 3 and 4


1.b. Realize a 5-input NOR function using 2-input NOR gates only.

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

DIGITAL SYSTEM DESIGN UNIT I (2 MARKS)

FPGA Design. Part I - Hardware Components. Thomas Lenzi

Figure 1: segment of an unprogrammed and programmed PAL.

Laboratory Exercise 7

Previous Lecture Sequential Circuits. Slide Summary of contents covered in this lecture. (Refer Slide Time: 01:55)

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

For Teacher's Use Only Q Total No. Marks. Q No Q No Q No

9 Programmable Logic Devices

Laboratory Exercise 4

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

Sequential Logic. Analysis and Synthesis. Joseph Cavahagh Santa Clara University. r & Francis. TaylonSi Francis Group. , Boca.Raton London New York \

DIGITAL ELECTRONICS MCQs

Laboratory Exercise 7

EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Introduction Actel Logic Modules Xilinx LCA Altera FLEX, Altera MAX Power Dissipation

Come and join us at WebLyceum

The word digital implies information in computers is represented by variables that take a limited number of discrete values.

DIGITAL CIRCUIT LOGIC UNIT 11: SEQUENTIAL CIRCUITS (LATCHES AND FLIP-FLOPS)


CS6201 UNIT I PART-A. Develop or build the following Boolean function with NAND gate F(x,y,z)=(1,2,3,5,7).

MODEL QUESTIONS WITH ANSWERS THIRD SEMESTER B.TECH DEGREE EXAMINATION DECEMBER CS 203: Switching Theory and Logic Design. Time: 3 Hrs Marks: 100

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

DIGITAL TECHNICS II. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

CHAPTER1: Digital Logic Circuits

Flip-Flops and Registers

Using minterms, m-notation / decimal notation Sum = Cout = Using maxterms, M-notation Sum = Cout =

ECE 263 Digital Systems, Fall 2015

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

S.K.P. Engineering College, Tiruvannamalai UNIT I

Chapter 2. Digital Circuits

CS302 - Digital Logic Design FAQs By

Design for Testability

CAD for VLSI Design - I Lecture 38. V. Kamakoti and Shankar Balachandran

EECS 270 Final Exam Spring 2012

Reconfigurable Architectures. Greg Stitt ECE Department University of Florida

ECE 3401 Lecture 12. Sequential Circuits (II)

EEE130 Digital Electronics I Lecture #1_2. Dr. Shahrel A. Suandi

2. Logic Elements and Logic Array Blocks in the Cyclone III Device Family

CPS311 Lecture: Sequential Circuits

A Tour of PLDs. PLD ARCHITECTURES. [Prof.Ben-Avi]

Advanced Digital Logic Design EECS 303

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 2 Logistics

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

Logic Design ( Part 3) Sequential Logic (Chapter 3)

DHANALAKSHMI SRINIVASAN INSTITUTE OF RESEARCH AND TECHNOLOGY CS6201-DIGITAL PRINCIPLE AND SYSTEM DESIGN. I Year/ II Sem PART-A TWO MARKS UNIT-I

Universidad Carlos III de Madrid Digital Electronics Exercises

Designing for High Speed-Performance in CPLDs and FPGAs

Synchronous Sequential Design

Laboratory 1 - Introduction to Digital Electronics and Lab Equipment (Logic Analyzers, Digital Oscilloscope, and FPGA-based Labkit)

Digital. Digital. Revision: v0.19 Date: : / 76

EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

MODULE 3. Combinational & Sequential logic

CHAPTER 4: Logic Circuits

Sequential Logic Circuits

Flip-Flops and Sequential Circuit Design

Logic Design II (17.342) Spring Lecture Outline

COMP2611: Computer Organization. Introduction to Digital Logic

Software Engineering 2DA4. Slides 3: Optimized Implementation of Logic Functions

ELCT201: DIGITAL LOGIC DESIGN

Chapter 5: Synchronous Sequential Logic

Logic Design ( Part 3) Sequential Logic- Finite State Machines (Chapter 3)

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Registers

Transcription:

IE1204 Digital Design F11: Programmable Logic, VHDL for Sequential Circuits Masoumeh (Azin) Ebrahimi (masebr@kth.se) Elena Dubrova (dubrova@kth.se) KTH / ICT / ES

This lecture BV pp. 98-118, 418-426, 507-519 IE1204 Digital Design, Autumn2016 2

Programmable Logic Devices Programmable logic devices (PLDs) were introduced in the 1970s They are based on a structure with an AND-OR array that makes it easy to implement a sum-of-products expression IE1204 Digital Design, Autumn2016 3

Structure of a PLD x 1 x 2 x n Input buffers and inverters x 1 x 1 x n x n P 1 AND plane P k OR plane f 1 f m IE1204 Digital Design, Autumn2016 4

Programmable Logic Array (PLA) Both AND and OR arrays are programmable x 1 x 2 x 3 P 1 OR plane f 1 =x 1 x 2 +x 1 x 3 +x 1 x 2 x 3 P 2 f 2 =x 1 x 2 +x 1 x 2 x 3 +x 1 x 3 P 3 P 4 AND plane f 1 f 2 IE1204 Digital Design, Autumn2016 5

Programmable Array Logic (PAL) Only the AND array is programmable x 1 x 2 x 3 f 1 =x 1 x 2 x 3 +x 1 x 2 x 3 f 2 =x 1 x 2 +x 1 x 2 x 3 P 1 P 2 P 3 f 1 P 4 f 2 AND plane IE1204 Digital Design, Autumn2016 6

Combinatorial and register outputs In earlier PLDs there were combinatorial outputs register outputs (outputs with a flip-flop) For each circuit the number of combinational and register outputs was fixed To increase flexibility, macrocells were introduced one can choose if an output is combinatorial or has a flip-flop IE1204 Digital Design, Autumn2016 7

Macrocells in a PLD x1 x2 x3 P1 P2 f1 Select Enable P3 P4 f2 f 1 Flip-flop Clock D Q A programmable multiplexer can be used to select the type of output To AND plane IE1204 Digital Design, Autumn2016 8

Programming of PLDs IE1204 Digital Design, Autumn2016 9

Complex PLD's (CPLD) PLDs were quite small (PALCE 22V10 had 10 flip-flops) To program larger functions, structures consisting of several PLD-like blocks were developed called Complex PLD (CPLD) IE1204 Digital Design, Autumn2016 10

CPLD Structure I/O block PAL-like block PAL-like block I/O block Interconnection wires I/O block PAL-like block PAL-like block I/O block IE1204 Digital Design, Autumn2016 11

Programming of CPLDs via the JTAG interface Modern CPLDs (and FPGAs) can be programmed by downloading circuit description (programming information) via a cable Download usually uses a standard port called JTAG port (Joint Test Action Group) IE1204 Digital Design, Autumn2016 12

Programming via the JTAG port (a) CPLD in a Quad Flat Pack (QFP) package To computer You can program the chips when they are soldered to the circuit board - using the programmer you can select which chip you want to program through the JTAG port Printed circuit board (b) JTAG programming IE1204 Digital Design, Autumn2016 13

Field Programmable Gate Arrays CPLDs are based on the AND-OR array It is difficult to make really large functions using CPLDs FPGAs use a different concept based on logic blocks IE1204 Digital Design, Autumn2016 14

Structure of an FPGA IE1204 Digital Design, Autumn2016 15

Look-up-tables (LUT) Programmable cells 0/1 0/1 1 0 1 f A LUT with n inputs can realize all combinational functions with up to n inputs. The usual size of LUT in an FPGA is n = 4 0/1 1 0 0/1 0 x 2 x 1 Two-input LUT IE1204 Digital Design, Autumn2016 16

Example: XOR gate x1 x2 f 1 1 0 1 0 1 0 1 1 0 0 0 Programmed values x 2 x 1 0 1 1 0 1 0 1 0 1 0 f Two-input LUT IE1204 Digital Design, Autumn2016 17

Logic Block in a FPGA A logic block in an FPGA often consists of a LUT, a flip-flop and a multiplexer to select register output Select In 1 Flip-flop Out In 2 LUT D Q In 3 Clock IE1204 Digital Design, Autumn2016 18

Programming the LUT's and the connection matrix in an FPGA Blue cross: switch is programmed Black cross: switch is not programmed x 1 x 3 f f=f 1 +f 2 x 2 x 1 x 2 0 0 0 1 x 2 0 f 1 1 f 2 0 x 3 0 f=x 1 x 2 +x 2 x 3 f 1 f 2 0 1 1 1 f IE1204 Digital Design, Autumn2016 19

DE2 University Board DE2 Board Cyclone II EP2C35 FPGA (Datorteknikcourse) 4 Mbytes of flash memory 512 Kbytes of static RAM 8 Mbytes of SDRAM Several I/O-Devices 50 MHz oscillator IE1204 Digital Design, Autumn2016 20

Cyclone II Logic Element IE1204 Digital Design, Autumn2016 21

Cyclone II Family (3) Total Number of 18x18 Multipliers DE2 IE1204 Digital Design, Autumn2016 22

Stratix III Family DE3 Board IE1204 Digital Design, Autumn2016 23

Multiple processors can be implemented on an FPGA Nios II is a so-called 'softprocessor' (32-bit) that can be implemented on Altera s FPGAs Today's FPGAs are so large that multiple processors can fit on a single FPGA chip Nios II Nios II Very powerful multiprocessor systems can be created on an FPGA! IE1204 Digital Design, Autumn2016 24

ASICs An ASIC (Application Specific Integrated Circuit) is a circuit which is manufactured at a semiconductor factory In a full custom integrated circuit, the entire circuit is customized In an ASIC, some design steps have already been made to reduce design time and cost There are several types of ASICs: Gate array ASICs Standard cell ASIC IE1204 Digital Design, Autumn2016 25

ASICs: Gate Array In a gate array ASIC, gates (or transistors) are already on silicon IE1204 Digital Design, Autumn2016 26

ASICs: Gate Array We only need to create the links between the inputs and outputs of gates x 1 x 2 f 1 x 3 IE1204 Digital Design, Autumn2016 27

ASICs: Standard Cells A standard cell can for example be AND, OR, Invert, XOR, XNOR, buffer, or a storage function as flipflop or latch. IE1204 Digital Design, Autumn2016 28

Comparison FPGA, Gate Array, Standard Cell Initial Cost Cost per part Performance Fabrication Time FPGA Low High Low Short Gate Array (ASIC) Standard Cell (ASIC) High Low High Long IE1204 Digital Design, Autumn2016 29

Design Trade-Offs Design Time Full Custom Standard Cell Gate Array Programmable Logic Microprocessor Performance IE1204 Digital Design, Autumn2016 30

VHDL: Sequential circuits IE1204 Digital Design, Autumn2016 31

Quick question Which logic gate is represented by the following VHDL code? IE1204 Digital Design, Autumn2016 32

Quick question Which logic gate is represented by the following VHDL code? IE1204 Digital Design, Autumn2016 33

Moore-machine processes For a Moore machine, we create three processes Next state decoder Output decoder State register State Input signals NEXT STATE DECODER STATE REGISTER OUTPUT DECODER Output signals Clk IE1204 Digital Design, Autumn2016 34

Bottle dispenser Bottle dispenser consists of several parts COIN RECEIVER DROP BOTTLE COIN RETURN Machine accepts only the following coins: 1 Euro, 50 Cent, 10 Cent The vending machine only returns 10 Cent coins IE1204 Digital Design, Autumn2016 35

Bottle dispenser vending machine in VHDL We use bottle dispenser vending machine as an example We describe its system controller in VHDL GT_1_EURO DROP DROP_READY DROP BOTTLE COIN RECEIVER EQ_1_EURO LT_1_EURO SYSTEM CONTROL DEC_ACC CLR_ACC RETURN_10_CENT CHANGER_READY COIN RETURN IE1204 Digital Design, Autumn2016 36

Signal Properties DROP_READY is active for one clock cycle after the bottle has been ejected CHANGER_READY is active for one clock cycle after a 10 Cent coin is ejected Because of the mechanical properties, the following signals are active and inactive for several clock cycles: (active for several clock cycles after the coin drop) DROP_READY (active for several clock periods after bottle drop) CHANGER_READY (inactive for several clock periods after coin return) IE1204 Digital Design, Autumn2016 37

Flow diagram of control system No Total <1 Reset Coin registered? Yes Total? Coin 10 Cent, 50 Cent, 1 Euro Coin return 10 Cent Bottle Price 1 Euro Total = 1 Total> 1 Eject bottle Reset sum Return 10 Cent Decrease sum IE1204 Digital Design, Autumn2016 38

State diagram (Moore) (a) (b) (a) (b) (c) Wait for coin Register coin Coin is registered (3 cases) LT_I_EURO (c) (d) (e) Drop bottle Reset sum EQ_I_EURO GT_I_EURO (f) Return 10 Cent DROP READY DROP (d) (f) CHANGER READY RETURN_10_CENT (g) Decrease sum with 10 Cent DROP READY (e) CLR_ACC (g) DEC_ACC CHANGER_READY Upon entry into the state, signal becomes active When exiting the state, signal becomes inactive IE1204 Digital Design, Autumn2016 39

State diagram (a) (b) State assignment with no claim for optimality (Ad hoc) (a) next to (b) DROP READY LT_I_EURO EQ_I_EURO DROP (d) (c) GT_I_EURO (f) CHANGER READY RETURN_10_CENT (b) next to (c) (d) next to (e) (f) next to (g) For all these cases, only one variable changes AB DROP READY CHANGER_READY 00 01 11 10 (e) (g) C 0 a - d f 1 b c e g CLR_ACC DEC_ACC ( - = don t care) IE1204 Digital Design, Autumn2016 40

State diagram DROP READY LT_I_EURO EQ_I_EURO DROP DROP READY (d) 110 (e) 111 CLR_ACC (a) 000 (b) 001 (c) 011 GT_I_EURO (f) 100 (g) 101 DEC_ACC CHANGER READY RETURN_10_CENT CHANGER_READY The state diagram contains all information required to generate an implementation Assumption: D flip-flops are used as state register 7 states: 3 flip-flops are needed The state variable order is ABC, i.e. state (c) is A = 0, B = 1,C = 1 IE1204 Digital Design, Autumn2016 41

Unused state?! DROP READY LT_I_EURO EQ_I_EURO DROP DROP READY (d) 110 (e) 111 CLR_ACC (a) 000 (b) 001 (c) 011 GT_I_EURO (f) 100 (g) 101 DEC_ACC (h) 010 CHANGER READY RETURN_10_CENT CHANGER_READY If fall into the unused state (h) we are stuck!! Possible ways out: going to (c) and continue. going to (d) and offering soft drinks!! going to (e) and resetting any previous payment. Which option do you prefer for your design?! Which option leads to a simpler design? IE1204 Digital Design, Autumn2016 42

Construction of next-state and output decoders (Moore machine) Combinational circuit Flip-flops Combinational circuit Inputsignals Outputsignals Clk LT_I_EURO EQ_I_EURO GT_I_EURO DROP_READY CHANGER_READY A B Next State Decoder D A D B D C D D D B C A Output Decoder DROP RETURN_I0_CENT CLR_ACC DEC_ACC C Clk At next step, we develop the logic for the next state (D A, D B, D C ) and outputs IE1204 Digital Design, Autumn2016 43

Construction of next-state and output decoders Input-signals Next state decoder (Combination al circuit) Clk Flip-flops Output decoder (Combination al circuit) Output-signals?? LT_I_EURO EQ_I_EURO GT_I_EURO DROP_READY CHANGER_READY A B Next State Decoder D A D B D C D D D B C A Output Decoder DROP RETURN_I0_CENT CLR_ACC DEC_ACC C Clk At next step, we develop the logic for the next state (D A, D B, D C ) and outputs IE1204 Digital Design, Autumn2016 44

Decoder: Next state - D A LT_I_EURO EQ_I_EURO (a) 000 (b) 001 (c) 011 GT_I_EURO C D A AB 00 01 11 10 0 0-1 1 1 0 (=) + (>) 0 0 (=) : EQ_1_EURO (>) : GT_1_EURO DROP READY DROP (d) 110 (f) 100 CHANGER READY RETURN_10_CENT DROP READY (e) 111 (g) 101 CHANGER_READY D A = AB( = ) + AB( > ) + AC CLR_ACC DEC_ACC IE1204 Digital Design, Autumn2016 45

Variable-Entered Mapping (VEM) Variable-Entered Mapping can help to draw and minimize Karnaugh diagrams with many variables. In this example there are several variables as: Coin_Present, Drop_Ready, Changer_Ready, GT, LT, EQ. Instead of opening an "extra dimension" we write a variable into the Karnaugh map You must be extra careful when drawing circuits so that you do not forget a variable combination! D A AB 00 01 11 10 C 0 0-1 1 1 0 (=) + (>) 0 0 IE1204 Digital Design, Autumn2016 46

Decoder: Next state - D B LT_I_EURO EQ_I_EURO (a) 000 (b) 001 (c) 011 GT_I_EURO C D B AB 00 01 11 10 0 0-1 0 1 CP (=) 0 1 (=) : EQ_1_EURO CP : DROP READY DROP (d) 110 (f) 100 CHANGER READY RETURN_10_CENT DROP READY (e) 111 CLR_ACC (g) 101 DEC_ACC CHANGER_READY D B = AB( = ) + BC + BC(CP) + ABC IE1204 Digital Design, Autumn2016 47

Decoder: Next state- D C DROP READY LT_I_EURO EQ_I_EURO DROP (d) 110 (a) 000 (b) 001 (c) 011 GT_I_EURO (f) 100 CHANGER READY C RETURN_10_CENT D C AB 00 01 11 10 0 CP - DR CR 1 1 0 0 1 CP : DR: DROP_READY CR: CHANGER_READY DROP READY (e) 111 CLR_ACC (g) 101 DEC_ACC CHANGER_READY D C = AC(CP) + BC(DR) + AB(CR) + BC IE1204 Digital Design, Autumn2016 48

Decoder: Output signals DROP READY LT_I_EURO EQ_I_EURO DROP DROP READY (d) 110 (e) 111 CLR_ACC (a) 000 (b) 001 (c) 011 GT_I_EURO (f) 100 (g) 101 DEC_ACC CHANGER READY RETURN_10_CENT CHANGER_READY Output decoder is trivial, since its value is directly dependent on the current state DROP = CLR_ACC = ABC RETURN_10_ DEC_ACC ABC = CENT = ABC ABC IE1204 Digital Design, Autumn2016 49

Implementation LT_I_EURO EQ_I_EURO GT_I_EURO DROP_READY CHANGER_READY A B Next State Decoder D A D B D C D D D B C A Output Decoder DROP RETURN_I0_CENT CLR_ACC DEC_ACC C Clk Now you can design Next State Decoder and Output Decoder by knowing the logic function of D a, D b, D c, and logic funtion of outputs Drop, Return_10_Cent, CLR_ACC, and DEC_ACC. IE1204 Digital Design, Autumn2016 50

Vending Machine in VHDL: Entity Entity describes the system as a 'black box' Entity describes the interface to the outside world All inputs and outputs are described Apart from the input and output signals, block diagram needs signals for Clock Reset (active low) ENTITY Vending_Machine IS PORT ( -- Inputs coin_present : IN std_logic; gt_1_euro : IN std_logic; eq_1_euro : IN std_logic; lt_1_euro : IN std_logic; drop_ready : IN std_logic; changer_ready : IN std_logic; reset_n : IN std_logic; clk : IN std_logic; -- Outputs dec_acc : OUT std_logic; clr_acc : OUT std_logic; drop : OUT std_logic; return_10_cent : OUT std_logic); END Vending_Machine; IE1204 Digital Design, Autumn2016 51

Vending Machine in VHDL: The architecture describes the function of the machine We define Architecture internal signals for the current and next states three processes for next-state decoder, output decoder and state register IE1204 Digital Design, Autumn2016 52

Processes in VHDL A architecture in VHDL can contain multiple processes Processes are executed in parallel A process is written as a sequential program IE1204 Digital Design, Autumn2016 53

Internal signals Moore machine contains internal signals for Current state Next state These signals are declared in the architecture description IE1204 Digital Design, Autumn2016 54

Vending Machine in VHDL: Internal Signals We need to create a type for internal signals Since we describe the states, we use an enumerated type with the values a, b, c, d, e, f, g We declare one variable for the current state (current_state) and one for the next state (next_state) ARCHITECTURE Moore_FSM OF Vending_Machine IS TYPE state_type IS (a, b, c, d, e, f, g); SIGNAL current_state, next_state: state_type; BEGIN -- Moore_FSM IE1204 Digital Design, Autumn2016 55

Vending Machine in VHDL: Internal Signals If we do not specify a state assignment, synthesis tool will select it We can force a certain encoding using attributes (NOTE: Attributes are dependent on synthesis tool and thus are not portable!) ARCHITECTURE Moore_FSM OF Vending_Machine IS TYPE state_type IS (a, b, c, d, e, f, g); -- We can use state encoding according to BV 8.4.6 -- to enforce a particular encoding (for Quartus) ATTRIBUTE enum_encoding : string; ATTRIBUTE enum_encoding OF state_type : TYPE IS "000 001 011 110 111 100 101"; SIGNAL current_state, next_state : state_type; BEGIN -- Moore_FSM IE1204 Digital Design, Autumn2016 56

Vending Machine in VHDL: Process for Next-State Decoder Input-signals Next-State-Decoder is described as a process Sensitivity list contains all the inputs that 'activate' the process NEXTSTATE : PROCESS (current_state, coin_present, gt_1_euro, eq_1_euro, lt_1_euro, drop_ready, changer_ready) - Sensitivity List BEGIN -- PROCESS NEXT_STATE Next state decoder (Combination al circuit) Clk Flip-flops Output decoder (Combination al circuit) Output-signals IE1204 Digital Design, Autumn2016 57

Vending Machine in VHDL: Process for Next-State-Decoder Input-signals Next state decoder (Combination al circuit) Flip-flops Output decoder (Combination al circuit) Output-signals Clk We now use a CASE statement to describe the transitions to the next state from each state conditions CASE current_state IS WHEN a => IF coin_present = '1' THEN next_state <= b; ELSE next_state <= a; END IF; WHEN b => IF coin_present = '0' THEN next_state <= c; ELSE next_state <= b; END IF; DROP READY LT_I_EURO EQ_I_EURO DROP DROP READY (d) 110 (e) 111 CLR_ACC (a) 000 (b) 001 (c) 011 (f) 100 (g) 101 GT_I_EURO DEC_ACC CHANGER READY RETURN_10_CENT CHANGER_READY IE1204 Digital Design, Autumn2016 58

Vending Machine in VHDL: Process for Next-State-Decoder We can simplify the description by specifying a default value for the next state next_state <= current_state; CASE current_state IS WHEN a => IF coin_present = '1' THEN next_state <= b; END IF; WHEN b => IF coin_present = '0' THEN next_state <= c; END IF; It is important to we specify all options fornext_state signal. Otherwise we may implicitly setnext_state <= next_state which generates a loop. IE1204 Digital Design, Autumn2016 59

Vending Machine in VHDL: Process for Next-State-Decoder We terminate the CASE statement with a WHEN OTHERS statement. Here we specify that we should go to the stateaif we end up in an unspecified state WHEN g => next_state <= c; WHEN OTHERS => next_state <= a; END CASE; END PROCESS NEXTSTATE; IE1204 Digital Design, Autumn2016 60

Vending Machine in VHDL: Process for Output-Decoder Input-signals Next state decoder (Combination al circuit) Flip-flops Output decoder (Combination al circuit) Output-signals Clk Output decoder is described as a separate process Sensitivity list contains only the current state because the outputs are directly dependent on it IE1204 Digital Design, Autumn2016 61

Vending Machine in VHDL: Process for Output-Decoder OUTPUT : PROCESS (current_state) BEGIN -- PROCESS OUTPUT drop <= '0'; clr_acc <= '0'; dec_acc <= '0'; return_10_cent <= '0'; CASE current_state IS WHEN d => drop <= '1'; WHEN e => clr_acc <= '1'; WHEN f => return_10_cent <= '1'; WHEN g => dec_acc <= '1'; WHEN OTHERS => NULL; END CASE; END PROCESS OUTPUT; IE1204 Digital Design, Autumn2016 62

Vending Machine in VHDL: Process for State register Input-signals Next state decoder (Combination al circuit) Flip-flops Output decoder (Combination al circuit) Output-signals Clk State register is modeled as a synchronous process with asynchronous reset (active low) CLOCK : PROCESS (clk, reset_n) BEGIN -- PROCESS CLOCK IF reset_n = '0' THEN -- asynchronous reset (active low) current_state <= a; ELSIF clk EVENT AND clk = '1' THEN -- rising clock edge current_state <= next_state; END IF; END PROCESS CLOCK; IE1204 Digital Design, Autumn2016 63

Quick question Which state machine is represented by this VHDL code? IE1204 Digital Design, Autumn2016 64

Mealy machine State Input signals NEXT STATE DECODER STATE REGISTER OUTPUT DECODER Output signals Clk In a Mealy machine, output signals depend on both the current state and inputs IE1204 Digital Design, Autumn2016 65

Mealy machine in VHDL A Mealy machine can be modeled in the same way as the Moore machine The difference is that output decoder is also dependent on the input signals Process which models outputs needs to have input signals in the sensitivity list as well! IE1204 Digital Design, Autumn2016 66

More on VHDL The sample code for bottle dispenser available on the course website Look at the study of "VHDL synthesis" on the course website Both Brown/Vranesic- and Hemert-book includes code samples IE1204 Digital Design, Autumn2016 67

Summary PLD, PAL, CPLD FPGA ASIC gate array and standard cell Modeling sequential circuits with VHDL Next lecture: BV pp. 584-640 IE1204 Digital Design, Autumn2016 68