Lab 4 - EE-313 VECTORS AND MORE Rev 01/30/2013 I. Purpose: A. Reinforce the skill necessary to implement a functional logic design. B. Introduce VECTOR data types and the WITH/SELECT/WHEN and WHEN/ELSE statements. II. Equipment: A. Computer with Altera Software and web access B. Altera DE2 Board with power supply and USB cable III. Pre-lab assignment: A. Complete BCD to 7 Segment Display Driver Design and record equations in your lab notebook. IV. Lab Procedure and Questions: In this project, you will create a BCD to 7 segment display driver using VHDL and then test it using by incorporating it into a test schematic. The project must meet the following design requirements. BCD to Seven Segment Display Driver Requirements PROJECT NAME: yourlastname_lab04 ENTITY NAME yourlastname_bcd2seven FUNCTION Drive an active high seven segment display given a 4 bit BCD number. NAME TYPE SIZE STD_LOGIC_VECTOR 4 Bits INPUT x STD_LOGIC 1 Bit Each OUTPUTS a,b,c,d,e,f,g ENTITY NAME yourlastname_lab04 FUNCTION Connect your bcd2seven entity to sw[3] through sw[0] and display the corresponding decimal value on one of the ALTERA boards 7 segment displays. NAME TYPE SIZE Input pin INPUT sw[3 downto 0] OUTPUTS ledr[3 downto 0] Output pins hex0[7 downto 0] Output pins NOTES Output pins hex0[7 downto 0] should be connected to the corresponding outputs of the BCD 2 Seven Segment Display Driver. The LEDs of the seven segment displays are Active LOW. Design Segment Labels DE2 Segment Labels Lab 4 - EE-313 VECTORS AND MORE Rev 01/30/2013 A New Datatype STD_LOGIC_VECTOR The STD_LOGIC_VECTOR expands the STD_LOGIC datatype so that bits can be grouped together in a meaningful way. Line 6 of the sample code illustrates how to define an input variable of type STD_LOGIC_VECTOR. This definition prevents having to define 4 separate input ports x3, x2, x1, and x0. Additionally, it allows VHDL to treat the signal as a complete unit thus allowing statements like that shown on Line 15. If you want to access the individual elements of the STD_LOGIC VECTOR, you can simply by referencing the desired bit as shown on Line 23 of the sample code. Two New Statements The WHEN/ELSE and WITH/SELECT/WHEN statements allow you to specify your logic in a format similar to a truth table. Each essentially assigns a value to the target when a particular condition exists. Line 15 of the sample code is one example of how to use the WHEN/ELSE statement. Lines 18 through 21 show an example of the WITH/SELECT/WHEN statement. WHEN/ELSE Statement Syntax: The conditions in a WHEN/ELSE statement are prioritized. The first output statement listed has the highest priority and will be executed first, if the condition is true. If the first condition is not true, the second output statement will be executed next, and so on. WITH/SELECT/WHEN Statement Syntax: Commas are used in a WITH/SELECT/WHEN statement WHEN OTHERS must be used to terminate a WITH/SELECT/WHEN The selected signal assignment (WITH/SELECT/WHEN) examines the value of the expression and executes only the assignment statement that matches the WHEN value, and all other statements are skipped. WHEN OTHERS is required to terminate a WITH/SELECT/WHEN statement. This is used to ensure that all possible choices of the expression are considered. Note the use of commas in the syntax for the WITH/SELECT/WHEN statement. Lab 4 - EE-313 VECTORS AND MORE Rev 01/30/2013 Figure 1 – Sample Code A. Create a new project B. Implement the bcd2seven entity such that it meets the design requirements using the Sample Code as a starting point. In order to implement outputs d through g, you can use any of the three methods shown. Note: You can check for syntax errors while you go by selecting Processing→Analyze Current File. C. Create a Symbol File for your new entity. D. Implement the lab04 top level entity using a block diagram/schematic such that it meets the design requirements. NOTE: When assigning the input pin to your device, only one pin is required. It should be named sw[3..0] and it should be connected to input x using the Orthogonal Bus Tool. E. Program your Altera board and demonstrate its proper performance to the Instructor. F. Include a print out of your bcd2seven entity from the RTL Viewer in your lab notebook. G. Questions 1. 2. 3. 4. What questions did you ask the instructor while performing this lab? What were the answers to the questions asked? What character is displayed on your 7 segment display when X=”1111”? Identify the order of execution for your code if any.