New Horizons







Welcome to my blog

My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
and FPGA.
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and work
for Realtime Embedded AB.

My company



Contact

You are always welcome to contact me
and ask questions or make comments
about my blog.

View Sven Andersson's profile on LinkedIn

Search the blog

Loading

New Horizons
What's new
Starting a blog
Writing a blog
Using an RSS reader

Xilinx FPGA Design
New start August 2011
Problems, fixes and solutions
FPGA design from scratch. Part 51
FPGA design from scratch. Part 52
FPGA design from scratch. Part 53
FPGA design from scratch. Part 54
FPGA design from scratch. Part 55
FPGA design from scratch. Part 56
FPGA design from scratch. Part 57
FPGA design from scratch. Part 58
FPGA design from scratch. Part 59
FPGA design from scratch. Part 60
Using the Spartan-6 LX9 MicroBoard
Table of contents
FPGA design from scratch. Part 61
FPGA design from scratch. Part 62
FPGA design from scratch. Part 63
FPGA design from scratch. Part 64
FPGA design from scratch. Part 65
FPGA design from scratch. Part 66
FPGA design from scratch. Part 67
FPGA design from scratch. Part 68
FPGA design from scratch. Part 69
FPGA design from scratch. Part 70
FPGA design from scratch. Part 71
FPGA design from scratch. Part 72
FPGA design from scratch. Part 73
FPGA design from scratch. Part 74
FPGA design from scratch. Part 75
FPGA design from scratch. Part 76
FPGA design from scratch. Part 77
FPGA design from scratch. Part 78
FPGA design from scratch. Part 79
FPGA design from scratch. Part 80
FPGA design from scratch. Part 81
FPGA design from scratch. Part 82
FPGA design from scratch. Part 83
FPGA design from scratch. Part 84
FPGA design from scratch. Part 85
FPGA design from scratch. Part 86
FPGA design from scratch. Part 87
FPGA design from scratch. Part 88
FPGA design from scratch. Part 89
FPGA design from scratch. Part 90
FPGA design from scratch. Part 91
FPGA design from scratch. Part 92
FPGA design from scratch. Part 93
Started December 2006
Table of contents
Index
FPGA design from scratch. Part 1
FPGA design from scratch. Part 2
FPGA design from scratch. Part 3
FPGA design from scratch. Part 4
FPGA design from scratch. Part 5
FPGA design from scratch. Part 6
FPGA design from scratch. Part 7
FPGA design from scratch. Part 8
FPGA design from scratch. Part 9
FPGA design from scratch. Part 10
FPGA design from scratch. Part 11
FPGA design from scratch. Part 12
FPGA design from scratch. Part 13
FPGA design from scratch. Part 14
FPGA design from scratch. Part 15
FPGA design from scratch. Part 16
FPGA design from scratch. Part 17
FPGA design from scratch. Part 18
FPGA design from scratch. Part 19
FPGA design from scratch. Part 20
FPGA design from scratch. Part 21
FPGA design from scratch. Part 22
FPGA design from scratch. Part 23
FPGA design from scratch. Part 24
FPGA design from scratch. Part 25
FPGA design from scratch. Part 26
FPGA design from scratch. Part 27
FPGA design from scratch. Part 28
FPGA design from scratch. Part 29
FPGA design from scratch. Part 30
FPGA design from scratch. Part 31
FPGA design from scratch. Part 32
FPGA design from scratch. Part 33
FPGA design from scratch. Part 34
FPGA design from scratch. Part 35
FPGA design from scratch. Part 36
FPGA design from scratch. Part 37
FPGA design from scratch. Part 38
FPGA design from scratch. Part 39
FPGA design from scratch. Part 40
FPGA design from scratch. Part 41
FPGA design from scratch. Part 42
FPGA design from scratch. Part 43
FPGA design from scratch. Part 44
FPGA design from scratch. Part 45
FPGA design from scratch. Part 46
FPGA design from scratch. Part 50
Links
Acronyms and abbreviations
Actel FPGA design
Designing with an Actel FPGA. Part 1
Designing with an Actel FPGA. Part 2
Designing with an Actel FPGA. Part 3
Designing with an Actel FPGA. Part 4
Designing with an Actel FPGA. Part 5
CAD
A hardware designer's best friend
Zoo Design Platform
VirtualBox
Using VirtualBox. Part 1
Using VirtualBox. Part 2
Using VirtualBox. Part 3
Linux
Installing Cobra Comand Tool
Using the SIGMA Logic Analyzer in Linux
Installing Ubuntu Linux on a MacBook
Customizing Ubuntu Linux 1
Customizing Ubuntu Linux 2
Upgrading to Ubuntu 7.04
Install Ubuntu 7.04 with VMware
Making the virtual machine run faster
Ubuntu Links
A processor benchmark
Mac
Porting a Unix program to Mac OS X
Fixing a HyperTerminal in Mac OS X
A dream come true
Wireless freedom
Running
The New York City Marathon
Skiing/Skating
Kittelfjäll Lappland
Tour skating in Sweden and around the world
Top
Introduction
SSSK
Wild skating
Tour day
Safety equipment
A look at the equipment you need
Skate maintenance
Calendar
Links
Books, photos, films and videos
Weather forecasts
SystemC
SystemC from scratch. Part 1
SystemC from scratch. Part 2
SystemC from scratch. Part 3

