Electronic – FPGA, first steps

fpgaspartanxilinx

Well this is a continuation of my question on FPGA over here.

I finally selected a Digilent Atlys with a Spartan 6 FPGA, I don't have any prior experience of FPGA's although I have done some amount of work with micro-controllers.

I spent the last few days reading through data sheets of the FPGA, and I think it would be a good choice to start off with Verilog. I couldn't find any code examples though and even the data sheets are not newbie friendly.

I want to do some hand's on programming, simulation, synthesis now and this is what I want to do

  1. Generate an odd frequency, say 54Mhz from the FPGA (it runs on a 100Mhz clock) and route it to one of the pins. I would probably have to use the DCM or PLL for this, but no idea how to start here?

  2. Implement some sort of I2C read write from the FPGA.

What I'm looking for is a reference, possibly an online one or a book that gives me code examples and description of each of the hardware components available inside the FPGA, like DCM's, slices, clb's etc.

I guess that should get me started into the world of FPGA's.

Best Answer

Code Examples

Hop over to OpenCores and you will find dozens of open source projects. There are many written in Verilog and cover the gamut from I/O devices through to processors.

Also, do not forget the many Application Notes available from Xilinx. They are very helpful with their own devices.

Design Flow

Pick up a book or two on design flow so that you get an overview on the steps involved in FPGA design. In summary, they will involve:

  1. Design entry - in your case, Verilog.
  2. Functional simulation - using various tools.
  3. Synthesis - in your case, using the Xilinx ISE tools.
  4. Simulation - to verify your post-synthesis design because some aspects of Verilog are not synthesisable.
  5. Place & Route - using the Xilinx ISE tools.
  6. Implementation - downloading the design onto the FPGA.
  7. Testing.

FPGA Components

As for using the FPGA components, there are different ways to use them. But assuming that you are using a Verilog design entry, you can either infer or instantiate the different components.

Inference generally involves getting the synthesis tool to pick the best components to use based on the functionality that you require. The best example of this would be to design an adder.

By doing q <= a + b or q = a + b you can infer an adder. Both will infer the adder but there is a difference in when you use the blocking/non-blocking syntax.

Instantiation generally involves calling the exact library component in code. Some components just cannot be easily inferred in code - such as the DCM. You can use the ISE tools and examples to learn more about this.

The actual list of components themselves are provided by Xilinx in the Libraries Guide.

Protip

The best way to learn this is actually to experiment with short bits of code and run them through the ISE synthesis to see what it spits out. There are also plenty of examples in the ISE toolset itself.