DE2 Electronic Keyboard ReadMeFirst

Similar documents
Introduction to the Synthesizer ReadMeFirst

Introduction to VHDL Design on Quartus II and DE2 Board

The Simon State Machine Part 1

Lab 2 EECE473 Computer Organization & Architecture University of Maine

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

2 nd Year Laboratory. Experiment: FPGA Design with Verilog. Department of Electrical & Electronic Engineering. Imperial College London.

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

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

EET 1131 Lab #7 Arithmetic Circuits

NIOS CPU Based Embedded Computer System on Programmable Chip

CSC258H: Logisim-Evolution Reference

University of California, Davis Department of Electrical and Computer Engineering. Lab 1: Implementing Combinational Logic in the MAX10 FPGA

FPGA Introductory Tutorial: Part 1

Tutorial on Quartus II Introduction Using Verilog Code

NOTE: This tutorial contains many large illustrations. Page breaks have been added to keep images on the same page as the step that they represent.

Tutorial for Altera DE1 and Quartus II

Laboratory Exercise 8

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 7: VHDL and DE2 Board. Name: Date:

Tutorial on Quartus II Introduction Using Schematic Designs

Audio Controller i. Audio Controller

Lab 5: Introduction to the Synthesizer

CSCB58 - Lab 0. Intro to The Lab & The DE2 Board. Prelab /4 Part I (in-lab) /1 Part II (in-lab) /1

Terasic DE0 Field Programmable Gate Array (FPGA) Development Board

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

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

Altera Quartus II Tutorial ECE 552

Lab 6: Integrated the Decoder with Muti-bit Counter and Programming a FPGA

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

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

Laboratory Exercise 1

SOPC LAB1. I. Introduction. II. Lab contents. 4-bit count up counter. Advanced VLSI Due Wednesday, 01/08/2003

ENEE245 Digital Circuits and Systems Lab Manual

8. Best Practices for Incremental Compilation Partitions and Floorplan Assignments

Lab 3: Standard Combinational Components

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

Laboratory 4 Design a Muti-bit Counter and Programming a FPGA

PRELAB! Read the entire lab, and complete the prelab questions (Q1- Q3) on the answer sheet before coming to the laboratory.

Introduction to the Altera SOPC Builder Using Verilog Design

Xilinx ChipScope ICON/VIO/ILA Tutorial

Best Practices for Incremental Compilation Partitions and Floorplan Assignments

ENEE245 Digital Circuits and Systems Lab Manual

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

4.1 Design Concept Demonstration for Altera DE2-115 FPGA Board Demonstration for Cyclone III Development Board...

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

Laboratory 4 Design a Muti-bit Counter

Lab 2: Barrel Shifter Design

EXPERIMENT NUMBER 7 HIERARCHICAL DESIGN OF A FOUR BIT ADDER (EDA-2)

Quartus II Introduction Using Verilog Design

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

TUTORIAL #2 HIERARCHICAL DESIGNS AND TEST FIXTURES

INTRODUCTION TO DE2 SYSTEM INTERFACES

QUARTUS II Altera Corporation

TLL5000 Electronic System Design Base Module. Getting Started Guide, Ver 3.4

ECE 353 Lab 3. MIDI Note Number Display. Lab Info. Electrical and Computer Engineering

Name EGR 2131 Lab #6 Number Representation and Arithmetic Circuits

CPLD board datasheet EB

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

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

CPEN 230L: Introduction to Digital Logic Laboratory Lab 7: Multiplexers, Decoders, and Seven Segment Displays

CSE P567 - Winter 2010 Lab 1 Introduction to FGPA CAD Tools

EE 101 Lab 5 Fast Adders

SCHEMATIC DESIGN IN QUARTUS

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

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

NIOS CPU Based Embedded Computer System on Programmable Chip

LAB#2 ( Due Date & Time: See course web page )

PRELAB! Read the entire lab, and complete the prelab questions (Q1-Q3) on the answer sheet before coming to the laboratory.

Quartus II Introduction Using Schematic Design

Engineering 1630 Fall Simulating XC9572XL s on the ENGN1630 CPLD-II Board

NIOS CPU Based Embedded Computer System on Programmable Chip

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science. EECS 150 Spring 2000

To design a 4-bit ALU To experimentally check the operation of the ALU

TLL5000 Electronic System Design Base Module

Verilog Design Entry, Synthesis, and Behavioral Simulation

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

ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW

Xilinx Schematic Entry Tutorial

Engineering 303 Digital Logic Design Spring 2017

Start Active-HDL. Create a new workspace TUTORIAL #1 CREATING AND SIMULATING SIMPLE SCHEMATICS

University of Hawaii EE 361L. Getting Started with Spartan 3E Digilent Basys2 Board. Lab 4.1

EKT 422/4 COMPUTER ARCHITECTURE. MINI PROJECT : Design of an Arithmetic Logic Unit

EMT1250 LABORATORY EXPERIMENT. EXPERIMENT # 10: Implementing Binary Adders. Name: Date:

MicroTally/WinTally Manual. Introduction

LESSON PLAN FOR INFORMATION & COMMUNICATION TECHNOLOGY (ICT) PRATOMSUKSA 6

Lab 2: Introduction to Verilog HDL and Quartus

Laboratory Exercise 7

EE 367 Logic Design Lab #1 Introduction to Xilinx ISE and the ML40X Eval Board Date: 1/21/09 Due: 1/28/09

ECE 437 Computer Architecture and Organization Lab 6: Programming RAM and ROM Due: Thursday, November 3

SFWR ENG 2DA4 Lab 1. Announcements: Marking Scheme: Lab Safety Manual:

Chapter 2: Hardware Design Flow Using Verilog in Quartus II

and 32 bit for 32 bit. If you don t pay attention to this, there will be unexpected behavior in the ISE software and thing may not work properly!

Experiment VERI: FPGA Design with Verilog (Part 1)

Hardware/Software Codesign for Wireless Systems (E168b) Lab 2: GPS Correlator

ECE241 - Digital Systems

CPLD board datasheet EB

ECE241 - Digital Systems. University of Toronto. Lab #2 - Fall Introduction Computer-Aided Design Software, the DE2 Board and Simple Logic

EXPERIMENT 1. INTRODUCTION TO ALTERA

The simplest form of storage is a register file. All microprocessors have register files, which are known as registers in the architectural context.

Transcription:

DE2 Electronic Keyboard ReadMeFirst Lab Summary: In this lab, you will implement a two-tone electronic keyboard using the waveform synthesizer design from the previous lab. This lab is divided into two projects. In the first, you will make a single channel keyboard. In the second project, you will use hierarchy to add another channel to the circuit. Once you build the first channel and understand how it works, adding the second channel is relatively simple. Lab Background: In the last lab you transformed the DE2 Board into a signal generator. Now you will transform the DE2 Board into an electronic piano. In Part 1 of the lab, you will make a single channel keyboard. You will be given a keyboard with a PS/2 interface that will be re-mapped to play the desired notes. You are provided with a Verilog file (PS2_KEYBOARD.v) that will read the input from the PS2 keyboard and output a keycode. When you press one key, the first channel will play the note. When you hold one key and press another key, the second channel will play the note. In the next lab this feature will be used to make harmony parts in an automated play design. The codes from the PS/2 keyboard are mapped to frequencies according to the chart below. The chart below shows the music notes associated with each frequency and key code. The Hex codes associated with each key press are indicated in this chart.

Lab Preparation Although there are no videos this week, you should take time to re-familiarize themselves with the previous lab. Supplies: Speaker x 1 DE2 Board x 1 USB Blaster Cable x 1 PS/2 Keyboard x 1 Coaxial Cable x 1 BNC Connector x 1 Dual RCA to 3.5 mm Cable x 1

Part 1: Single Channel Electronic Keyboard The single channel keyboard is based on the synthesizer with 32-bit P values. The CODEC will be used to output the wave to the speaker. Use switch 0 (SW[0]) on the DE2 board to turn the channel on and off. Use the PS/2 keyboard to play notes. The necessary connections are illustrated below

Procedure: 1) Begin by reopening the synthesizer project you used for Lab 5 Part 2. 2) If the project does not already have all of the following files, download the Lab 6 files, copy each one to your project folder, and ADD them to your project: PS2_KEYBOARD.v freq_map_new.mif brass.mif DE2_115_pin_assignments.csv 3) Although the pin assignment file has been copied and added, you will still need to import the pin assignments as the final step. 4) Create a symbol file called PS2_KEYBOARD from the PS2_KEYBOARD.v included in the project. 5) Construct the first portion of your circuit shown below. The LEDs are attached to verify that the key presses are being detected. LEDG[7..0] are the green LEDs. Figure 1: Keyboard Decoder a) Use the CLOCK_50 from the input pin to the CODEC b) Make sure to use a BIDIRECTIONAL pin for the ps2_dat line. c) The Key[0] will allow you to reset the key code decoder if and when it hangs execution. This switch is the round black membrane switch on the lower right hand side of the DE2 board. 6) Compile and program the board NOTE!! : The PS2 Keyboard MUST be connected to the DE2 board when downloading the FPGA program, or the keyboard WILL NOT WORK (Bizarre but true!)