Travel
38000 feet above see level
A trip to Spain
Florida the sunshine state


Example Files
Verilog Testbench Body
Verilog Testcase
Verilog Setup
Simulation Result File
Simulation Report File


Photo Albums
Seaside Florida
Ronda Spain
Sevilla Spain
Cordoba Spain
Alhambra Spain
Kittelfjäll Lapland
Landsort Art Walk
Skating on thin ice

Books
100 Power Tips for FPGA Designers

Favorites
Adventures in ASIC
ChipHit
Computer History Museum
DeepChip
Design & Reuse
Dilbert
EDA Cafe
EDA DesignLine
Eli's tech Blog
Embedded.com
EmbeddedRelated.com
Forum for Electronics
FPGA Arcade
FPGA Blog
FPGA Central
FPGA developer
FPGA Journal
FPGA World
Lesley Shannon Courses
MacApper
Mac geekery
Mac 2 Ubuntu
Programmable Logic DesignLine
History of Linux
OpenCores
Simplehelp
SOCcentral
World of ASIC



If you want to be updated on this weblog Enter your email here:



rss feed



 
Saturday, April 14, 2012
What's new

2012-04-09 Read about the Nios II soft processor in my new blog.

2012-03-14 Read about the OpenRISC soft processor in my new blog.

2012-02-16 I will continue my blog about  LEON3 from the Realtime Embedded website.

2012-02-12 Did you know that you can use an RSS feed reader to read my blog?

2012-01-09 I will participate in the conference FPGA Forum in Trondheim 14-15 February and give a presentation about ASIC and FPGA design.

2011-12-06 Read about my blog in Elektroniktidningen

2011-11-30 Read about my blog in EE Times

2011-11-07 Added information on how to setup and use VirtualBox

2011-10-29 Added a new story. Designing with an Actel FPGA.

2011-10-19 Added information on how to install Linux on the LX9 MicroBoard.

2011-10-05 I will take a short brake and travel to Tuscany for 10 days.

2011-09-20 Added information on how to use the Avnet Spartan-6 LX9 MicroBoard

2011-08-21 Restarted my FPGA design from scratch blog. See part 51 and forward.


Posted at 02:54 am by svenand
Comments (3)  

 
Thursday, April 12, 2012
Installing Cobra Command Tool in Ubuntu 11.10
Introduction

Is it possible to install and run a more than 20 year old program in the latest version of Ubuntu (11.10 64bits). Let's find out. We will install the smart terminal program Cobra Command Tool which I develop more than 20 years ago. The program can be downloaded from my company web page: www.zoocad.com.





Click the
Zoo Design button and then the Download button.






Right-click
cobra_9.95ub.tar.gz and select Save Link as.






Use this command to unzip and unpack the downloaded file.

-->tar zxvf cobra_9.95ub.tar.gz

Here is the result.





Copy all the files to the installation directory and edit the startup script (cobra) to match this directory.




Move the startup script (cobra) to the bin directory and start Cobra using the command:

--> cobra &

Absolutly nothing happens, the Cobra.exe file is not found. The explanation is this. Cobra is compiled for a 32 bit Linux operating system and we try to run it in a 64 bit Linux system.


How to make 32-bit applications work on a 64-bit operating system

Here is a
Ubuntu help page describing how we can solve the problem.






Installing 32-bit shared libaries.

We start the Ubuntu Software Center and find the is32-libs and install them.




Let's try again.

--> cobra &



