element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Path to Programmable
  • Challenges & Projects
  • Design Challenges
  • Path to Programmable
  • More
  • Cancel
Path to Programmable
Blog FPGA - 04 - Testing the BRAM and Intro to custom IPs !
  • Blog
  • Forum
  • Documents
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: nixiefairy
  • Date Created: 24 Jan 2019 10:15 AM Date Created
  • Views 374 views
  • Likes 5 likes
  • Comments 11 comments
  • path-to-programmable
  • minized
Related
Recommended

FPGA - 04 - Testing the BRAM and Intro to custom IPs !

nixiefairy
nixiefairy
24 Jan 2019

Hey folks,

ZynqHW_2017_4_lab_6_v12.pdf

 

So let's continue our arduous journey through the lab manuals. Boy, aren't things spicing up a bit?

So the first part of lab 6 shows us to import our SDK files done from Lab 3. The main aim was just to show us how to import lab files. So in all fairness, we won't be needing those lab files.

The next part talks about importing a pre-made C file which executes the following steps :

  • Number of words the user wants to transfer
  • The manner in which these would get transferred
  • And a small report talking about the number of clock cycles used by a BRAM transfer and the number of clock cycles used by a DMA transfer.
{gallery} Outputs from Lab 6

Build Output : .elf file loaded onto the Cortex

Output from the board:Note the menu options

Output from the board: What an ambiguous output indeed!

Hmmm sounds fishy that last part...Looks like we will have to see under hood on what's going on :

So looks to me like a pretty straight forward code : I have added a few helpful comments here and there My dma_test.c . To be honest, I got stuck at a few parts in the code and had to continuously refer to the documentation given for each peripheral. A brief outline of what the code does is given below:

  • Initializes the following in order : A UART connection for user interrupt, Setting up the GIC along with the Interrupt Service Routine, a PS_Timer and finally the PS_DMA definitions.
  • The Scu Private Timer had started just before printing out the message "-----Simple DMA Design-----" after which the counted timer value was printed out.
  • A while loop is initialized taking a number of words as input. Here the size of a word would be size of a single entry in the Memory unit of the ARM (PS side) [So 32 bits I presume]
  • The timer is reset and then starts off again for each of the testcases (here BRAM and DMA)
  • For a BRAM transfer, no fancy function (from bram_cntrl_0 documentation) was used as the ECC (Error Correction Capabilities) was not enabled. Thus we could directly write in and out of the memory ranges of the BRAM unit (which is what the program does)
  • The next part uses passes data through the DMA instead of the BRAM. All functions and structures used to start the DMA are given in this file - have a look : xdmaps.h
  • Finally the results are printed out.

A short notes on what I observed : No DMA was initialized on the PL side. Instead it was setup by the PS. For better visualization isn't it better to setup a block diagram in the PL? Probably the lab was getting complex as it is and they thought of this shorter way. Also from what I've read soft DMA in fabric is way faster than the PS DMA controller thanks to HP ports. So implementing it in the PL would have been a better choice, no?

So that about covers lab 6.

 

Tomfoolery

 

The GIC or Generic Interrupt Controller is used to manage different interrupts between PL and PS side. It is required to setup the DMA in poll-mode. The counter is initialized when data is about to be sent to the DMA from let's say here the DDR . An interrupt is also sent to stand by all other low priority interrupts. After which the DMA sends data (here the DDR) and the counter is reset. This gives us the number of clock cycles. What happens if we remove the interrupt altogether? I mean, there can't be any other higher priority process running in the background right? So the DMA should respond naturally to the data sent by the DDR.

Turns out  I was wrong.

The DMA needs an interrupt and a handler to start off, irrespective of any other process being run at the background.

 

Easter egg ! - Inheritance level 99

 

ZynqHW_2017_4_lab_7_v13.pdf

 

This lab talks about packaging a new IP with an AXI-4 connection. It also talks about setting up a debug ILA too.

So, having a glance at the source code Avnet has given is (a) it is in VHDL and (b) some constructs, I think are poorly written. For example in PWM_Controller_Int.v:

Looks funny doesn't it? We can simply write this procedural block as :

always @ (posedge Clk)

    if(DutyCycle > 990000)

        Interrupt <= 1;

    else

        Interrupt<=0;

Well , according to me, it's not too major a error so we can ignore this for now. Also the IP src files are written in VHDL. For the Verilog guys, I have written the IP as a Verilog design and is on  My repo  . Feel free to use it. Other than that the lab drags out with the steps to setup a new PWM output IP. The final IP properties block should look something like this :

Also a quicker way to setup the ILA is - right click on the wires you want to debug and select Debug.

After which just run the Connection Automation green dialog which appears. The final block diagram looks like this :

After which we have to add to JTAG-AXI core IP. So basically this is a TCL console controlled Ip where we generate AXI transactions through JTAG to the block design. Another IP could be used instead is the AXI Traffic Generator. Infact, there would be no TCL console required here! And instead of generating a separate PWM module for generating PWM, One could also use the AXI timer in PWM mode. However, the period and the duty cycles have to be setup in the PS side ( C file SDK).

That was some food for thought,  until next time e14!

Anonymous

Top Comments

  • DAB
    DAB over 3 years ago +2

    Nice update.

     

    DMA should be very simple to set up and use.

    Did you look into the timing issues associated with a DMA lockout cycle on the basic software execution?

     

    DAB

  • DAB
    DAB over 3 years ago in reply to nixiefairy +2

    Hi Jan,

     

    That is why I am curious about how the FPGA implemented the buffering of address and data lines.

    I have not seen anything to suggest that you can process the DMA transfer without temporarily halting…

  • Jan Cumps
    Jan Cumps over 3 years ago in reply to DAB +1

    DAB  wrote:

     

    ...

    DMA should be very simple to set up and use.

    ....

    I find it one of the more difficult parts to set up correctly on most of the microcontrollers I've programmed. Is it simple on an FPGA?…

  • Jan Cumps
    Jan Cumps over 3 years ago in reply to DAB

    DAB  wrote:

     

    Hi Eashan,,

    I am not surprised that the manuals do not explicitly discuss this issue.

    It may well be a non issue due to parallel paths through the FPGA, but I am just curious if they can separate the data movement in and out of the BRAM without some timing effects on other paths.

     

    DAB

    Yes, Don. I expect that there must be a referee guarding the memory - even in DMA mode. To prevent dirty reads and competing writes.

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • DAB
    DAB over 3 years ago in reply to nixiefairy

    Hi Eashan,,

    I am not surprised that the manuals do not explicitly discuss this issue.

    It may well be a non issue due to parallel paths through the FPGA, but I am just curious if they can separate the data movement in and out of the BRAM without some timing effects on other paths.

     

    DAB

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • nixiefairy
    nixiefairy over 3 years ago in reply to DAB

    DAB,

    I don't see anything like this mentioned in any of the DMAC manuals published by Xilinx.

    It was a general look through, though. I will definitely update this blog concerning this issue. If you have a link or so where you saw this effect being minimized, it would be of great help!

    Regards,

    Eashan

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • nixiefairy
    nixiefairy over 3 years ago in reply to DAB

    Aah I see what you guys mean (I think).

    That's the point right? FPGA's processing can never stall - that's why we use it in the first place. The pipeline in which the DMA belongs can stall. As for the cycle steal, I am sure the DMA would take a few clock cycles to startup, but really what would be the number ( I am sure it would be a very small one though) ? And for the PS DMA too ? This looks like an interesting experiment indeed. Looks like this blog will have an update after I put up the latest one.

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 3 years ago in reply to DAB

    Yes, Don. That is the kind of info I'm looking for too - beyond the drag-and-drop from the tutorial.

    Fast DMA requires a memory manager that has the intelligence to protect, rule and block only when needed.

    I wonder what's behind the drag-and-drop feature in Vivaldo. Is it flexible? It would be interesting if a road tester could look behind the scenes and check out the hardware language that does the magic ...

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
>
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube