element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Interacting with DDR3 SDRAM on Arty S7-50 (7 Ways to Leave Your Spartan-6 FPGA)
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: cbohra00627
  • Date Created: 29 Jul 2022 12:37 PM Date Created
  • Views 4197 views
  • Likes 9 likes
  • Comments 0 comments
  • 7 Ways to Leave Your Spartan-6 FPGA
  • spartan-7
  • cbohra00627
  • Spartan_Migration
  • spartan-6
Related
Recommended

Interacting with DDR3 SDRAM on Arty S7-50 (7 Ways to Leave Your Spartan-6 FPGA)

cbohra00627
cbohra00627
29 Jul 2022

Introduction:

The Arty S7 contains a 256MB DDR3L SDRAM with a 16-bit bus. For proper operation of the memory, a memory controller and physical layer (PHY) interface needs to be included in the FPGA design. The easiest way to accomplish this on the Arty S7 is to use the Xilinx 7-series memory interface solutions core generated by the MIG (Memory Interface Generator) Wizard. The MIG Wizard can generate a native FIFO-style or an AXI4 interface to connect to user logic. Read more here.

In this blog, we will try to include this memory in our design and interact with it. Instead of using BRAM as data and instruction memory, we will try to use the SDRAM.

If you are new to FPGA or you haven't yet created your first project on the board, I will recommend you to go through the below mentioned blogs first:

  1. Getting Started with Arty S7-50.
  2. Implementing MicroBlaze based Microcontroller on Arty S7-50.



Creating Block Design:

  1. Open Vivado and create a new RTL project.
  2. Click on "Create Block Design".
  3. Add a MicroBlaze IP.
    MicroBlaze IP
  4. Run Block Automation. Select the settings as shown below. Note that we don't need BRAM because we will be using the SDRAM instead of the BRAM. Click on "OK".
    Run Block Automation
  5. Open the Clocking Wizard by double clicking on it and select "Active Low" for "Reset Type".
  6. Drag and drop the "System Clock" from the "Board" Tab into our design (it should get connected to the clocking wizard).
  7. Now run connection automation by selecting all automation.
  8. Now add a UARTlite IP and again run connection automation by selecting all automation.
  9. You can now regenerate the layout.
  10. Your design should look something like this:
    Block Design
  11. Now, we need to add the "DDR3 SDRAM" to our design.
  12. Go to the "Board" tab and drag and drop "DDR3 SDRAM" to our design from there.
  13. Now you will see that a "Memory Interface Generator" block with "DDR3 SDRAM" as an external port will be added to your design.
    Block Design with MIG
  14. Now, double click on the MIG block to customize it.
  15. Actually, majority of the settings will be already selected according to our SDRAM. But still we should go through it just to confirm it.
  16. In the "MIG Output Options", "Create Design" should be selected. Click on "Next".
    Create Design
  17. Leave the "Pin Compatible FPGAs" as it is. Click on "Next".
    Pin Compatible FPGAs
  18. Select "DDR3 SDRAM" for controller type. Click on "Next".
    DDR3 SDRAM
  19. Check the following settings for "Options for Controller 0". Click on "Next".
    Options for Controller 1
  20. Leave the "AXI Parameter Options C0" as it is. Click on "Next".
    AXI Parameter Settings
  21. Check the following options for "Memory Options C0". You can unselect "Select Additional Clocks", we don't need it. Click on "Next".
    Memory Options 1
    Memory Options 2
  22. Check the following settings. Click on "Next".
    Other Settings
  23. Select 50 Ohms for "Internal Termination for High Range Banks".
    Internal Termination
  24. Select "Fixed Pin Out" for "Pin Selection Mode".
    Fixed Pinout
  25. Click on "Validate" to verify the Pinout.
    Validate Pinout
  26. Now, keep clicking on "Next", accept the agreement then click on "Generate".
  27. Now, in the block design, select "clk_ref_i" and "sys_clk_i" and delete them.
    clk_ref_i sys_clk_i
  28. Now, open the "Clocking Wizard". Go to "Output Clocks", enable "clk_out2" with 200MHz frequency. Click on "OK"
    200 MHz clk_out2
  29. Connect the "clk_out2" to the "clk_ref_i" port of MIG.
    Connect 200 MHz clock to MIG
  30. Click on "Run Connection Automation". Select "sys_clk_i". Select "New External Port" with 100 MHz for "Clock Source". Click on "OK".
    Connection Automation for sys_clk_i
  31. Now, again run connection automation, select "All Automation". "reset (System Reset)" should be selected for "Select Board Part Interface". Click on "OK".
    Connection Automation
  32. You can regenerate the layout now.
    Regenerated Layout
  33. Now, if you would look at our block design, you will notice that we have a path between MicroBlaze and MIG for data ( i.e. "M_AXI_DP") but we don't have an instruction path. Without it we wouldn't be able to run C code on our design.
  34. To enable instruction path, double click on the MicroBlaze IP, go to the 4th page and select "Enable Peripheral AXI Instruction Interface". Click on "OK".
    AXI Peripheral Interface
  35. Now, run connection automation. Select "/mig_7series_0/S_AXI" for "Slave Interface". Click on "OK".
    Connection Automation
  36. Regenerate Layout.
    Regenerate Layout
  37. Validate your design.
    Validate Design
  38. Now save your design.
  39. Create HDL Wrapper for your design, Run Synthesis, Run Implementation and Generate Bitstream.
  40. It will give you a critical warning after running implementation and the BMM file will not be generated. That is because we don't have BRAM in our design. For now we can proceed without worrying about it.
  41. Export your hardware and then launch Vitis.