We are missing the library libxview.so.3. The Cobra program was written for the SUN OS 4 using the
xview toolkit. This toolkit is obsolete but it has been converted to the Linux OS and can be downloaded from here. We will download the 32 bit version of the libraries.





Installing the xviewg libraries

We unpack the downloaded package using the following command:

sudo dpkg -x xviewg_3.2p1.4-28_i386.deb tmp





We copy all the files in the lib directory to the cobra install directory. When we start Cobra the next time the program will find the xview library files using the LD_LIBRARY_PATH variable.


Installing font files

The Cobra program uses old xfonts with fixed sizes. xfonts-100dpi provides a set of bitmapped fonts at 100 dots per inch. In most cases it is desirable to have the X font server (xfs) and/or an X server installed to make the fonts available to X clients.

We install the font server and the fonts using the following commands:

sudo apt-get install xfonts-100dpi
sudo apt-get install xfonts-75dpi
sudo apt-get install xfonts-utils


Starting Cobra

We are ready to start Cobra.

--> cobra &




This doesn't look so good. We need to fix the font sizes for the buttons and the console.

.Xresources

In the X Window System, the X resources are parameters of computer programs such as the name of the font used in the buttons,the background color of menus, etc. They are used in conjunction with or as an alternative to command line parameters and configuration files.

We add the following .Xresources file in our home directory:




We can use the command: xrdb .Xresources to enable the new settings. The next time we boot our system this command will be executed automatically during start up.

Now let's start Cobra again.

--> cobra &



This time everything looks just perfect. We have demonstrated that we can take a 20 year old program and run it in the latest Linux environment. This shows the power of unix and the X-windows system.


Now when we have Cobra Command Tool running we can learn more about all the features of the program by reading the
User's guide.


Posted at 05:20 pm by svenand
Comments (11)  

 
Monday, March 12, 2012
FPGA design from scratch. Part 93

The OpenRISC 1200

OpenRISC OR1200 is a synthesizable CPU core maintained by developers at OpenCores.org. The OR1200 design is an open source implementation of the OpenRISC 1000 RISC architecture. The Verilog RTL description is released under the GNU Lesser General Public License (LGPL). For more information see OpenRisc 1200 Specification document.




For even more information read my new blog.



Posted at 12:21 pm by svenand
Comment (1)  

 
Wednesday, January 25, 2012
FPGA design from scratch. Part 92
 
LEON3 soft processor

I have just started a new FPGA design project. This time we will use the Leon3 soft processor from Gaisler and build a system around it. For that reason I have ordered a new development board from Xilinx, the Spartan-6 FPGA SP605 Evaluation Kit.




Unpacking the box

Here is what's in the box.







The board itself.




The documentation

In the box we find these two documents, all other documents are found on the USB flash drive that is included in the kit.




Here is the content of the USB flash drive.




Installing the ISE Design Suite software

The software can be installed from the DVD included in the kit or from the Xilinx software download page. For more information about downloading and installing the software from the download site see part 51.

To install the software from the DVD, insert the DVD in your computer's DVD reader. The DVD contains the following directories and files.



We will install the Linux version of the software. To start the installation double-click the xsetup icon and follow the instructions.


 Installing the license file

A software voucher is included with the SP605 evaluation kit. The voucher contains the code that is used to create a device-locked and node-locked software license for the ISE Logic Edition. To create a license goto the Xilinx Product Licensing.



Enter the 22-digit code from the voucher in the field shown here above and click Redeem Now. For more information see the document "Getting Started with the Xilinx Spartan-6 FPGA SP605 Evaluation Kit" and part 51 in this blog.

Find out more

I will continue this blog about LEON3 from the Realtime Embedded website.


Posted at 08:40 am by svenand
Comments (2)  

 
Thursday, January 12, 2012
Reading my blog using an RSS reader
Introduction

I have for a long time thought about using an RSS reader for subscribing to different web pages and blogs but never taken the step to do it. Now the time has come. First let's see what it is all about. Here is a short introduction from Wikipedia.

RSS (originally RDF Site Summary, often dubbed Really Simple Syndication) is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format. An RSS document (which is called a "feed", "web feed", or "channel") includes full or summarized text, plus metadata such as publishing dates and authorship.

RSS feeds benefit publishers by letting them syndicate content automatically. A standardized XML file format allows the information to be published once and viewed by many different programs. They benefit readers who want to subscribe to timely updates from favorite websites or to aggregate feeds from many sites into one place.