Checkpoint 1: Demonstrate your keyboard decoder to the lab monitor. The LEDs should read 11110000 when no key is pressed, and change when the key codes are sent. 7) Keep only the 32-bit version of the synthesizer. 6) Next you will add a circuit that will allow you to turn the keyboard off and on. Add an lpm_mux 2 channel multiplexer shown below to switch between the keyboard codes coming from the PS2_KEYBOARD block, and a grounded input bus. Connect Switch 0 to the select line of the multiplexer. ******************************************************************************* NOTE: The switch (SW[0]) in the diagram above is connected using a bus. This will cause errors. Use a wire instead. ******************************************************************************* 7) Add an lpm_rom for the frequency map file Freq_map.mif.

The output of the lpm_rom containing the Freq_map.mif will replace lpm_constant module in the Synthesizer block. The keyboard codes are used as an address input to the lpm_rom which replaces the to P values. The ROM contains values for the correct frequencies of the musical tones. The frequencies have already been converted to P values inside the ROM look-up-table for you, so the sampling frequency and width of the data is already taken into account. You are provided the file Freq_map.mif file for this ROM in the Lab 6 file folder. Freq_map.mif has 2^8 words and a width of 32 data bits. Remember to enable the Memory Editor for the lpm_rom. This will come in handy if you have to troubleshoot the project. ******************************************************************************* NOTE: Giving your lpm modules meaningful names also helps you remember their function. It is also helpful to label buses and wires using functional names. Remember to NOT create components in separate directories. This will usually result in errors that very difficult to resolve and often result in redoing large portions, if not all, of your project. ******************************************************************************* 8) Now connect the output of the lpm_rom containing the Freq_map.mif to the input of the lpm_add_sub of your 32-bit synthesizer circuit from last week. Obviously, you can delete the P value lpm_constant. 9) Replace the sine wave.mif file in the synthesizer from last week with the brass.mif file provided for this lab. This waveform gives a more musical quality to the tone. Once you have everything connected, you should have the following path in your schematic: PS2_KEYBOARD block -> Channel Ctrl Multiplexer -> Freq Map Lookup Table - > Synthesizer (brass.mif) -> adc2dac block -> Line Out ************************************************************************ NOTE: A bug in your design can be identified by connecting the LED array to different bus lines in this path to verify that the data is changing whenever a key is pressed. Generally, a bad module will cause everything downstream to malfunction. This technique should help you narrow down the location of the error. ************************************************************************ 10) Next, divide the signal strength of the channel by 8 by bit shifting the output of the synthesizer by 4 bits (a factor of 16) as shown in the following diagram.

******************************************************************************** NOTE: PLEASE perform the bit shifting to reduce your volume (you will overdrive the speakers and possibly damage them otherwise). I also think my ears are bleeding if you don't do this. ******************************************************************************** 12) If you haven't already, connect the provided keyboard to the PS/2 port Do this BEFORE Compiling and Programming the board. You may connect the speaker to the Line Out audio port, but LEAVE IT OFF. 13) Compile and program your design onto the DE2. 14) Turn on the speaker. If you get a horrible screech, your software is not working. Please turn off your speaker. Otherwise... 15) Set SW[0] up to activate 'Keyboard Mode'. Pressing keys on the keyboard should now generate different notes (Refer to the keyboard layout in the Background section). Checkpoint 2: Demonstrate your working Single-Channel Keyboard Synthesizer to the lab monitor.

