510 likes | 627 Views
Advanced Digital Circuits ECET 146 Week 4. Professor Iskandar Hack ET 205B, 481-5733 hack@ipfw.edu. This Week’s Goals. Introduction to VHDL Designing a Combinational Circuit from a Truth Table using a Case structure in VHDL Implementing a Truth Table in VHDL using a Case a Select structure.
E N D
Advanced Digital CircuitsECET 146Week 4 Professor Iskandar Hack ET 205B, 481-5733 hack@ipfw.edu
This Week’s Goals • Introduction to VHDL • Designing a Combinational Circuit from a Truth Table using a Case structure in VHDL • Implementing a Truth Table in VHDL using a Case a Select structure
Introduction to VHDL • VHSIC* Hardware Description Language (VHDL) is a way of describing the function of a digital circuit (in other words, describing what it does) in a text format. • VHDL is, in part, an alternative to the traditional “schematic diagram” or logic diagram description of digital circuit functionality. • VHDL is NOT a programming language!!! Programming languages are inherently sequential. One operation is executed, then the next, and the next, and so on. • VHDL can and usually does include operations which execute concurrently or simultaneously, as do logic circuits. . *VHSIC is an acronym from the early 1980s. It stood for “Very High Speed Integrated Circuit”, but is hardly ever seen or heard nowadays. Others claimed it stood for Very Huge Sums of Infused Case because of DOD spend on the development.
Introduction to VHDL • VHDL may be written in such a way that VHDL code can be automatically translated into hardware by a process called logic synthesis. • VHDL code which is written in such a way as to support logic synthesis is called synthesizable VHDL. • Certain structures must be avoided if code is intended to be synthesizable. For example, the statement “a = a + 1”, which is a common structure in software languages, must be avoided in VHDL if it is to be synthesizable. • Non-synthesizable code is supported, and is used for things like test benches.
Some Simple VHDL Code: • First, a couple of formalities. The VHDL source file has to begin with a library clause, listing the libraries which are to be used. • This is normally followed by one or more use clauses, which identify the specific library units to be used from the libraries listed in the library clause • For our example, which will implement a truth table, the library clause and use clauses look like this:
Some Simple VHDL Code • Notice that each of these two lines ends with a semicolon. Most lines of code end with semicolons. • The most common coding error is omission of the semicolon at the end of a line of code. • The next thing to add is one or more enitity declarations. • An entity is a black box, with inputs and outputs. • Inputs and outputs are defined as ports. • The entity declaration says nothing about what the entity does.
Some Simple VHDL Code • You may visualize our entity, a four-input, one-output combinatorial logic block implementing a truth table, like this: A(3) A(2) D TruthTable A(1) A(0) • The four inputs are shown as four bits of a four-bit input vector A. A(3) is the most-significant bit (MSB), A(0) is the least-significant bit (LSB).
Some Simple VHDL Code • After adding the entity declaration, our source file looks like this: • Notice how the Port statement is indented, and how a blank line is left between the use clause and the entity declaration. These are examples of coding style, which is used to make code more readable. It is good practice, and is often required by an employer, customer or client. • We still haven’t defined what the entity actually does. That comes next, in the architecture body.
Some Simple VHDL Code • The simplest architecture just implements a with/select command that resembles the Table Command in AHDL : • The line following the “BEGIN” is an assignment statement. • There is a output of ‘1’ for each line of the truth table which contains a ‘1’ in the X column and ‘0’ for others.
Some Simple VHDL Code • Here’s the entire VHDL source file:
Some Simple VHDL Code • Start Quartus II. • Select File -> New, and create a new VHDL file. Name it TruthTable.vhd, and save it in a folder named “TruthTable” on your flash drive. • Enter the source code shown in the previous slide in the file you just created, and save it. • Select File -> New Project Wizard, then click the “Next” button.
Some Simple VHDL Code • Click the “…” next to “What is the working directory for this project”, then navigate to the “TruthTable” folder you created. Click OK on the file selection dialog. The path of the TruthTable folder should appear as shown here.
Some Simple VHDL Code • Click the “…” next to “What is the name of this project”, then select “TruthTable.vhd” on the file selection dialog and click OK.
Some Simple VHDL Code • “TruthTable” should appear as the project name and as the top-leel design entity. Click the “Finish” button.
Some Simple VHDL Code • Next, open your project by selecting File-> Open Project. Navigate to your TruthTable folder, select the file TruthTable.qpf, and click the “open” button. • Add your source file, “TruthTable.vhd”, to the project by slecting Project->Add/Remove Files in Project. Click the “…” button on the “settings” dialog , then navigate to the project folder and select TruthTable.vhd. Click the “open” button on the file selection dialog, then click the “Add” button on the “settings” dialog. • Click the “OK” button on the settings dialog to dismiss the dialog.
Some Simple VHDL Code • In the Quartus II Project Navigator pane, select the “Files” tab as shown below.
Some Simple VHDL Code • Expand the “Device Design Files” folder by clicking the “+” beside it: • You should see your VHDL source file. Click on it.
Some Simple VHDL Code • Click the “start compilation button:
Some Simple VHDL Code • If you haven’t made any typing errors (like leaving out semicolons), your code should compile successfully. It could take several minutes. If the compiler finds any errors, correct them and try again.
Some Simple VHDL Code • Now, create a waveform file to provide the inputs to the design. You’ve done this in the previous lab, but here are the instructions again. • Select File->New. When the dialog appears, choose the “Other Files tab:
Some Simple VHDL Code • Select “Vector Waveform File”, and click the OK button to dismiss the dialog.
Some Simple VHDL Code • When the resulting vector waveform file, probably with the default name “Waveform1.vwf”, appears, select File->Save As and save it as “TruthTable.vwf”.
Some Simple VHDL Code • Right-click in the blank space under “Name”, and select “Insert->Insert Node or Bus”
Some Simple VHDL Code • Right-click in the blank space under “Name”, and select “Insert->Insert Node or Bus”
Some Simple VHDL Code • Click the “Node Finder” button …
Some Simple VHDL Code • The Node Finder dialog appears. Make sure the Name box contains a “*” (asterisk) and the “Filter” box contains “Pins: all” as shown, then click the List button.
Some Simple VHDL Code • The Node Finder dialog appears. Make sure the Name box contains a “*” (asterisk) and the “Filter” box contains “Pins: all” as shown, then click the List button.
Some Simple VHDL Code • The vector A appears under Nodes Found, as do each of its individual bits and the output X. Select A, and click the “>” button:
Some Simple VHDL Code • A appears under selected nodes. Select X, and click the “>” again:
Some Simple VHDL Code • You have selected all the inputs and outputs for this simple design. Click “OK” to dismiss the node finder.
Some Simple VHDL Code • You have selected all the inputs and outputs for this simple design. Click “OK” to dismiss the node finder.
Some Simple VHDL Code • Click “OK” to dismiss the “Insert Node or Bus” dialog.
Some Simple VHDL Code • A and X appear on the waveform editor.
Some Simple VHDL Code • Left-Click on A to select it, then click the “count value” button:
Some Simple VHDL Code • Left-Click on A to select it, then click the “count value” button:
Some Simple VHDL Code • On the Count Value dialog, select the Timing tab …
Some Simple VHDL Code • Make sure the Start Time is 0 and the End time is 1 microsecond. Make sure “At Absolute Times” is selected, and the “Count Every” value is 50 ns (nanoseconds). Click “OK”:
Some Simple VHDL Code • Notice that the value of A is now a hexidecimal number which increments every 50 nS until it reaches “F”, then starts over from 0. • Xout is unknown, because we haven’t run the simulator yet.
Some Simple VHDL Code • Select Processing->Simulator Tool • Make sure TruthTable.vwf is selected as the “Simulation Input”, then click the “Start Simulation” button:
Some Simple VHDL Code • If the simulator fails, correct any errors in your code and try again. • If the simulation is successful, scroll to the bottom of the simulator tool dialog and click the “Report” button.
Some Simple VHDL Code • Examine the waveforms, and decide whether you have successfully implemented the truth table. You may expand A to examine the individual bits by clicking on the “+”
Some Simple VHDL Code • Examine the waveforms, and decide whether you have successfully implemented the truth table. You may expand A to examine the individual bits by clicking on the “+”
Open the Programming Module • Select the Programmer Hot Button
Select Programming Hardware • Once the programmer is opened – hit hardware setup • Then select Add Hardware • Selected Byteblaster on LPT1:
Select Programming Options • Select Program/Configure and Verify
Program the Part • Hit the start button • You should see the progress bar move during programming. Note the run/prog switch must in the RUN postition
Verify the Design • Using the switches SW0-SW3, and LEDR0 verify your truth table
Summary • This week we covered how to design a circuit without drawing ANY schematics using the waveform editor • We also got our first look at designing a circuit by using VHDL (also without drawing schematics) • We also we reviewed how to verify a combinational logic design using the Altera hardware