Tutorial 3. Appendix D. D.1 Design Using Verilog Code. The Ripple-Carry Adder Code. Functional Simulation

Similar documents
Tutorial 2 Implementing Circuits in Altera Devices

Contents. Appendix B HDL Entry Tutorial 2 Page 1 of 14

Using Library Modules in Verilog Designs

Using ModelSim to Simulate Logic Circuits for Altera FPGA Devices

Using Library Modules in Verilog Designs. 1 Introduction. For Quartus II 13.0

Using ModelSim to Simulate Logic Circuits in VHDL Designs. 1 Introduction. For Quartus II 13.0

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

Laboratory Exercise 7

QUARTUS II Altera Corporation

Tutorial on Quartus II Introduction Using Verilog Code

University of Florida EEL 3701 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering Revision 0 12-Jun-16

EET 1131 Lab #7 Arithmetic Circuits

University of Florida EEL 3701 Dr. Eric M. Schwartz Madison Emas, TA Department of Electrical & Computer Engineering Revision 1 5-Jun-17

Using Library Modules in VHDL Designs

Laboratory Exercise 8

Using Library Modules in VHDL Designs

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 6: Quartus II Tutorial and Practice. Name: Date:

Quartus II Introduction Using Verilog Design

Using Library Modules in VHDL Designs. 1 Introduction. For Quartus II 12.1

SCHEMATIC DESIGN IN QUARTUS

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

Tutorial on Quartus II Introduction Using Schematic Designs

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180A DIGITAL SYSTEMS I Winter 2015

Quartus II Introduction Using Schematic Design

Introduction to Simulation of VHDL Designs Using ModelSim Graphical Waveform Editor. 1 Introduction. For Quartus Prime 16.1

ENEE245 Digital Circuits and Systems Lab Manual

Engineering 303 Digital Logic Design Fall 2018

ENEE245 Digital Circuits and Systems Lab Manual

Verilog Design Entry, Synthesis, and Behavioral Simulation

Laboratory Exercise 9

Lab 2: Introduction to Verilog HDL and Quartus

EET2141 Project 2: Binary Adder Using Xilinx 7.1i Due Friday April 25

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Generating Parameterized Modules and IP Cores

EE 231 Fall Lab 1: Introduction to Verilog HDL and Altera IDE

CPE 200L LABORATORY 4: INTRODUCTION TO DE2 BOARD UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND:

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

LAB 4: Seven Seg, Full Adder, Ripple Adder, Heirarchical Design

ECE 3610 Microprocessing Systems Lab #1 Verilog Design of the TOC Using Quartus II

EXPERIMENT 1. INTRODUCTION TO ALTERA

Quartus II Introduction Using Verilog Designs. 1 Introduction. For Quartus II 12.0

MaxPlus II Tutorial with Basic Graphical Gate Entry and Simulation Obtaining the MaxPlus Software: Example Problem: Y = A*/B + /C

A Beginner's Guide to MAX+plus II

Chapter 6 Combinational-Circuit Building Blocks

COSC 3215 Embedded Systems Laboratory

CHAPTER 3 METHODOLOGY. 3.1 Analysis of the Conventional High Speed 8-bits x 8-bits Wallace Tree Multiplier

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

ECSE-323 Digital System Design. Lab #1 Using the Altera Quartus II Software Fall 2008

My First FPGA for Altera DE2-115 Board

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

problem maximum score 1 10pts 2 8pts 3 10pts 4 12pts 5 7pts 6 7pts 7 7pts 8 17pts 9 22pts total 100pts

Digital Design with FPGAs. By Neeraj Kulkarni

Lecture 32: SystemVerilog

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Altera Quartus II Tutorial ECE 552

Getting Started with Xilinx WebPack 13.1

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Chapter 2 Getting Hands on Altera Quartus II Software

SignalTap II with Verilog Designs. 1 Introduction. For Quartus II 13.1

FPGA Introductory Tutorial: Part 1

Contents. Appendix D Verilog Summary Page 1 of 16

Verilog 1 - Fundamentals

Error Correction Code (ALTECC_ENCODER and ALTECC_DECODER) Megafunctions User Guide

Simulating a Design Circuit Using Qsim