RSS feeds can be read using software called an "RSS reader", "feed reader", or "aggregator", which can be web-based, desktop-based, or mobile-device-based. The user subscribes to a feed by entering into the reader the feed's URI or by clicking a feed icon in a web browser that initiates the subscription process. The RSS reader checks the user's subscribed feeds regularly for new work, downloads any updates that it finds, and provides a user interface to monitor and read the feeds. RSS allows users to avoid manually inspecting all of the websites they are interested in, and instead subscribe to websites such that all new content is pushed onto their browsers when it becomes available.


Blogdrive RSS feed


This small image tells us that Blogdrive supports RSS feeds. If we move the cursor over it the URI is displayed: svenand.blogdrive.com/index.xml

Finding an RSS reader

RSS feed readers and news aggregators let us follow news and blogs easily, comfortably and efficiently in a dedicated program, on a web site or in our email program. There are hundreds of RSS readers available and it is not easy to choose. I have decided to try NewsFire on my MacBook.


Download and install NewsFire

We will download the program from the Apple Mac App Store.





Adding an RSS feed

After starting NewsFire we click the + sign in the lower left corner and enter the URI of the blog http://svenand.blogdrive.com/index.xml. Now we have to wait a few minutes for the program to grab the feed and display the name of the blog: New Horizions. Click Add to add the RSS feed.





Reading blog entries

We can now read the latest blog entries in the RSS reader. It was that simple.







Posted at 12:59 pm by svenand
Comments (4)  

 
Sunday, January 08, 2012
Using the SIGMA Logic Analyzer in Linux

Introduction

We need a logic analyzer for our embedded design project. After looking around I found the ASIX SIGMA Logic Analyzer.


The Linux solution

ASIX provides a Linux solution using Wine. It is not the most user-friendly installation and if we can stay away from Wine it would be good. Let's see if there are other solutions. When searching the web I found sigrok.


The sigrok project



According to their webpage they support the ASIX SIGMA logic analyzer. Let's find out more.

Finding a Ubuntu/Debian package

The package can be found here: http://packages.debian.org/en/sid/sigrok




Download the sigrok package

We find a download server and download the package and open it in the Ubuntu Software Center.




Fixing dependencies

First we have to add multiarch-support..





Next we have to download libftdi1 0.19.





Install sigrok




Installing firmware

The necessary firmware files are provided by the vendor for distribution. As a result, the SIGMA works out of the box with sigrok. Trigger support has been implemented in 100 MHz and 200 MHz modes for rising/falling edges. 

First we have to install the Git package if not already installed:

--> sudo apt-get install git


The firmware files must be copied to the directory: /usr/share/sigrok/firmware





Running sigrok

The command to start sigrok is sigrok-cli:



Identify device

Use the command: sigrok-cli -D to show connected devices:



Command-line description

Here is a description of the options that can be specified on the command-line.



Find the version and display some useful information.




Building a package for Debian

We can also build a package from source files. Here is the documentation.




Fetching the source files from the GIT archive

Use this command to checkout the sigrok source files:

--> git clone git://sigrok.git.sourceforge.net/gitroot/sigrok/sigrok


Sigrok 0.2


The latest version (0.2) can be downloaded from Softpedia.



Posted at 10:16 am by svenand
Comments (4)  

 
Wednesday, January 04, 2012
FPGA design from scratch. Part 91
Writing software to control the accelerometer

We will use Xilinx Software Development Kit (SDK) for the software development. To start a software project in SDK, the hardware design information needs to be exported from XPS to SDK. In XPS go to Project->Export Hardware Design to SDK and click Export Only.





For more information about software development see part 66.

Starting SDK

--> xsdk &

Start SDK and select a new workspace for our software project.




Starting a new project

Select New C Project from the File menu.




The first thing we have to do when starting a new project in SDK is to setup the hardware platform. We will do that by finding the XML file: LX9_AXI_ACL_system.xml and select it as the target hardware specification file.




Creating a new C-project


We call our new C project adxl345_control and start with an empty application.




We create a new board support package called adxl345_bsp_0




Adding c-program files

Because we are not the best c programmers and a bit lazy we will copy the c-files from the Avnet installation we have already downloaded. After copying the files to the src directory we have to do a refresh to see the files in SDK. 



Here is the final result ready to be compiled and built.



Before we can compile our application there are a few things we have to fix.

  1. Generate a linker script
  2. Edit the cf_adxl345_sw.c file