Part 2: Dual-Channel Keyboard Now, you will add a second channel to your circuit. This allows you to play two keys simultaneously and generate harmony. Rather than rebuilding an entire channel, use hierarchy in your design. NOTE!!! : Make a copy of your working project or an archive before continuing. This is where things often go irreversibly wrong, and you DEFINATELY want the working single channel design to go back to and try again. Procedure: 1) Copy everything between the PS/2 block and the CODEC (DE2_i2Sound) block into a new schematic sheet and name it Channel. You can delete the LED output pins. 2) Create and connect off page pins for all signals that enter or exit the Channel schematic. Add input pins for the key_code[7..0], the switch (SW[0]), and AUD_DACLRCK and output pins for the synthesizer (wave[15..0]). 3) With the Channel diagram open, create a symbol block by selecting File->Create/Update-> Create Symbol File for Current File. Substitute the created block in your top level schematic as shown below. Figure 4: Single Channel Synthesizer with Hierarchy Checkpoint 3: Demonstrate that your Single-Channel Keyboard Synthesizer STILL works after substituting the Channel block.

4) Conduct the following steps to create a second synthesizer channel. You will have to replace the lpm_roms in the second channel. If you follow these steps you will only have to do it once. If you perform these steps incorrectly, this process can become an endless loop of frustration and misery! : a. Save the Channel.bdf schematic as another schematic called Channel2.bdf b. Replace the frequency map rom (lpm_rom0) with a new lpm_rom. Verify that Quartus has assigned in incremental name (lpm_rom2, e.g.). Add the same freq_map_new.mif file to the rom. c. Replace the rom containing the brass.mif file (lpm_rom1) with a new rom, lpm_rom3 and configure it with the same parameters and brass.mif file. d. Verify that your Channel2.bdf file looks like the following schematic before creating the block: Figure 5: Channel2 Schematic used to Generate a Block Symbol e. Now create a symbol called Channel2 from the modified Channel2.bdf schematic 5) Add a second block for your second channel by inserting the Channel2 symbol in the top level (CODEC) schematic. (makes sense, right?). 6) Connect the Channel2 key_code[7..0] to key2_code[7..0] on the PS2_KEYBOARD block. You can use the red LEDs with an output pin named LEDR[7..0] to verify the channel 2 key codes are working independently. 7) Connect the signal AUD_DACLRCLK to clock input, NOT clock_50. 8) Use SW[1] to enable in order to enable / disable the output of your second channel. If you use SW[0], you cannot turn the channels off and on independently. 9) Next you need to sum the outputs of the two channels together. In order to preserve the volume, you would normally divide each channel by 2 before adding them together. Since you already bit shifted to reduce the volume, this was already taken into account.

The total number of bit shifts should be 4 (divide by 16, as shown in the following diagram from inside each of the Channel blocks). Please verify that you did this back in set 10) of Part1. Figure 6: Bit shifting by 4 bits is sufficient for both volume reduction and dividing by 2 prior to summing the two channels together. *********************************************************************************** NOTE: The OUTPUT pin name AUTOMATICALLY matches the pin name on your CHANNEL block when you create it. HOWEVER, the internal bus name that you are bit shifting MUST BE A DIFFERENT NAME, or the compiler will optimize the bit shifting out of the design. In other words, the bus between q[15..0] and the OUTPUT (output[15..0]), cannot both be named output[15..0] or q[15..0]. If they were, everything in between would be disregarded. The intermediate bus name of w[15..0] allows for the bit shift by 4 because the output[15..0] can be assigned as w[15],w[15],w[15],w[15],w[15..4]. *********************************************************************************** 10) Use an lpm_add_sub in the top level schematic to add the outputs of the two channel blocks together. Connect the resulting sum to both audio_outl and audio_outr. You will need to rename the output bus going to the CODEC since it now comes from the lpm_add_sub module output instead of a single channel. If you don't, only one channel will work.

Figure 7: Dual Channel Synthesizer with Hierarchy 11) Recompile and reprogramming the DE2. You should now be able to play two notes simultaneously when SW[0] and SW[1] are in the up position. Checkpoint 4: Demonstrate your working Dual-Channel Keyboard Synthesizer to the lab monitor. What a Rock Star! Checkpoint 5: Clean-up your workspace ************************************************************************* NOTE: You will be using the Keyboard Lab as a starting point in your next lab. Make sure all members of the group have access to a copy of the project. You can use Project->Archive Project to create easy-to-share Quartus II Archive Files (.qar). ************************************************************************* Discussion Questions: Topic 1: How do you verify that the circuit is receiving key codes from the keyboard other than hearing the sound from the speaker? Topic 2: What is the purpose of the Freq Map Lookup Table? Topic 3: How are the two cords merged into a single sound heard on the speaker?