EE 231 Fall EE 231 Lab 2

CSCB58 - Lab 3. Prelab /3 Part I (in-lab) /2 Part II (in-lab) /2 TOTAL /8

University of Massachusetts Amherst Computer Systems Lab 2 (ECE 354) Spring Lab 1: Using Nios 2 processor for code execution on FPGA

CSC / EE Digital Systems Design. Summer Sample Project Proposal 01

QuartusII.doc 25/02/2005 Page 1

E85: Digital Design and Computer Engineering Lab 2: FPGA Tools and Combinatorial Logic Design

NIOS CPU Based Embedded Computer System on Programmable Chip

Finite-State Machine (FSM) Design

Laboratory Exercise 3 Comparative Analysis of Hardware and Emulation Forms of Signed 32-Bit Multiplication

DIGITAL SYSTEM DESIGN

Xilinx Schematic Entry Tutorial

1 Introduction 2. 2 Background 3. 3 Getting Started 4. 4 Starting a New Project 6. 5 Design Entry Using VHDL Code 13

Quartus. Tutorial. Programmable Logic Development System

Altera Technical Training Quartus II Software Design

ECE 2300 Digital Logic & Computer Organization. More Finite State Machines

Lecture 15: System Modeling and Verilog

Chapter 2: Hardware Design Flow Using Verilog in Quartus II

2015 Paper E2.1: Digital Electronics II

ENEE 245 Lab 1 Report Rubrics

Register Transfer Level in Verilog: Part I

Laboratory Exercise 3

Quartus II Version 14.0 Tutorial Created September 10, 2014; Last Updated January 9, 2017

*Instruction Matters: Purdue Academic Course Transformation. Introduction to Digital System Design. Module 4 Arithmetic and Computer Logic Circuits

EECS 270 Verilog Reference: Sequential Logic

ENGN1640: Design of Computing Systems Topic 02: Lab Foundations

Chap 6 Introduction to HDL (d)

Xilinx Tutorial Basic Walk-through

Quartus II Tutorial. September 10, 2014 Quartus II Version 14.0

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign

Control in Digital Systems

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

Recommended Design Techniques for ECE241 Project Franjo Plavec Department of Electrical and Computer Engineering University of Toronto

Experiment 18 Full Adder and Parallel Binary Adder

Transcription:

Appendix D Tutorial 3 This tutorial introduces more advanced capabilities of the Quartus II system. We show how Verilog code is organized and compiled and illustrate how multibit signals are represented using the CAD tools. Examples using the building blocks in the library of parameterized modules (LPM) are presented, as well as examples of sequential circuits. In addition to the CAD tool applications that are used in Tutorials 1 and 2, this tutorial introduces the Timing Analyzer application. D.1 Design Using Verilog Code In section 5.5 we show how an n-bit ripple-carry adder can be specified in Verilog code. In this section we show how the ripple-carry adder can be implemented using the Quartus II system. Create a new project, adder16, in a directory tutorial3\addern. We will implement the adder circuit in a MAX 7000 CPLD. Thus, in the New Project Wizard window shown in Figure B.7, select the MAX 7000S family. Then, in the window given in Figure B.8, choose the EPM7128SLC84-7 chip. We have chosen this chip because it is provided on the Altera development board, which is discussed in section C.3. D.1.1 The Ripple-Carry Adder Code Verilog code for the n-bit adder is given in Figure D.1. It takes the carry-in signal, carryin, plus two n-bit numbers, X and Y, as inputs and produces the n-bit output sum, S, and carry-out signal, carryout. The code uses the parameter n, so that the adder can be parameterized to work for any value of n. In this example, n is set to 16. In the code the vector C is used to represent the intermediate carries between the stages in the adder. A for loop is used to create n full-adders that comprise the ripple-carry adder. Type the code in Figure D.1 into the Text Editor, as explained in Section B.4.2, and save the file in the tutorial3\addern directory using the name adder16.v. Compile the circuit. When analyzing the code, the compiler reports errors in your code, fix them. The compilation report is shown in Figure D.2. D.1.2 Functional Simulation To verify the correctness of the circuit, we will perform functional simulation, as described in Section B.3.3. Since this is a tutorial on the usage of CAD tools, we will use only a few test vectors. Normally, more extensive testing is required. 1