Generate a linker script

We will setup the linker to put all the code in the MicroBlaze BRAM.



Edit the c-program

There are two small changes to be made.




Building the project

Here is the print out from the build process. Everything looks OK.



Configure the Spartan-6 FPGA

In SDK select Xilinx Tools->Program FPGA. Select the program ELF file to be loaded to the BRAM.




Click Program.




Start the console

Start gtkterm or an other console program you prefer.

--> gtkterm &


Start program execution

From the SDK menu select Run As->Run Configuration. Select the USB port to connect to the terminal and set the baud rate to 9600. Click RUN to start the program.




After a few seconds this print out appears on the console screen.




When twisting and moving the board the values change. A great example of what we can achieve with this simple setup.


Top Previous  Next



Posted at 08:26 am by svenand
Make a comment  

 
Friday, December 30, 2011
FPGA design from scratch. Part 90
Using Pmods

Pmods are small I/O interface boards that offer an ideal way to extend the capabilities of the Spartan-6 LX9 MicroBoard. Pmods communicate with system boards using 6 and 12-pin connectors. Pmods include sensors, I/O, data acquisition & conversion, connectors, external memory, and more.

Overview

The Spartan-6 LX9 MicroBoard has two connectors which allow expansion to Pmod Peripheral modules.



For more information on Pmods see: www.em.avnet.com/adipmods.

The Pmods can be ordered from Digilent. Here are some examples:


The Digilent Pmod 3-axis accelerometer

I just received the PmodACL board which I ordered from Silica before Christmas. A late Christmas present. We will connect this module to the Spartan-6 LX9 MicroBoard and build a new embedded system to make use of all the nice possibilities this board offers.


The Digilent Pmod-ACL features an Analog Devices ADXL345 Accelerometer. The ADXL345 is a small, thin, low power, 3-axis accelerometer with high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit two's complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.

The ADXL345 is well suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (4 mg/LSB) enables measurement of inclination changes less than 1.0°.


The tutorial


This tutorial demonstrates how to interface an Avnet Spartan-6 LX9 MicroBoard to a Digilent PmodACL using the Xilinx EDK. It includes a custom designed peripheral core that provides a simple interface for software to access streaming acceleration data in all 3 dimensions as well as tap and free fall detection. We will follow the document: "Spartan-6 LX9 MicroBoard On-Ramp Tutorial, Utilizing Analog Device's Accelerometer Pmod AXI Version" from Avnet that can be downloaded from their support page.


The hardware platform

Here is a picture showing the system we are going to build. We will start with an existing project and make a copy of it as a starting point for our new project.




Copying an EDK project

We copy the LX9_AXI design (see part 65) to a new project called LX9_AXI_ACL. The following files are copied from the LX9_AXI project and renamed to LX9_AXI_ACL_system.mhs, LX9_AXI_ACL_system.xmp and LX9_AXI_ACL_system.ucf

We also have to copy the file etc/download.cmd used by iMPACT.




Edit the project file LX9_AXI_ACL_system.xmp and change the MHS and UCF file names.




Xilinx Platform Studio XPS

Start XPS and load the new project.




We will remove the following IPs:

  • SPI_FLASH
  • axi_pwm_0
  • axi_timer
  • microblaze_0_intc


Adding the ADI peripheral core

The custom AXI-based IP core is written in Verilog and is a subset of the MicroBlaze project. This core is controlled by software running on the MicroBlaze processor as well as interrupts from the accelerometer. The processor can program any of the internal accelerometer's configuration registers as well as read any of its data registers through this IP core. The IP core continuously updates position data based on interrupts received from the accelerometer.

A state machine inside cf_adxl345.v handles all of the transactions from the processor. It sits in an idle state waiting for stimulus from the processor or accelerometer. The processor can initiate reads and writes through a command register at address 0x00. Meanwhile, the state machine also responds to interrupts from the accelerometer indicating new data is available. The BW_RATE Register (0x2C) dictates the refresh rate of the accelerometer. 




The IP core is included in the file "Avnet_SP6LX9_MicroBoard_ADI_ACL_AXI_Pmod_13_2_01.zip" that can be downloaded from the Avnet support site. When unpacked it locks like this:




Adding the IP core

  1. Copy the directory cf_adxl345_core_v1_00_a to our own pcores directory.
  2. From the Project menu select <Rescan User Repositories>
  3. The IP core will show up in the User section of the IP catalog



Add the IP core to our system.




