Friday 20 April 2012

VHDL to Spartan tutorial

We will be attempting (and succeeding) to make a simple vhdl execute in spartan 3 fpga board, I am using the one from digilient.But if your's is different don't fret this tutorial will work just fine.

So go ahead and click on the xilinx ise (the one used here is 10.1 again if your's is different it works just fine),

Provide a meaningful name (unlike what a lazy guy like me have done) then click next


Please make sure it is selected to your board version ,here being spartan 3 and if you care to simulate then select an appropriate simulator.


Select a new source to create a new instance of a vhdl file.






We are here creating a vhdl file hence select the same,but in case you need to create any other instance you have to do the same sequence of operation

 

Specify the input and output port identities ,note even if you skip this step ,you can still edit in the entity of the program the same port data


  Code your program and check the syntax by clicking synthesize - XST - > Check Syntax

You can simulate the same by choosing behavioural and simulate using the specified simulator ,ise comes inherently with a ise simulator .You can even procure another simulator by the name modelsim



With that done we have verified the program syntax and logic

 
We need the vhdl module to communicate with the external world once synthesized into the fpga and hence we need to map the programming ports onto the peripheral present ,we do so by observing the peripheral id which in some instance (The spartan 3 of digilent provides the peripheral id just below the peripheral) will be provided on the board itself.The peripheral may be switches or LED's or 7 segment and so on.
Also note that you are forced to use the peripherals on the board and you will not be blessed by additional peripherals so in case your program needs a 32 bit data to be fed and you intend to feed the data through switches ,Then you are forced to use 8 such slide switches provided on the board .A possible way out is to use the 8 slide switches 4 times thus you may hence need a enable signal and map it to one of the four push buttons,to indicate a 8 bit is entered to the board.



The xilinx pace above will allow you to provide the location of the ports mapped to the peripherals.
In case it does not work you may create a new source as a implementation constraint file or the UCF and manually edit it.It looks something like:

#PACE: Start of Constraints generated by PACE

#PACE: Start of PACE I/O Pin Assignments
NET "a"  LOC = "g12"  ;
NET "b"  LOC = "f12"  ;
NET "c"  LOC = "p13"  ;
#PACE: Start of PACE Area Constraints

#PACE: Start of PACE Prohibit Constraints

#PACE: End of Constraints generated by PACE

Where a and b are mapped to switches and c to a led


Save it.and observe the ucf  file,you can also check the ucf file in the directory where you have saved this program


With that done we (most optimistically ) go to the end of the tool chain and execute the last task (Doing so will cause all the subsequent tasks to be executed but hey,it's a leap of faith all the same).




Select Boundary scan and if any other dialog boxes do open just press OK,





Whoa we are pretty close ,the impact gui tool will ask for your bit file ,select the vhdl-program-name.bit file and press ok,It the opens up another window just press bypass this time.




We then select our device ,that would be the green one and right click it to program.If everything is correct you will be greeted with a program succeeded message

Any day i'll vouch for one spartan board instead of 300 spartans

1 comment:

  1. Thanks dude this article really saved me from reading all the crude manual from xilinx

    ReplyDelete