References
- Digilent ZedBoard
- Hardware E & F (I have E, despite F being available)
- Avnet ZedBoard
DDR References from Digilent: (Not really related to ZedBoard)
Set up Vivado 2022.2 to use VS Code (Windows 10 Pro) as the editor.
I added C:\Program Files\Microsoft VS Code and ...\bin to my PATH.
See here
and use code.cmd -g [file name]:[line number].
Protected folder access blocked
- App:
vivado.exe - Protected folder:
%userprofile%\Documents\ - Blocked by:
Controlled folder access - Action chosen:
Allow on device
Antivirus sent a lot of Vivado files to see if they were safe.
Reference: Digilent Walkthrough
-
Clone the GitHub repo
-
Run Vivado 2022.2
-
Settings -> Vivado Store -> Board Repository
- Add the cloned repo's
new/board_filesdirectory
Note that the Vivado Store inside Vivado gets its board files
from this GitHub repository
and branch 2022.2. If you update the Vivado Store repository it
adds it to the settings automatically. Then, in the Boards selector (below)
you will see three ZedBoards: An Avnet one, and two Digilents - the 1.0 from
Xilinx Board Store and the 1.1 from the repo above.
- The Avnet ZedBoard has an
Add Companion Cardoption- This has the
FMC XM105 Debug Cardselectable - I have one of these! :)
- How can I get that usable in the Digilent
Zedboard? - What does it mean/do?
- This has the
Using: Vivado 2022.2
References:
- Run Vivado 2022.1 and create a new project
- RTL project with no sources to start with
- Use the Zedboard 1.1 board definition
(This says it is for board
D.3but I haveE)
- Add a constraint file from the GitHub Repo to the project
- Be sure to
Copy constraints files into projectis selected - This now appears in Sources -> Constraints -> constrs_1 -> Zedboard-Master.xdc
- Uncomment the constraints for the pins we will use
- Add a
create_clockas well- I am assuming the GCLK is 100 MHz
-
Create the SystemVerilog blinker code
-
Create the bitstream with
Generate Bitstream
- This takes an unreasonable amount of time. Quite a few minutes on my laptop (Alienware 13R3, 32G RAM)
- Open Hardware Manager
- Plug a USB Micro-B cable to the
PROGport next to the power jack - Open Target -> Auto Connect
Program Device->xc7z020_1
Voila. The LED should be blinking about 3 times a second.
- After powering on and letting the Zedboard boot from the default image with Linux and all that - I have no idea if the previously running Linux is still running!
References:
-
Create blank project (as above)
-
Project Manager -> IP INTEGRATOR -> Create Block Design
- Give it a name, I chose
BMBlock
- Add an IP block for the Zynq processor
- Click the
+in theDiagrampane - Add a
ZYNQ7 Processing System- Two additional tabbed panes will show up,
Address EditorandAddress Map - The block will be named
processing_system7_0
- Two additional tabbed panes will show up,
- Click the
Run Block Automationlink that pops up in a green bar in theDiagrampane- A window will pop up, just click
OK - (
Apply Board Presetis checked, we have that ZedBoard Digilent 1.1 preset, and it says that checking it will discard the existing IP configuration, of which we have none.)
- A window will pop up, just click
- This added a bunch of ports to the Zynq block in the
Diagrampane, including connections toDDRandFIXED_IO.- There are also these unconnected:
MDIO_ETHERNET_0SDIO_0USBIND_0M_AXI_GP0- with an odd dotted portTTC0_WAVE#_OUTfor 0, 1, 2M_AXI_GP0_ACLK(seems to be an input?)FCLK_CLK0andFCLK_RESET0_N- see below
- There are also these unconnected:
- Double-clicking the Zynq block opens up a
Re-customize IPwindow sayingZYNQ7 Processing System (5.5)with a lot of pages. The first page is theZynq Block Designwhich has (double?) clickable green blocks that take you to other pages. Some have checkmarks next to them. (You can also right-click and chooseCustomize Block...)- Clicking
Summary Reportgenerates a huge HTML page and opens it in your browser.
- Clicking
- To see what the
DDRandFIXED_IOare:- See the
Designpane, underExternal Interfaces - This lists all the pins for that external interface
FIXED_IOincludesmio,srstb,clk, andporb- Not sure what some of those are
- See the
- NOTE: Changes in the Block Diagram have to be saved with Control-S like a text file.
- Deal with PS-generated clocks
- The block has a
FCLK_CLK0added by default, unconnected- (There is also an
FCLK_RESET0_N- meaning?)
- (There is also an
- By using
Customize Block...on the Zynq, then going to theClock Configurationpage, and then thePL Fabric Clocksyou can see the speed of this clock, which is curently 100 MHz. - You can add 3 more at whatever speed you want.
- Using
IO PLLit does not have good granularity - the actual speed will not usually match the requested speed. For example, I couldn't get any 1280x1024 VGA pixel clock speed close for any refresh rate.
- Using
- "All board files for Digilent Zynq boards enable a single Zynq PL clock by
default, which is intended to be used with peripherals connected to the
Zynq's
M_AXI_GP0port."
- Add GPIO for LEDs to Block Diagram
- Note the
Boardpane in theBLOCK DESIGN, and theGeneral Purpose Input or Outputwhich contains buttons, LEDs and switches. (The switches are called "DIP switches" but the ZedBoard has regular sliders switches.) - Right click the
LEDand chooseConnect Board Component... - Choose
AXI GPIO->GPIOand clickOK - A new block appears in the diagram, called
axi_gpio_0- Contains a pre-connected output to
leds_8bits- Tutorial says this pre-connection "will not require any further work to constrain."
- Contains a pre-connected output to
- Rename it to
AXI_GPIO_LED
- Add GPIO for buttons to Block Diagram (in a different way)
- Click the
+in theDiagrampane and add anAXI GPIOblock - Name it
AXI_GPIO_BUTTONS - Right click the
GPIOoutput and selectMake Externalwhich will add a linkage toGPIO_0.- "This option creates a new external interface port that does not rely on the board files."
- So this will require us to make our own
.xdcfile.
- Deal with constraints file & board design
- Add the Digilent-provided ZedBoard constraints file (as above)
- Uncomment the 5
BTNxlines
- Uncomment the 5
- Back to the
Diagrampane - Expand the
GPIOoutput of theAXI_GPIO_BUTTONSto reveal three connections, for Tristates:_i,_oand_t- When constrained to Tristate buffers these are combined into
tri_io, the docs say, but I don't see it.
- When constrained to Tristate buffers these are combined into
- Edit the
.xdcfile to rename theBTNxlines tobtn_tri_io[#]for the appropriate#(in this case, 5 for the ZedBoard) - In the diagram, double-click
AXI_GPIO_BUTTONSto get theRe-customize IPwindow- Choose the
IP Configurationpane - Change
GPIO Widthto the number of buttons (5for the ZedBoard)
- Choose the
- Click
Run Connection Automationin the green bar- Select
All Automationwhich includes theS_AXIfor the two AXI blocks we added, and hitOK
- Select
- The diagram turns into a rats nest!
- An
AXI Interconnectand aProcessor System Resetare added - Move things around to make it look nice
- Change the
Default Viewdropdown box to see other perspectives of the same boxes
- An
- Deal with Addresses
- Open the
Address Editorpane - Update the
Rangefor the two GPIOs to 4k (they defaulted to 64k) - this is probably unnecessary - Go back to the
Diagram- Right click it and choose
Validate Designor hit F6 - This gave
Critical warningsfor fourDDR_DQS_TO_CLOCK_DELAYthings (ignore?).- "These warnings are ignorable and will not affect the functionality of the project. See the Hardware Errata section of your board's reference manual for more information."
- These Errata are the only Errata I could find; I saw none on Digilent's web site. This errata shows nothing useful.
- This board post says to ignore it for a Zybo board.
- Here is the Zybo Errata which mentions this
- Right click it and choose
- Create an HDL Wrapper of the Block Design
Sourcespane ->Design Sources-> BMBlock (right click) ->Create HDL Wrapper...- Select
Let Vivado manage wrapper and auto-update(the default choice) - The
Design Sourcesnow showsBMBlock_wrapperinstead withBMBLock_wrapper.vandBMBlock.v - There is also a
Simulation Sourcesentry for theBMBlock_wrapper - You can double-click the
BMBLock_wrapper.vand see it in your editor- This contains only top-level instantiations:
BMBlock- Five
IOBUFs for the five button tristates (which really should be inputs only)
- And look at the
BMBlock.v
- And build it!
- Click
Generate Bitstreamin theFlow Navigator - I have no idea how to monitor what it is doing
- It took a while to generate stuff for
IP Integrator blocksinTcl Console Project Summarypane shows Synthesis, Implementation areQueued- It shows
Running multple block runsat the top corner, with a green spinny - Occasionally a small window will pop up in the bottom right of the screen with a quick update that quickly disappears (how useless is that?!)
- It took a while to generate stuff for
- Eventually it gets to
Synthesiswith 585 warnings - Then to
Implementation- Critical warnings (which we can ignore) in the
.xdcfile:set_property IOSTANDARD LVCMOS18 [get_ports -of_objects [get_iobanks 35]];set_property IOSTANDARD LVCMOS33 [get_ports -of_objects [get_iobanks 13]];- Since evidently we didn't use those IO Banks
- Critical warnings (which we can ignore) in the
- This probably took 10-15 minutes (!!!)
- Vivado is sooooo sloooooow
- "Critical warnings about how IPs included within another IP were packaged with a
different board value can be safely ignored. The same is true for warnings related
to negative CK-to-DQS delays seen on some Zynq boards."
- I did not see any critical warnings other than the
DQSand the.xdcones.
- I did not see any critical warnings other than the
- Get ready for Vitis
- File -> Export -> Export Hardware
- In
Outputpane, choose toInclude bitstreamthat we just generated - Choose the default location for the
.xsafile in theFilespane - And let it do it's thing
- The
.xsafile is a binary file of some sort
Now we move into Vitis! (This IDE seems to be based on Eclipse.)
- Launch Vitis
- From Start Menu
- From Tools -> Launch Vitis IDE in Vivado
- Choose a workspace when it pops up
- I chose
C:\src\FPGA\dpf-zb-barmetal-workspace
- Create Application Project
- Project -> Create Application Project in the Vitis welcome window
- In the
Platformpane, click theCreate a new platform from hardware (XSA)tab- XSA = Xilinx Shell Architecture
- Browse for the
.xsafile we just exported - Select it in the
Hardware SpecificationXSA File:list - Select
Generate boot components - Give it a platform name (I chose
DPF-BareMetal) - Click Next to see
Application Project Detailspane - Application Project Name:
BareMetal1 - Target
ps7_cortexa9_0(for now) - Click
Nextto see theDomainpane- We will use defaults in
Domain
- We will use defaults in
- Click
Nextto see theTemplatespane - Choose
Empty Application(C)and clickFinish - ...and the Vitis IDE opens with the
BareMetal1andBareMetal1_systempanes available
- Create Source
Explorerpane- Right-click
srcdirectory, New -> File - Name it
main.c - COpy the code from the tutorial
- Edit the
BTN_MASKandLED_MASK
- Build!
Assistantpane- Select
BareMetal1_system - Click
Buildhammer icon or right-click and selectBuild - It does its thing for a while, building a
.biffile and stuff
- Update the board settings to boot from JTAG
- Default as shipped ZedBoard MIO[6:2] jumpers are 01100 to boot from SD card (MIO[5:3])
- Hardware guide says JTAG boot is MIO[5:3] of 3'b000
- Set Jumpers 7-11 appropriately
-
Connect TeraTerm at 115.2kbps and no flow control
-
Power the board on with both JTAG and UART Micro-USB cables connected to computer
-
Run it!
- Explorer pane
BareMetal1_system(right click) -> Run As -> 1 Launch Hardware- The blue LED marked
DONEshould light up (LD12) - TeraTerm will say "Entered function main"
- Tap any of the 5 buttons
- All 8 LEDs should light up
- Tapping
PROGbutton will clear the PL and things will break (blue light goes out) - Tapping
PS-RSTwill reset the PS and things will also break - You can re-program exactly the same way and the blue light will come back
- Make the LEDs display each button
- And "all on" or "all off" or "any on" lights
- Send console message with each button change
- Go to Vivado and add GPIO switches to the Block Diagram
- I also seem to have accidentally turned my buttons into input-only,
and consequently needed to add new constraints for
btn_tri_iinstead. - Set the address window to 4K again
-
Regenerate the bitstream
-
Re-export the hardware
-
In Vitis, in the
Assistantpane, right click the[Platform](calledDPF-BareMetalin mine) andUpdate Hardware Specification
- Give it the re=exported
.xsafrom the step above and let it do its thing - THen right-click it again and pick
Open Platform Editor - Click the
Board Support Packagefor eitherzynq_fsblorstandalone_ps7_cortexa9_0- You will see
AXI_GPIO_SWITCHESunder the Operating System -> Drivers tab
- You will see
- It says
Out-of-dateand if you look inxproperties.hyou see no reference to the switches we just added - Let's see what happens if I now hit
Buildon the[Platform]- THIS WORKED
- The
Out-of-dategoes away on the system xparameters.hnow has a section onDefinitions for peripheral AXI_GPIO_SWITCHES
- Modify the C code to use the switches however you like
- In
Assistantpane, clickBuildon theBareMetal1_system [System] - Run
1 Launch Hardwareto build the software (in theExplorerpane) - Test it on the board
- If the board works, you're golden, otherwise, fix it and repeat this step (or possibly go to step 1)
Digilent Tutorial to follow along with.
- Apparently this is automatically built due to having selected
Generate boot componentsearlier (above)
- See
dpf-zb-baremetal-workspace/BareMetal1_system/Debug/sd_carddirectory
- Prepare SD card
- FAT32 formatted microSD (so up to 32G will work)
- Copy BOOT.BIN file into its root directory (about 4 Mbytes long)
- Set the ZedBoard to boot from SD card (see above)
- Insert the SD card
- Boot
- It literally configures in under a second
- Windows can't configure the UART fast enough to get the introductory message
- Other buttons
- PROG button will kill the application
- PS-RST will reload the application quickly
- The initial startup printf will show up on console
Zooming and movement:
- Center-drag to move the window
- Control-scroll wheel to zoom in and out
- Left-drag to do various zooms:
- Area (downward right diagnonal)
- To fit (upward left diagonal)
- In or out (along a one diagonal) by 0.5
-
How are the pre-made
DDRandFIXED_IOconnections in the Block Design set up and/or connected? -
Where do I get documentation on all the APIs available in the Vitis project?
- Like documentation on
XGpio_CfgInitializeorxil_printfand so forth? - What about the
xxx_CHANNELparameter toXGpio_SetDataDirection
- Like documentation on
-
Build my own AXI LED & button/switch interface from scratch
- Instantiate it in the diagram
- Read buttons/switches and send LED outputs from bare metal
- ...and from Linux
-
Build character RAM based external display (e.g. I2C or SPI display with one of my other character display drivers, or VGA)
- Build AXI interface to the character memory using true dual-port RAM (?)
- Since I never built anything with AXI this will be the real challenge
- Change character buffers from bare metal
- Since I never built anything using Zynq in general this will be challenge #2
- Change character buffer from a Linux device driver
- Since I never built PetaLinux or Ubuntu with Zynq this will be challenge #3
- Build AXI interface to the character memory using true dual-port RAM (?)