Rename the IP core to ADXL345. here is the result.




Connect all ports to external pins.




Here is the final result : LX9_AXI_ACL_system.mhs

Edit the constraints file: LX9_AXI_ACL_system.ucf




The LX9 MicroBoard


Connect the Pmod board to the connector J4.




We are ready to write the software to control our accelerometer. See next part.


Top Previous  Next



Posted at 04:15 pm by svenand
Comments (4)  

 
Tuesday, December 20, 2011
FPGA design from scratch. Part 89

Writing Linux device drivers

I sent an email to John Williams at PetaLogix and asked him if they had some information about writing Linux device drivers. Here is his answer:.

"We don't document how to write device drivers as such, since that is a
generic topic relevant across all Linux systems.

There is the petalinux-new-module command which is used to create a
template loadable module, which might be the first step of creating a
custom driver.

You might like to look at the UIO framework - userspace IO. We use it
a lot and it is a nice way of making simple driver interfaces".

I am not a Linux kernel expert and know nothing about the internals of the Linux kernel. Let's try the two other methods. 

Device drivers for custom hardware

For many types of devices, what is really needed is some way to handle an interrupt and provide access to the memory space of the device. The logic of controlling the device does not necessarily have to be within the kernel if the device does not need to take advantage of any of other resources that the kernel provides. In this tutorial, we will explore two ways of achieving direct access to the hardware from user space:

  • Direct access to device registers via /dev/mem 
  • User Space I/O (UIO) framework.


Writing a kernel driver is overkill for some devices, and the development process is more complicated because it requires writing kernel code. In this tutorial, we will create our first very simple UIO driver and learn how to load a module in Linux.

Userspace access via /dev/mem

"/dev/mem" is a virtual file representing the memory map of the whole system. To access the device from user space, we can open "/dev/mem", and then use mmap() to map the device to memory, and then we can access the device by using the pointer which points to the mapped memory. Here are some of the characteristics:

  • Userspace interface to system address space
  • Accessed via mmap() system call
  • Must be root or have appropriate permissions
  • Quite a blunt tool – must be used carefully
  • Can bypass protections provided by the MMU
  • Possible to corrupt kernel, device or other processes memory

Pro

  • Very simple – no kernel module or code
  • Good for quick prototyping / IP verification
  • peek/poke utilities
  • Portable (in a very basic sense)

Con

  • No interrupt handling possible
  • No protection against simultaneous access
  • Need to know physical address of IP
    Hard-code?

OK for prototyping – not recommended for production

Running an example

Run the following command to create an application called "gpio-dev-mem-test"




Here is the generated directory:




Replace the file gpio-dev-mem-test.c with the file that can be downloaded from here.

Enable the build and installation of the application from menuconfig by running:

--> petalinux-config-apps






Save the configuration.

Build a new image

Run make to compile the application and build it into the Linux image.

--> cd $PETALINUX/software/petalinux-dist

--> make

Boot the board

For instruction on how to boot the system see part 76. After logging in to the Linux, try the gpio-dev-mem-test command to directly access the GPIO devices.



This command will turn on all four LEDs on the board.


Creating an UIO driver

In this section we will create an UIO driver using the enhanced generic UIO framework. We will start by generating a new application called "gpio-uio-test".



 

Replace the file gpio-uio-test.c with the file that can be downloaded from here.

Configure user application

Run petalinux-config-apps and select the <gpio-uio-test> application.



Save the configuration.

Configure the kernel to support UIO

Although, we can implement the control logic of the devices totally in user space, we need to enable the UIO framework in the kernel. We will configure the UIO subsystem to be built as a loadable module. However, it is also possible to build it directly into the kernel if we prefer.

Run petalinux-config-kernel to open the kernel menuconfig

--> petalinux-config-kernel

Select Device Drivers



In the Device Drivers menu scroll down to the "Userspace I/O drivers". Select it as a <M>.




Because the kernel is configured to support loadable modules by default, for those loadable device drivers,  we can select it as built-it or module. "<*>" means built-in and "<M>" means module. If a driver is selected as a module, it will not be loaded when booting Linux.  We can load it after Linux boots by using the modprobe command (see below).

Go into the "Userspace I/O Drivers" menu and mark the "Userspace I/O platform driver with generic IRQ handling".


 

Exit the kernel menuconfig and save the configuration.


Identifying the device to be controlled by UIO

