NiosIIExercisesVer3.docx

上传人:b****5 文档编号:12586957 上传时间:2023-04-20 格式:DOCX 页数:71 大小:1.34MB
下载 相关 举报
NiosIIExercisesVer3.docx_第1页
第1页 / 共71页
NiosIIExercisesVer3.docx_第2页
第2页 / 共71页
NiosIIExercisesVer3.docx_第3页
第3页 / 共71页
NiosIIExercisesVer3.docx_第4页
第4页 / 共71页
NiosIIExercisesVer3.docx_第5页
第5页 / 共71页
点击查看更多>>
下载资源
资源描述

NiosIIExercisesVer3.docx

《NiosIIExercisesVer3.docx》由会员分享,可在线阅读,更多相关《NiosIIExercisesVer3.docx(71页珍藏版)》请在冰豆网上搜索。

NiosIIExercisesVer3.docx

NiosIIExercisesVer3

 

DesigningwithNiosIIandSOPCBuilder

ExerciseManual

 

 

Lab1

CreatingaNiosIISystem

_____________________________________________________________________

Note:

Forthefollowingsetoflabexercises,moredetailedstep-by-stepinstructionsareprovidedinthe“SolutionsManual”locatedatthebackofthisdocument.

_____________________________________________________________________

 

Hardwaresetuprequirements:

∙ByteBlaster,ByteBlasterII,ByteBlasterMV,orUSB-BlasterconnectedbetweencomputerandByteBlasterconnectionondevelopmentboard

∙Powersupplyconnectedtotheboard

 

1.CreateadirectoryontheCdriveofyourcomputercalled“altera_trn”ifthereisn’tonealready.Copythefilenios_II_lab_QII4.1.exetothatdirectoryanddoubleclickonit.Thiswillunzipthelabfilestoadirectorycallednios_II_lab.AmongthesefilesisthepartiallycompletedQuartusIIprojectcalledniosII_lab.qpfthatwewillusetoday.

2.StarttheQuartusIISoftware,andopenthisQuartusIIproject.

3.AssigndevicefamilyandpinoutsettingstotheQuartusIIproject:

SourceoneoftheTCLscriptsthatwehaveprovidedtoassignrelevantdevicesettingsandpinoutsfortheparticularFPGAdevelopmentboardthatyouareusing.Thatis,fromtheToolsmenuselectTclScripts,andthenfromtheprojectfolderhighlightthesetupscriptforyourdevelopmentboard(eg.Setup_Cyclone_1C20.tcl,etc.),andthenclickRun.(IfunsureofwhichscripttorunpleasecheckwhichFPGAisonyourdevelopmentboardorconsulttheworkshopco-ordinator.)ThiswillsetupyourQuartusprojectforthelabtoday.

4.Let’snowbuildourembeddedsystem!

StartSOPCBuilder,andprovidethesystemname,niosII.YoucanchooseVHDLorVerilog,dependingonwhichimplementationlanguageyouprefer.IntheSPCBuilderwindow,TargettheparticularStratixorCyclonedevelopmentboardthatyouareusingandensurethattheSystemClockFrequencyissetto50MHz.

5.AddaNiosIIProcessortoyourdesign.FortheprocessorcoreselectNiosII/s.Settheinstructioncachesizeto4kbytes.ClicktheJTAGDebugModuletab.

 

6.SelecttheJTAGTargetConnectionDownloadLevel3optionandclickFinish.Thiswillgiveusallofthedebugoptionslistedonthehighlightedtab.

7.Renametheprocessorbyrightclickingonthecurrentnameandselectingrename.Typeincpuandhitenter.

NB:

ItisimportanttoenterthenamesofanyperipheralsormemorieswithinSOPCBuilderEXACTLYasshown.ThesearereferencedbypinsettingsandC–CodeexamplesandassucharealsoCASESENSITIVE.

8.AddanIDT71V416SRAMmemorytoyourdesign.Selectamemorysizeof1024kB,andrenamethememorytoext_ram.

