music box from fpga4fun.doc

Upload: sauumye-chauhan

Post on 04-Jun-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Music Box from fpga4fun.doc

    1/11

    Reference: http://www.fpga4fun.com/Links.html

    The main FPGA vendors in the world are

    Xilinxand their University Program

    Alteraand their University Program

    Latticeand their University Program

    Actel

    QuickLogic

    Other links

    A repository of many FPGA-FAQs, created from the comp.arch.pganewsgroup.

    Lots of FPGA links on this ePanaramapage. The page has a nasty popup though.

    The opencores.orgsite, with its growing collection of pro!ects.

    Some nice conerence papers an" articlesfrom An"raka#s site, plus other nice pages like

    $ultiplication in FPGAsand %istri&ute" Arithmetic.

    The FPGA Arca"esite, with old popular games recreated in FPGAs.

    uild your own FPGA!"ased Logic Analy'er.Also from the same author, FreeP()freeware

    P# layout software.

    The Open(ollector %ata&ase,a compilation of open hardware tools $ designs.

    The Alien *laughter ++video game on an FPGA.

    $y,%L, an open source package that lets you use Python as an hardware description and

    verification language.

    The latest fun is to put a custom #P% inside an FPGA.road su"&ect. Try these links'

    The FPGA (PUwe" site, and their X*O(#P% pro&ect.

    The (% sot (PU core, a synthesi(a"le )*!"it #P% with development tools.

    A nice list of Open +Ps / Open (ores.

    The Leon-0SPA+# core.

    The 1ios-++#P%, with manypro!ectsand linksfrom the #ornell %niversity.

    http://www.xilinx.com/http://www.xilinx.com/univ/http://www.altera.com/http://www.altera.com/education/univ/http://www.latticesemi.com/http://www.latticesemi.com/http://www.latticesemi.com/support/universityprogram/http://www.actel.com/http://www.quicklogic.com/http://www.fpga-faq.com/http://groups.google.com/groups?q=comp.arch.fpgahttp://www.epanorama.net/links/fpga.htmlhttp://www.epanorama.net/links/fpga.htmlhttp://www.opencores.org/http://www.opencores.org/projects/http://www.andraka.com/papers.htmhttp://www.andraka.com/http://www.fpga-guru.com/multipli.htmhttp://www.fpga-guru.com/distribu.htmhttp://www.fpga-guru.com/distribu.htmhttp://www.fpgaarcade.com/http://minila.sourceforge.net/http://minila.sourceforge.net/http://www.freepcb.com/http://opencollector.org/summary.phphttp://opencollector.org/summary.phphttp://www.ugrad.physics.mcgill.ca/~beek/as2/http://myhdl.jandecaluwe.com/http://www.fpgacpu.org/http://www.fpgacpu.org/xsoc/cc.htmlhttp://www.tinyboot.com/cd16/index.htmhttp://www.lug-kiel.de/links/details/hdl.htmlhttp://www.gaisler.com/cms4_5_3/index.php?option=com_content&task=view&id=12&Itemid=52http://www.altera.com/products/ip/processors/nios2/ni2-index.htmlhttp://instruct1.cit.cornell.edu/courses/ece576/FinalProjects/http://instruct1.cit.cornell.edu/courses/ece576/FinalProjects/http://instruct1.cit.cornell.edu/courses/ece576/http://www.xilinx.com/univ/http://www.altera.com/http://www.altera.com/education/univ/http://www.latticesemi.com/http://www.latticesemi.com/support/universityprogram/http://www.actel.com/http://www.quicklogic.com/http://www.fpga-faq.com/http://groups.google.com/groups?q=comp.arch.fpgahttp://www.epanorama.net/links/fpga.htmlhttp://www.opencores.org/http://www.opencores.org/projects/http://www.andraka.com/papers.htmhttp://www.andraka.com/http://www.fpga-guru.com/multipli.htmhttp://www.fpga-guru.com/distribu.htmhttp://www.fpgaarcade.com/http://minila.sourceforge.net/http://www.freepcb.com/http://opencollector.org/summary.phphttp://www.ugrad.physics.mcgill.ca/~beek/as2/http://myhdl.jandecaluwe.com/http://www.fpgacpu.org/http://www.fpgacpu.org/xsoc/cc.htmlhttp://www.tinyboot.com/cd16/index.htmhttp://www.lug-kiel.de/links/details/hdl.htmlhttp://www.gaisler.com/cms4_5_3/index.php?option=com_content&task=view&id=12&Itemid=52http://www.altera.com/products/ip/processors/nios2/ni2-index.htmlhttp://instruct1.cit.cornell.edu/courses/ece576/FinalProjects/http://instruct1.cit.cornell.edu/courses/ece576/http://www.xilinx.com/
  • 8/13/2019 Music Box from fpga4fun.doc

    2/11

    Music boxere we teach our FPGA how to play sounds and music.

    -e start "y generating a single tone. Then slowly more fun stuff like producing a police siren and play

    a tune.

    ou can listen to the sound produced "y clicking on the speaker icon. For e/ample here0s the 1police

    siren1 .

    The hardware

    A Pluto "oard, a speaker and a )23 resistor are used for this pro&ect.

    A more formal representation looks like this'

    The oscillator provides a fi/ed fre4uency to the FPGA. The FPGA divides the fi/ed fre4uency to drive an

    56. The 56 is connected to a speaker through a )23 resistor. y changing the 56 fre4uency, the FPGA

    produces different sounds.

    The HDL design

    *imple &eep

    FPGAs can easily implement "inary counters. Let0s start with a )*!"its counter.Starting from the 789( clock, we can simply 1divide the clock1 using the counter. A )* "its countercounts from : to *88;8

  • 8/13/2019 Music Box from fpga4fun.doc

    3/11

    inputclkCoutputspeakerC

    >> inary counter, )*!"its wideregD)8':E counterCal2ays

  • 8/13/2019 Music Box from fpga4fun.doc

    4/11

    A""ing a parameter

    ere0s essentially the same code. A new parameter named 1clkdivider1 was added, and the counterwas changed into a 1count!down1 counter ! &ust a matter of preference.

    mo"ulemusicJJ:>7C

    regD)J':E counterCal2ays7C

    regD7;':E toneCal2ays

  • 8/13/2019 Music Box from fpga4fun.doc

    5/11

    that go down from )7K to :.To switch "etween the up!ramp and the down!ramp, we use toneD77E. As soon as the up!ramp hits)7K, we switch to the down!ramp, until it goes to :, and then "ack to the up!ramp...

    2ireD*':E ramp ?

  • 8/13/2019 Music Box from fpga4fun.doc

    6/11

    inputclkCoutputspeakerC

    regD7K':E toneCal2ays

  • 8/13/2019 Music Box from fpga4fun.doc

    7/11

    To go from one octave to the ne/t, fre4uency is multiplied "y 171. asy to do in hardware, we do thatin step J.To go from one note to the ne/t, fre4uency is multiplied "y 1).:8MJ1. Rot really easy to do inhardware. So we use a look!up ta"le with pre!calculated values.

    -e divide the main clock "y 8)7 for note A, "y J@; for note AU, "y J8* for note ... +emem"er,dividing "y a lower value gives us a higher fre4uency>higher note, that0s what we want.

    al2ays> AU>"

    7' clkdivider ? J8*!)C >> ;' clkdivider ? J;)!)C >> #J' clkdivider ? J:*!)C >> #U>B"

    8' clkdivider ? ;@J!)C >> B*' clkdivider ? ;*7!)C >> BU>"

    K' clkdivider ? ;J7!)C >> @' clkdivider ? ;7;!)C >> FM' clkdivider ? ;:J!)C >> FU>G"

    ):' clkdivider ? 7@K!)C >> G))' clkdivider ? 7K)!)C >> GU>A"

    )7' clkdivider ? :C >> should never happen );' clkdivider ? :C >> should never happen )J' clkdivider ? :C >> should never happen )8' clkdivider ? :C >> should never happenen"case

    al2ays

  • 8/13/2019 Music Box from fpga4fun.doc

    8/11

    mo"ulemusic> ;' clkdivider ? J;)!)C >> #

    J' clkdivider ? J:*!)C >> #U>B" 8' clkdivider ? ;@J!)C >> B*' clkdivider ? ;*7!)C >> BU>"

    K' clkdivider ? ;J7!)C >> @' clkdivider ? ;7;!)C >> FM' clkdivider ? ;:J!)C >> FU>G"

    ):' clkdivider ? 7@K!)C >> G))' clkdivider ? 7K)!)C >> GU>A"

    )7' clkdivider ? :C >> should never happen );' clkdivider ? :C >> should never happen

    )J' clkdivider ? :C >> should never happen )8' clkdivider ? :C >> should never happenen"case

    regD@':E counternoteCal2ays

  • 8/13/2019 Music Box from fpga4fun.doc

    9/11

    The 1divide "y )71 module takes a * "its value > and &ust do a divide "y 1;1 on the remaining "its

    case

  • 8/13/2019 Music Box from fpga4fun.doc

    10/11

    -e also want that

    the tune pauses after the +69 ends

    the 1fullnote1 of value : is a 4uiet note.

    so we change the last line of the previous design from

    al2ays

  • 8/13/2019 Music Box from fpga4fun.doc

    11/11

    *creenshot

    ere0s the view of a 7K9( signal, sampled at )::9( and reconstructed using the 1samplee4uivalent time1 techni4ue.

    Links ow to "uild a"igital oscilloscope"ased on the AB#:@:J and 6penGL

    A nice Oscilloscope FAQsite with lots of information.

    ,o2 oscilloscopes 2orkfrom )>; Precision.

    Pro&ing ,igh-*pee" %igital %esignsfrom *ignal (onsulting= +nc.

    http://glory.honour.ca/projects/Oscilloscope/Oscilloscope.htmlhttp://glory.honour.ca/projects/Oscilloscope/Oscilloscope.htmlhttp://www.qsl.net/wd1v/scopefaq/http://www.bkprecision.com/download/scope/HowScopeWork.pdfhttp://www.bkprecision.com/http://www.signalintegrity.com/Pubs/straight/probes.htmhttp://www.signalintegrity.com/http://glory.honour.ca/projects/Oscilloscope/Oscilloscope.htmlhttp://www.qsl.net/wd1v/scopefaq/http://www.bkprecision.com/download/scope/HowScopeWork.pdfhttp://www.bkprecision.com/http://www.signalintegrity.com/Pubs/straight/probes.htmhttp://www.signalintegrity.com/