The "compatible" property on a device entry in the device tree (DTS) links the device to a kernel driver. We are going to mark the LEDs GPIO to be controlled as the UIO device, instead of the normal Xilinx GPIO device driver. The CTS file can be found here:




Edit the DTS file

We are going to use the UIO driver instead of the normal GPIO driver for our GPIO device (we have only one the 4bit LEDs). We will replace the compatible parameter line with: compatible="generic-uio"


Rebuilding and booting PetaLinux

Run make inside "petalinux-dist"

--> $PETALINUX/software/petalinux-dist

--> make

Reboot the system and login to the Linux system.




Load the UIO modules

Load the UIO modules using the following commands:

modprobe uio

modprobe uio_pdrv_genirq

List the active loaded modules with the lsmod command. We can find the information of the loaded modules from:  /sys/class/uio




Run mdev -s to make sure the /dev/uio0 correctly represents the UIO device. This command automatically creates device files in /dev for the devices found in: /sys/class/*




Try the gpio-uio-test command to turn on/off the LEDs on the board.


Top  Previous  Next



Posted at 08:32 am by svenand
Comments (2)  

 
Sunday, December 18, 2011
FPGA design from scratch. Part 88

The Spartan-6 FPGA

We have finished the first phase of our FPGA project and we managed to fit the design in the Spartan-6 FPGA on the LX9 MicroBoard. Let's take a closer look at the FPGA device itself and try to understand how we can build our system using the logic in the FPGA. We will use the information we get from PlanAhead when we  enter Design Analysis.



The Spartan-6 product specification

The Spartan-6 family provides leading system integration capabilities with the lowest total cost for high-volume applications. The thirteen-member family delivers expanded densities ranging from 3,840 to 147,443 logic cells, with half the power consumption of previous Spartan families, and faster, more comprehensive connectivity.

Built on a mature 45 nm low-power copper process technology that delivers the optimal balance of cost, power, and performance, the Spartan-6 family offers a new, more efficient, dual-register 6-input look- up table (LUT) logic and a rich selection of built-in system-level blocks. These include 18 Kb (2 x 9 Kb) block RAMs, second generation DSP48A1 slices, SDRAM memory controllers, enhanced mixed-mode clock management blocks, SelectIO technology, power-optimized high-speed serial transceiver blocks, PCI Express compatible Endpoint blocks, advanced system-level power management modes, auto-detect configuration options, and enhanced IP security with AES and Device DNA protection.




Spartan-6 XC6SLX9

The FPGA device on the LX9 MicroBoard is the XC6SLX9. Here is the LX9_LXN_system implementation device view taken from PlanAhead:



Memory Controller Block

The MCB is a dedicated embedded block multi-port memory controller that greatly simplifies the task of interfacing Spartan-6 devices to the most popular memory standards.  The MCB provides significantly higher performance, reduced power consumption, and  faster development times than equivalent IP implementations. The embedded block  implementation of the MCB conserves valuable FPGA resources and allows the user to  focus on the more unique features of the FPGA design. Here is a block diagram showing the content of the MCB. The IP wrapper can be generated using the Core Generator. For more information see the Xilinx UG416 Spartan-6 FPGA Memory Interface Solutions.

The EDK library has a pre-configured memory controller called MCB3_LPDDR which we have used in our design.




The DSP48A1 DSP element

The DSP48A1 slice  the digital signal processing (DSP) element in Spartan®-6 FPGAs. Each DSP48A1 slice forms the basis of a versatile, coarse-grained DSP architecture. The DSP48A1 slices support many independent functions, including multiplier, multiplier-accumulator (MACC), pre-adder/subtracter followed by a multiply-accumulator, multiplier followed by an adder, wide bus multiplexers, magnitude comparator, or wide counter. The architecture also supports connecting multiple DSP48A1 slices to form wide math functions, DSP filters, and complex arithmetic without the use of general FPGA logic. Here is the user guide..


DSP48A1 slice in detail




The BRAM block

The block RAM in Spartan-6 FPGAs stores up to 18K bits of data and can be configured as either two independent 9 Kb RAMs, or one 18 Kb RAM. Each RAM can be addressed through two ports, but can also be configured as a single-port RAM. The block RAM resources include output registers to increase pipeline performance. Block RAMs are placed in columns. The total number of block RAMs depends on the size of the Spartan-6 device.
Similar to other Xilinx FPGA block RAMs, Write and Read are synchronous operations; the two ports are symmetrical and totally independent, sharing only the stored data. Each port can be configured in one of the available widths, independent of the other port. The memory content can be initialized or cleared by the configuration bitstream. During a write operation the memory can be set to have the data output either remain unchanged, reflect the new data being written or the previous data now being overwritten. Embedded dual- or single-port RAM modules, ROM modules, synchronous FIFOs, and data-width converters are easily implemented using the Xilinx CORE Generator block memory modules. Dual-clock FIFOs can be generated using the CORE Generator FIFO Generator module.


The BRAM Block is a configurable memory module that attaches to a variety of BRAM Interface Controllers. The BRAM Block structural HDL is generated by the EDK design tools based on the configuration of the BRAM interface controller IP. All BRAM Block parameters are automatically calculated and assigned by the Platgen and Simgen EDK tools. More information can found in the user guide.


Clock Management Tiles

The Spartan-6 FPGA Clock Management Tiles (CMTs) provide very flexible, high-performance clocking. The Spartan-6 FPGA CMT blocks are located in the center column along the vertical global clock tree. Each CMT block contains two DCMs and one PLL. For more information see the user guide.




Phase Lock Loop (PLL)

The main purpose of PLLs is to serve as a frequency synthesizer for a wide range of frequencies, and to serve as a jitter filter for either external or internal clocks in conjunction with the DCMs of the CMT. The PLL block diagram shown in the figure provides a general overview of the PLL components.




Input MUXes select the reference and feedback clocks from either the IBUFG, BUFG, IBUF, PLL outputs, or one of the DCMs. Each clock input has a programmable counter D. The Phase-Frequency Detector (PFD) compares both phase and frequency of the input (reference) clock and the feedback clock. Only the rising edges are considered because as long as a minimum High/Low pulse is maintained, the duty cycle is not important.

The PFD is used to generate a signal proportional to the phase and frequency between the two clocks. This signal drives the Charge Pump (CP) and Loop Filter (LF) to generate a reference voltage to the Voltage Controlled Oscillator (VCO). The PFD produces an up or down signal to the charge pump and loop filter to determine whether the VCO should operate at a higher or lower frequency.

When VCO operates at too high of a frequency, the PFD activates a down signal, causing the control voltage to be reduced, which decreases the VCO operating frequency. When the VCO operates at too low of a frequency, an up signal will increase voltage. The VCO produces eight output phases. Each output phase can be selected as the reference clock to the output counters. Each counter can be independently programmed for a given customer design. A special counter, M, is also provided. This counter controls the feedback clock of the PLL allowing a wide range of frequency synthesis.


Digital Clock Managers

Digital Clock Managers (DCMs) provide advanced clocking capabilities to Spartan-6 FPGA applications. Primarily, DCMs eliminate clock skew, thereby improving system performance. Similarly, a DCM optionally phase shifts the clock output to delay the incoming clock by a fraction of the clock period. DCMs optionally multiply or divide the incoming clock frequency to synthesize a new clock frequency. The DCMs integrate directly with the global low-skew clock distribution network.




Open implemented design

In PlanAhead select <Open Implemented Design> from the <Implemented Design> menu.




Zooming in

To zoom in press the left mouse button and drag the cursor from upper right corner to the lower left corner.








Slice description

Every slice contains four logic-function generators (or look-up tables, LUTs) and eight storage elements. These elements are used by all slices to provide logic and ROM functions (Table 1). SLICEX is the basic slice. Some slices, called SLICELs, also contain an arithmetic carry structure that can be concatenated vertically up through the slice column, and wide- function multiplexers. The SLICEMs contain the carry structure and multiplexers, and add the ability to use the LUTs as 64-bit distributed RAM and as variable-length shift registers (maximum 32-bit). For more information see Spartan-6 FPGA Configurable Logic Block User Guide.



One single slice




One single LUT

The function generators in Spartan-6 FPGAs are implemented as six-input look-up tables (LUTs). There are six independent inputs (A inputs - A1 to A6) and two independent outputs (O5 and O6) for each of the four function generators in a slice (A, B, C, and D). The function generators can implement any arbitrarily defined six-input Boolean function. Each function generator can also implement two arbitrarily defined five-input Boolean functions, as long as these two functions share common inputs. Only the O6 output of the function generator is used when a six-input function is implemented. Both O5 and O6 are used for each of the five-input function generators implemented. 





Top Previous  Next


Posted at 04:23 pm by svenand
Comments (2)  

Next Page