9.AddaFlashMemory(CommonFlashInterface)toyourdesign-choosetheAMD29LV065D-120Rpresetwithanaddresswidthof23andadatawidthof8.Renamethememorytoext_flash.

10.AddtheJTAGUARTperipheralandacceptthedefaults.IntheSimulationtabbesuretoselectCreateModelSimaliastoopenawindowshowingoutputasASCIItext,andrenametheperipheraltojtag_uart.

11.AddaPIO(ParallelI/O)withbuswidthof16bitswithdirectionsettooutputportsonly.Renamethisperipheralseven_seg_pio.

12.AddanotherPIO(ParallelI/O)withbuswidthof8bitssettooutputportsonly.Renamethisperipheralled_pio.

13.AddonemorePIO(ParllelI/O),thistimewithawidthof4bitssettoInputportsonly.Renamethisperipheralbutton_pio.

14.AddanIntervalTimerfromtheOthersectioninthelistofSOPCBuilderperipherals.Acceptthedefaults,andrenamethetimertosys_clk_timer.

15.AddanotherIntervalTimer,butthistimechangetheperiodtousec.Renamethetimertohigh_res_timer.(Wearegoingtousethislaterwhenwetimethespeedofsomeofoursoftwarefunctions.)

16.NowaddaSystemIDPeripheralfromtheOthersection.

17.AddanAvalonTri-StateBridge,beingsuretosettheRegisteredoption.Renametheperipheralext_ram_bus.

18.ToensurethatallbaseaddressesarevalidselectAuto-AssignBaseAddresses.

 

19.NowsettheResetandExceptionAddressesoftheCPUontheMore“cpu”Settingspage:

Chooseext_flashfortheResetAddressandext_ramfortheExceptionAddress.Also,UnchecktheSimulationcheckbox.Thiswillspeedupsystemgeneration.

Yoursystemshouldlooklikethis:

(withtheTargetsettotheboardyouareusing.)

20.NowclickGeneratesothatSOPCBuildercanproducetheparameterizedNiosIIprocessorsystem.

21.AftertheSOPCBuilderhasfinishedgeneratingyoursystem,openthepartially-completedniosII_lab.bdfschematicinQuartusII,andaddtheniosIIsymbol.

 

22.PressOKandlocateandplacethesymbolintheschematicsothatitlinesupwiththepinplacementsasshownbelow.Thepinsshouldalllineupexactly!

Iftheydon’t,chancesarethatyouneedtogobacktotheeSOPCBuilderandre-checkyourwork.

 

23.NowsavetheschematicandstartcompilationinQuartusbyselectingStartCompilationfromtheProcessingmenu.

 

Donotwaitforcompilationtocomplete.Wewillcontinuefromthispointduringthenextlab.

 

ENDOFLAB1

 

Lab2

SoftwareFlow

WearenowgoingtoprogramtheFPGAwiththedesignimage,andrunsomesoftwareonit.

 

1.OpentheQuartusIIProgrammer,anddownloadtheNiosIIFPGAdesign(ie.thenios_sys.sof)createdinthepreviouslabtotheNiosdevelopmentboard.

2.LaunchtheNiosIIIDE.

3.CreateanewsoftwareprojectcalledniosII_training_project.EnsurethattheptffilefromyourSOPCBuildersession(niosII.ptf)populatestheSOPCBuilderSystemfieldintheSelectTargetHardwaresection.Also,usetheBlankProjecttemplate.

4.PressNextandFinishtocreateanewsystemlibraryforyourapplication.

5.YouhavenowactuallycreatedtwonewsoftwareprojectsintheNiosIIIDE-aC/C++applicationprojectandasystemlibraryproject.However,theC/C++applicationprojectisblankandweneedtoaddsourcecodefilestotheproject.Addthesimple.cfiletotheprojectbyclickingontheNavigatortabonthelowerlefthandpaneloftheNiosIIIDEandexpandingtheniosII_training_projectfolder.

Then,openFileExplorerinWindowsandthenbrowsetothealtera_trn\nios_II_lab\softwarefolder.Dragthesimple.cfilefromthisfolderintotheniosII_training_projectfolderintheNavigatortabintheNiosIIIDE.

6.NowswitchbacktotheC/C++ProjecttabonthelefthandpanelintheNiosIIIDE.HighlighttheniosII_training_projectfolder,right-clickonthisfolder,andthenselectRefreshtoensurethattheprojectrecognizesthatwehaveaddedthesimple.cfile.

7.EdittheSystemLibraryPropertiesforthissoftwareproject,andensurethatthestdout,stderrandstdindevicesaresettojtag_uart.AlsoensurethatthePeriodicsystemtimerissettoSYS_CLK_TIMERandthattheProgram,Read-onlydata,andRead/writememoryfieldsaresettoext_ram.

8.WehavenowcreatedaprojecttorunoutofexternalSRAMthatusestheJTAGUARTasthestdiodevice.Now,compiletheprojectintheNiosIIIDE.

9.Afterthecompilationcompletes,downloadandRuntheprogramonthedevelopmentboard.

Note:

IfRunterminatesbeforethecodedownloadstoyourboard,andyougetamessagepertainingtotheJTAGdownloadcable.thenselectRun>Run…andfromtheTargetConnectiontabchoosetheappropriatedownloadcablethatyouareusingandhitApplyandRun.

 

ObservethattheconsolewindowintheNiosIIIDEdisplaystheprintfstatementfromthesimple.cprogram.PressofanyofthebuttonsontheboardtoshifttheLEDonespacetotheright.

10.NowstartthedebuggerbyselectingDebugAs->NiosIIHardware.Thedebuggerwilllaunch,connecttothetargetanddownloadtheprogramreadyfordebug.

11.Setbreakpointsonline22andline37.(IfthetexteditorintheNiosIIIDEdoesnotdisplaythelinernumberthenweneedtosetthoseinthePreferencesfromtheWindowmenu.OpentheC/C++folderandselectC/C++Editor.ChecktheShowlinenumbersboxandpressOK).Acirclewillappearnexttothelinenumberonwhichyouhavesetabreakpoint.

12.Clickontheresumebutton

.

13.Now,selecttheVariableswindowandviewthecontentsofthebuttonsvariable.NoticethatthebuttonshavebeenreadasshownintheVariableswindow.Changethisviewtohexadecimalbyright-clickingonthebuttonsvalueandselectingFormat=>Hexadecimal.

14.Clickresume

again.Sincetheifexpressionisfalse(ie.nobuttonsarepressed)thestatementswithinthecurlybracesarenotexecutedandwewillnotbreakonline37,insteadwewillbreakonline22again.

15.HolddownswitchSW3ontheboardandclickresume.Anewvalueisstoredinthevariablebuttons.

16.ContinuetoholddownSW3andclickresumeagain.Thebreakpointonline37isnowcaughtasabuttonwaspressed,sotheifconditionistrue.NoticethatthelitLEDhasalsochangedposition.

17.Clickresume.

18.Double-clickonbuttonswithinthevariableswindow.Nowchangethevalueto0xeandpressOK.Clickresume.Theifstatementisexecutedastruebecausewewehavechangedthebuttonvalueusingthevariableswindow.

Thisisusefulforemulatingexternalhardwareeventsorotherconditionsthataredifficulttoreplicate!

19.Fromthedebugmenu,right-clickonthesoftwareproject,andselectTerminateandRemove.Thenclose(

)simple.cintheNiosIIIDE.

 

Lab3

RTLSimulation

InthislabwewilluseModelSim-Alteratosimulaterunningcode.

1.SOPCBuildercanbeusedtocustomizetheJTAGUARTsothatitcangenerateadatastreamtosendtothehostprocessorduringsimulation.Doubleclickthejtag_uartperipheral,andasthedialogboxopens,ClicktheSimulationtab.T

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1