Starting from:

$30

Lab #2 VHDL for a simple circuit

ECE 380: Lab #2
Part I. VHDL for a simple circuit
The objective of this practice is to generate and simulate (test) different type of design for a simple
combinational logic. Please use three individual projects for the following tasks.
a b c f
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0
Design A: Write a VHDL model (entity and architecture) to describe the logic specify by the above truth
table. Describe the circuit with AND, OR, NOT in your architecture body.
- Create a project using VHDL, following lab 01 related steps.
- Test your design using functional simulations. You need to generate all the combinations for
those three inputs, i.e., 000, 001, 010, …,111.
- With a ready VHDL code, compile (short-cut key, Ctrl+K).
- Generate waveform simulations. Follow the same procedure in lab 1 to open .vwf file. List all the
input (A, B, C), and output (f) nodes and insert them in the waveform editor. Since there are 3
inputs, number of possible inputs are 23
=8.
- Select the signal you want to edit in the waveform editor
- Click the icon “overwrite clock” on the toolbar
- Set the period of signal and click OK. A clock waveform will be generated in the waveform editor
- Set the period of signals A, B and C to 20, 40, and 80 ns respectively. Set the end time to 160 ns.
- Run functional simulations to generate the output waveform and save the screenshot of .vwf
showing all the inputs and output.
Note: Similar tutorial materials can be found in Introduction to Simulation of VHDL Designs,
supplement_quartusii_simulation_vhdl.pdf, in lab 01.
Design B: Create a schematic based on the NOR gate implementation.
- Test/simulate this design.
- Open .vwf and insert the clock signals for A, B, and C inputs as in Designs A and B.
- Perform functional simulations.
- Compare the generated output waveform with those from Designs A and B. 
Part II. Generate a flashing LED
In this part, you are asked to follow a simple design and upload the design to the Altera’s DE1 board. This
simple design drives a LED flashing at a rate of one second.
The DE1 board provides 50 MHz clock signals. To generate the required one-second period clock, you need
to use a multi-bit counter, which can be implemented by a library module LPM_COUNTER, in Quartus II, to
divide the onboard 50 MHz clock. The customized LPM_COUNTER uses 26 bits can count from 0 to
50,000-1. The counter reduces the frequency of the 50 MHz clock signal and its output behaves as a clock
signal changing at the rate of one second.
Requirement: Demonstrate a LED flashing at 1 second rate.
Step 1: Create a new project named frequency. Under the project, create a new BDF file and save the file as
frequency.bdf.
Step 2: Configure lpm_conter and draw the schematics
- Go to Library  Arithmetics  lpm_Counter
When you click on lpm_counter, a dialogue window “Save IP variation” appears as below:
Save it under the project ‘frequency’ as lpm_counter1(C:\altera\16.0\quartus\frequency\lpm-counter1). Make
sure you save it as VHDL and click OK.
After clicking OK, MegaWizard Plug-in manager appears where parameters of the counter can be changed. It
goes through the following six steps:
1. Change the number of bits to 26, click Next. 
2. Insert 50,000,000 as modulus with a count modulus, click Next.
3. Click Next.
4. Click Next.
5. Select the type of files you want Quartus II to generate. Select “VHDL component declaration
file”, “symbol file” and then click Finish.
6. After that, click Yes to add lpm_counter1 file to the existing projects.
Once added, lpm_counter1 can be found in the symbol tool and can be dragged on the block editor.
Step3: With lpm_counter1 in the block editor, fetch an Input pin, connect it with lpm_conter1, and name the
pin as Clock. Connect the wire on the output side and double click the wire to highlight it into blue. The
highlighted blue indicates that the wire can be named. Name it as q[25..0]. Further, name the output pin as
q[25].
Step 3: Save and compile the project.
Step 4: Pin assignment. After the project is successfully compiled, assign the DE1 pins to both input and
output of your design.
Click on pin planner and the following image appears.
View of DE 1 board before assigning pins
Click on location and type in PIN_AF14 to assign pin to clock signal (input) and type in PIN_V16 to assign
q[25] (output).
Pin Planner 
The details of PIN numbers of clock input signal (Page 20) and output (Page 24) can be found in DE1 board
manual (distributed along this lab document).
View of DE 1 board after assigning pins
Step 5: Compile again and upload the program to DE 1 board
- Switch ON the DE1 Board using the red button
- In Quartus II, go to Tools- Programmer Hardware Setup-select ‘DE-SoC’
- Make sure Mode is ‘JTAG’
- Click auto-detect
- Select 5CSEMA
- Right click on 5CSEMA5-add file-output files-select the frequency.sof file (in output files of
the directory)
- Click on the Program/Configure checkbox on the 5CSEMA5 line
- Click ‘Start’.
- At this point, your program has been transferred to the DE1 board. You should see the LED flashing
on DE1 Board. 
You can also follow the youtube link for the implementation:
https://www.youtube.com/watch?v=sbUAJByFb30
Note that our Quartus II version is different from the one from the video. You should adjust accordingly,
based on the instructions provided above.
Write the Lab Report: Please follow the sample report format as in Lab 01 and do the following in the lab
report:
• Print the source codes/schematics (make sure it is well commented) for Part I and the schematics
for Part II.
• Provide waveforms for all designs in Part I.
• Mark the printouts to show each test case for Part I.
• Explain your test procedures for Part I and Part II. 
Print this page, bring the hardcopy to your lab session, get it signed by the TA after the demo, and
submit it along with your report
Lab demo (50 pts) Score TA initial
Part I (Designs A, B), 25 pts
Report (50 pts)
Lab 2 Total Grade (100 pts)
Bonus: Quartus Prime Installation (25 pts)
(Note: You only get one time 25 pts, not both
times)
HW #2 (100 points)
1) (30 pts) Use two types of methods, algebraic manipulation and truth tables, to prove the following
Boolean statements.
a) ( , ) = ∏ (0, 3) = ∑ (1, 2) f x1 x2 M m (Note these are two input functions)
b) 𝑥𝑥̅𝑦𝑦𝑦𝑦 + 𝑥𝑥𝑦𝑦�𝑧𝑧 + 𝑥𝑥𝑥𝑥𝑧𝑧̅+ 𝑥𝑥𝑥𝑥𝑥𝑥 = 𝑥𝑥𝑥𝑥 + 𝑦𝑦𝑦𝑦 + 𝑥𝑥𝑥𝑥
c) 1 2 3 f (x , x ) = ∑m(0,1,2) =M (Assume that the minterms and maxterms are for the two input functions).
2) (10 pts) Draw two types of the AND-OR schematic for the following function: 𝑓𝑓(𝑥𝑥, 𝑦𝑦, 𝑧𝑧) = ∏ 𝑀𝑀(0, 3, 6);
a) Product-Of-Sums (POSs) form, or the maxterm form. b) Sum-Of-Products (SOPs) form, or a minterm
form.
3) (60 pts) For the logic function,
𝑌𝑌 = (𝐴𝐴 + 𝐶𝐶̅
)(𝐴𝐴 + 𝐵𝐵� + 𝐶𝐶)(𝐴𝐴̅+ 𝐵𝐵 + 𝐶𝐶)
a) Develop a truth table for the following standard POS expressions:
b) Based on the truth table developed, draw the schematic using NAND gates only
c) Based on the truth table developed, draw the schematic using NOR gates only

More products