module adder16 (carryin, X, Y, S, carryout); parameter n = 16; input carryin; input [n 1:0] X, Y; output [n 1:0] S; output carryout; reg [n 1:0] S; reg [n:0] C; reg carryout; integer k; always @(X or Y or carryin) begin C[0] = carryin; for (k=0;k<=n 1; k = k+1) begin S[k] = X[k] Y[k] C[k]; C[k+1] = (X[k] & Y[k]) (C[k] & X[k]) (C[k] & Y[k]); end carryout = C[n]; end endmodule Figure D.1. Verilog code for a ripple-carry adder. Figure D.2. The compilation report summary. Open the Waveform Editor window. Set the desired simulation to run from 0 to 250 ns. Choose the grid lines to be placed at 25-ns intervals. This is done by selecting Edit Grid Size, which leads to the window in Figure D.3. Set the period to 50 ns and click OK. Select View Fit in Window to display the entire simulation range in the window. Resize the window to its maximum size. 2

Figure D.3. Setting the spacing of grid lines. Figure D.4. The Node Finder window. Open the Node Finder utility to reach the window in Figure D.4. Set the filter to Pins: all and click Start, which displays the input and output nodes as depicted in the figure. Scroll down the list of displayed nodes until you reach carryin. Select this node by clicking on it and then clicking the > sign. Next select the X input. Note that this input can be selected either as nodes that correspond to the individual bits (denoted by bracketted subscripts) or as a 16-bit vector, which is a more convenient form. Then, select the input Y and outputs S and carryout. This produces the image in the figure. Click OK. The Waveform Editor window now looks like the image in Figure D.5. Vectors X, Y, and S are initially treated as binary numbers. They can also be treated as either octal, hexadecimal, signed decimal, or unsigned decimal numbers. For our purpose it is convenient to treat them as hexadecimal numbers, so right-click on X and select Properties in the pop-up box to get to the window displayed in Figure D.6. Choose hexadecimal as the radix, make sure that the bus width is 16 bits, and click OK. (Quartus II uses the term bus to refer to multibit nodes.) In the same manner, declare that Y and S should be treated as hexadecimal numbers. The resulting waveform display is shown in Figure D.7. 3

Figure D.5. Selected input and output nodes. Figure D.6. Defining the characteristics of a node. Figure D.7. Using the hexadecimal representation for multibit signals. We will now set the test values of X and Y. The default value of these inputs is 0. To assign specific values in various intervals proceed as follows. Select (highlight) the interval from 100 to 175 ns of input X. Press the Arbitrary Value icon in the toolbar (it is labeled by a question mark), to bring up the pop-up window in Figure D.8. Enter the value 3FFF and click OK. Then, set X to the value 7FFF in the interval from 175 to 250 ns. Set Y to 0001 in the interval from 50 to 250 ns. Thus, the input waveforms should be as depicted in Figure D.9. Save the file as adder16.vwf. 4

Figure D.8. Assigning the value of a multibit signal. Figure D.9. The result of functional simulation. As explained in Section B.3.3, to perform the functional simulation, select Assignments Settings Simulator Settings Mode to display the window in Figure B.25 and choose Functional as the simulation mode. Run the simulator. The result of simulation is shown in Figure D.9, which indicates that the values of the output S are correct for the test input vectors applied. D.1.3 Timing Simulation Having verified that the designed circuit is functionally correct, we will now perform the timing simulation to determine its speed of operation in the chosen device. Select Assignments Settings Simulator Settings Mode to reach the window in Figure B.25 and choose Timing as the simulation mode. Run the simulator. The result is given in Figure D.10. It shows considerable delays in producing the correct values of S because the carries are rippling through the adder stages. Figure D.10. The result of timing simulation. 5