Testing the design:

  1. Launch your Vitis Workspace. Create an empty C Application project. Select the xsa file that we earlier exported as our platform.
  2. Create a C language source file inside the "src" folder.
  3. Copy the code inside the source file:
    #include "platform.h"
    #include "xparameters.h"
    #include "xil_printf.h"
    #include "xil_io.h"
    
    int main() {
    
    	init_platform();
    
    	int x = 56;
    	int num;
    
    	Xil_Out8(XPAR_MIG7SERIES_0_BASEADDR + 3, 23);
    	num = Xil_In8(XPAR_MIG7SERIES_0_BASEADDR + 3);
    
    	xil_printf("%d %d", x, num);
    
    	cleanup_platform();
    
    	return 0;
    }
  4. We can directly write to a memory location if we know its address. The BASE address and HIGH address for the SDRAM is listed in the "xparameters.h" file. "XPAR_MIG7SERIES_0_BASEADDR" refers to the base address of SDRAM as is given the "xparameters.h" header file.
    • The Xil_Out8() function is used to write one byte of data to the memory location specified.
    • The Xil_In8() function retrieves one byte data from the memory location specified.
    • These functions are defined under the "xil_io.h" header file.
    • To know more about these functions, refer this documentation.
  5. If you will look at our code, you will notice that we have included some header files in our code. The header files "xparameters.h", " xil_printf.h" and "xil_io.h" are already present in the "includes" folder inside the design wrapper folder.
  6. We need to get the "platform.h" header file. To get it, just create a new Application Project by selecting the "Hello World" template. Inside the "src" folder, you will find three files: "platform_config.h", "platform.h" and "platform.c". Just copy these files to your original project "src" folder. You can now delete the Hello World project. We don't need it now.
    Header Files
  7. Connect your board. Notice that there is no BMM file in our project that is because we haven't included BRAM in our design. Program your device.
    Program Device
  8. Open a Serial Terminal.
  9. Build your code and then run it on the hardware.
    Run Code
  10. As it can be seen on the terminal, we have created a variable and accessed its value successfully and we were also able to write directly to a memory location using the Xil_Out8() function. I would like to advice that if your code consists of assigning to and accessing values from a variable then avoid using direct memory location access using Xil_Out because it might overwrite your already existing variable data.

Conclusion:

The IP integrator has made it really easy to customize any design according to our needs. But one will require a little bit of patience and practice to learn to implement correct approach to build their designs and not get confused by seeing vast number of options and features offered by the Vivado Design Suite.

  • Sign in to reply
element14 Community

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 © 2025 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

  • X
  • Facebook
  • linkedin
  • YouTube