Figure D.11. Expanded view of timing simulation results. To get a good estimate of the delay, we can use the reference line. Point to the small square handle at the top of the reference line and drag it to the point where the S value becomes 4000. (To make it possible to move the reference line to any point in the waveform display, it may be necessary to turn off the feature View Snap on Grid.) A more accurate estimate can be obtained if the waveform image is enlarged using the Zoom Tool. This tool is activated by the toolbar icon that looks like a magnifying glass. Then, left-clicking or right-clicking on the waveforms will enlarge or reduce the displayed image, respectively. Enlarge the image to look like the display in Figure D.11. Click on the Selection Tool icon (which looks like a big arrowhead), and drag the reference line as closely as possible to the point where the value 4000 becames valid. The change in S from 0001 to 4000 is caused by the X input changing from 0000 to 3FFF, which occurs at 100 ns. As seen in Figure D.11, the output S changes to 4000 at approximately 127.5 ns. Therefore, the propagation delay through the adder, for these particular values of inputs, is estimated to be 27.5 ns. Note that, in this case, the adder performs the operation 3FFF + 1 = 4000 which involves a carry rippling through most of the stages of the adder circuit. For other values of inputs, the propagation delay may be much smaller. In Figure D.11, we see that the operation 0000 + 0001 = 0001 is completed within 8 ns. When Quartus II compiles a circuit design, it automatically produces an estimate of the speed of the circuit. Open the compilation report by selecting Processing Compilation Report or by clicking on the toolbar icon that looks like a white sheet on top of a blue chip. The report includes the derived timing analysis. Click on the small + symbol next to Timing Analyzer to expand this section of the report. Then, click on Timing Analyzer Summary to get the display in Figure D.12. The summary indicates that the estimated worst case propagation delay, t pd, is 27.5 ns. This agrees with the estimate we obtained by means of timing simulation. Note also that the minimum delay is estimated to be 7.5 ns. More detailed information about the propagation delays along various paths through the circuit can be seen by clicking on tpd, which displays the information in Figure D.13. Here, we see that there are ten paths along which the propagation delay is 27.5 ns, including the one given in the summary in Figure D.12. These longest-delay paths are referred to as critical paths. Figure D.12. The worst-case propagation delay. 6

Figure D.13. The critical paths. The Timing Analyzer performs different types of timing analysis. The results displayed in Figure D.13 give the delays through a combinational circuit, from input pins to output pins. The other types of analysis are applicable only to circuits that contain storage elements, namely flip-flops. For example, a typical computer circuit has flip-flops on both the input and output sides of a combinational circuit. Then, it is of interest to know the longest propagation delay from the input to the output flip-flops. This delay determines the maximum frequency at which the flip-flops can be clocked, referred to as fmax. D.1.4 Implementation in an FPGA Chip We will now implement the ripple-carry circuit in an FPGA chip. Select Assign Device to reach the window in Figure D.14. Choose the FLEX10K family. Also, choose a specific device, EPF10K20RC240-4, which is included on the Altera development board described in section C.3. Click OK. Compile the circuit. Open the Timing Analyzer summary in the compilation report, which is depicted in Figure D.15. Observe that the worst-case propagation delay is now 60.2 ns, which is significantly longer than the delay observed in Section D.1.3. We should not jump to a conclusion that FPGA devices are not as good as the CPLD chips. There are many FPGAs that are much faster than the device chosen in our implementation. Also, there are other possibilities in implementing a design, as we will see in the next section. We have finished working on the addern project, so close the project. 7

Figure D.14. Specification of the desired device. Figure D.15. The worst-case delay for the implementation of section D.1.4. D.2 Using an LPM Module In section 5.5.1 we discuss how an adder circuit can be implemented by using the lpm add sub module in the library of parameterized modules (LPM). In this section we compare the adder circuit produced by the lpm add sub module to the ripple-carry adder implemented in section D.1.4. Create a new project, adder16 lpm, in the directory tutorial3\adderlpm. Choose the same FPGA chip as in section D.1.4. The easiest way to instantiate an LPM module is by means of a wizard. Select Tools MegaWizard Plug-in Manager to activate the wizard. A number of pop-up boxes will appear in which we can specify the features of the desired module. In the box shown in Figure D.16 choose to create a new variation of a megafunction, and click Next. In the pop-up box in Figure D.17 select the LPM ADD SUB module. Also, indicate that a Verilog specification is 8

needed. Let the output file be named megadd.v. (Recall that the file extension, v, will be added automatically.) Click Next. In Figure D.18, specify that a 16-bit adder circuit is required. Click Next to reach the pop-up box in Figure D.19. Indicate that both inputs can vary and click Next. In Figure D.20 specify that both carry input and output signals are needed. Observe that the wizard displays a symbol for the adder which includes the specified inputs and outputs. In the next pop-up box, in Figure D.21, decline the pipelining option. The last pop-up box is given in Figure D.22. It indicates the files generated by the wizard. Click Finish. Figure D.16. Choose to create an LPM instance. Figure D.17. Select the LPM and its Verilog specification. 9

Figure D.18. Choose the adder option and the number of bits. Figure D.19. Choose both inputs to be variable. Figure D.20. Include carry input and output connections. 10

Figure D.21. Decline the pipelining option. Figure D.22. Files generated by the wizard. The megadd file is shown in Figure D.23. (We have removed the comments to make the figure smaller.) The Verilog code that specifies the entire circuit is given in Figure D.24. It instantiates the megadd module which defines the adder circuit by referring to the desired LPM. Enter this code into a file called adder16 lpm.v. Then include both files, megadd.v and adder16 lpm.v, in the project tutorial3\adderlpm\adder16 lpm using the Add Files window presented in Figure B.5. Compile the design. A summary of the timing analysis is shown in Figure D.25. In this design, the worst-case propagation delay is 12.5 ns. Clearly, the adder implementation by means of an appropriate LPM is superior to our generic specification in Figure D.1. We may conclude that a designer should use an LPM if a suitable module exists in the library. Close the adder16 lpm project. 11

module megadd (dataa, datab, cin, result, cout); input [15:0] dataa; input [15:0] datab; input cin; output [15:0] result; output cout; wire sub wire0; wire [15:0] sub wire1; wire cout = sub wire0; wire [15:0] result = sub wire1[15:0]; lpm add sub lpm add sub component (.dataa (dataa),.datab (datab),.cin (cin),.cout (sub wire0),.result (sub wire1)); defparam lpm add sub component.lpm width = 16, lpm add sub component.lpm direction = ADD, lpm add sub component.lpm type = LPM ADD SUB, lpm add sub component.lpm hint = ONE INPUT IS CONSTANT=NO ; endmodule Figure D.23. Verilog code for the megadd module. module adder16 lpm (carryin, X, Y, S, carryout); input carryin; input [15:0] X, Y; output [15:0] S; output carryout; megadd adder circuit (.cin(carryin),.dataa(x),.datab(y),.result(s),.cout(carryout)); endmodule Figure D.24. Verilog code that instantiates the LPM adder module. D.3 Design of a Finite State Machine This example shows how to implement a sequential circuit using Quartus II. The presentation assumes that the reader is familiar with the material in Chapter 8. In section 8.1 we show a simple Moore-type finite state machine (FSM) that has one input, w, and one output, z. Whenever w is 1 for two successive clock cycles, z is set to 1. The state diagram for the FSM is given in Figure 8.3; it is reproduced in Figure D.26. Verilog code that describes the machine appears in Figure 8.29; it is reproduced in Figure D.27. Create a new project, simple, in the directory tutorial3\fsm. Create a new Text Editor file and enter the code shown in Figure D.27. Save the file with the name simple.v. 12

Reset w = 1 w = 0 A z = 0 B z = 0 w = 0 w = 0 w = 1 C z = 1 w = 1 Figure D.26. State diagram of a Moore-type FSM. module simple (Clock, Resetn, w, z); input Clock, Resetn, w; output z; reg [2:1] y, Y; parameter [2:1] A = 2 b00, B = 2 b01, C = 2 b10; // Define the next state combinational circuit always @(w or y) case (y) A: if (w) Y = B; else Y=A; B: if (w) Y = C; else Y=A; C: if (w) Y = C; else Y=A; default: Y = 2 bxx; endcase // Define the sequential block always @(negedge Resetn or posedge Clock) if (Resetn == 0) y <=A; else y <=Y; // Define output assign z = (y == C); endmodule D.3.1 Implementation in a CPLD Figure D.27. Verilog code for the FSM in Figure D.26. Select the same MAX 7000S device as in section D.1. Compile the circuit. Open the Waveform Editor and import the nodes Resetn, Clock, w, and z. These nodes are found by setting the Node Finder filter to Pins: all. We also want to 13

see the behavior of the state variables, which are implemented by means of flip-flops. To find these nodes, set the filter to Registers: post-fitting and click Start. The Node Finder displays two nodes, as shown in Figure D.28. Import both of these nodes into the Waveform Editor. Set the total simulation time to 650 ns and set the grid size to 25 ns. Set Resetn =0during the first 50 ns, and then set Resetn =1. To enter the waveform for the clock signal, click on the name of the Clock waveform in the Waveform Editor display. With the signal highlighted, click on the Overwrite Clock icon in the toolbar (the icon depicts a clock). This causes the pop-up window in Figure D.29 to appear. Set the clock period to be 50 ns, make sure that the phase is 0 and the duty cycle is 50 percent, and click OK. The defined clock signal is now displayed in the Waveform Editor window, as depicted in Figure D.30. Next, draw the waveform for w as indicated in the figure. Save the file, under the name simple.vwf. Run the Timing Simulator to get the result shown in Figure D.31. Figure D.28. Nodes that represent the state variables. Figure D.29. Setting the Clock input. Figure D.30. Input test vectors. 14

Figure D.31. Timing simulation waveforms. Figure D.32. Summary of the timing analysis for the FSM circuit. The FSM behaves correctly, setting z =1in each clock cycle for which w =1in the preceding two clock cycles. Examine the timing delays in the circuit, using the reference line in the Waveform Editor. Observe that changes in the FSM s state occur 2.5 ns after an active clock edge and that 4.5 ns are needed to change the value of the z output. Open the Timing Analyzer summary in the compilation report, which is displayed in Figure D.32. The first row indicates that the maximum frequency, fmax, at which the synthesized circuit can operate is 125 MHz. This is a useful indicator of performance. As mentioned in section D.1.3, the fmax is determined by the longest propagation delay between two registers (or flip-flops). The figure also shows the values of some other timing parameters. The worstcase flip-flop setup time, tsu, and hold time, th, are given. The parameter tco indicates the time elapsed from an active edge of the clock signal until an output signal is produced at an output pin. This delay is 4.5 ns for the z output, which is what we also observed in the waveforms in Figure D.31. Note that the states of this FSM are implemented using two state variables. The Verilog code in Figure D.27 specified the present state variables as y[1] and y[2]. However, Quartus II gave the names y 8 and y 9 to these variables, as we discovered when using the Node Finder. Quartus II uses the names of all inputs and outputs as given in the Verilog code, but it may choose fairly arbitrary names for internal connections. Two or more binary signals can be combined into a group (corresponding to a vector in Verilog terminology) of signals that can be referred to by a single name. Open the simple.vwf file and select the y 8 and y 9 simultaneously, so that their waveforms are highlighted. Select Edit Group to reach the pop-up box in Figure D.33. Type y as the group name, choose unsigned decimal as the radix, and click OK. This causes y to be used, instead of y 8 and y 9, in the file simple.vwf. Perform timing simulation to get the result in Figure D.34. Now, the FSM states are represented by the values of the vector y. 15

Figure D.33. Grouping of signals. Figure D.34. Waveform displayed as a vector y. D.3.2 Implementation in an FPGA In section 8.8 we said that when implementing an FSM in an FPGA, a good strategy is to use one-hot encoding, with one state variable assigned to each state. Although our simple FSM has only three states we can use it to illustrate the general idea. Using a one-hot code would give A = 100,B = 010, and C = 001. In PLDs, flip-flops usually have clear inputs but they do not have preset inputs. It is convenient to invert the left-most bit in the state codes so that the reset state is A = 000, while the other two states are B = 110, and C = 101. The reader is encouraged to modify the Verilog code in Figure D.27 to extend the signals y and Y to have three bits and to change the state codes as described above. Choose the same device as in section D.1.4, compile the code, examine the equations generated in the report file, and perform a timing simulation for the implementation in the FPGA chip. D.4 Concluding Remarks In Tutorials 1, 2, and 3, we have introduced many of the most important features of Quartus II. However, many other features are available. The reader can learn about the more advanced capabilities of the CAD system by exploring the various commands and on-line help provided in each application. 16