FPGA Blade board

Discussion to talk about hardware related topics only.
superbrew
Posts: 7
Joined: Mon Oct 21, 2013 7:13 pm

FPGA Blade board

Post by superbrew »

Hello,
I am new to the world of FPGA's. I was given a PK70 with the FPGA blade board and I am just trying to get a simple 'Hello World' program working. I am somewhat familiar with VHDL from a class in my EE program, but not enough to get this working.
I started with the Xilinx Demo included with the NBEclipse environment, but I do not understand Verilog. I have created a project in the Xilinx ISE using the following code:

Code: Select all

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity LED_Blink is
	port (
		CLK_50MHz: in std_logic;
		LED: out std_logic
	);
end LED_Blink;

architecture Behavioral of LED_Blink is
signal blink : std_logic := '1';	
begin

	process(CLK_50MHz)
	variable Counter:integer:=0;
	
	begin
		if (CLK_50MHz'event and CLK_50MHz='1') then
			if Counter = 50000000 then
				Counter:=0;
				blink <= not blink;
			else
				Counter:= Counter + 1;
			end if;
		end if;
	end process;
	
	LED <= blink;
	
end Behavioral;
Here is my constraints file:

Code: Select all

NET "CLK_50MHz" LOC = "P177" | IOSTANDARD = LVTTL;
NET "LED" LOC = "P199" | IOSTANDARD = LVTTL;
I can compile the .bit file and it uploads to the PK70 with no errors, but the FPGA is not doing anything as far as I can tell.

Thanks in advance
superbrew
Posts: 7
Joined: Mon Oct 21, 2013 7:13 pm

Re: FPGA Blade board

Post by superbrew »

Is this not the place to ask these types of questions?
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: FPGA Blade board

Post by rnixon »

Just an opinion: I think FPGA, Verilog and VHDL questions might get a better response on the Xilinx boards. From the netburner side of things it just loads the xilinx image into the xilinx part. The type of questions you would ask here relate to the embedded programming languages like C/C++, networking, the NetBurner development environment, etc. I don't know how many people here know VHDL, but some might. In other words, probably everything other than how to program in Verilog/VHDL.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: FPGA Blade board

Post by rnixon »

Although I for one would really like to learn that as well. So if you get something working and feel like contributing it would be great if you could post something.
mbrown
Posts: 61
Joined: Tue Jan 29, 2013 7:12 pm

Re: FPGA Blade board

Post by mbrown »

@superbrew:

I know enough about the FPGA blade to get you working with it, but not enough
about VHDL to tell you exactly what is going wrong. I'm going to detail a number
of things you can try and go through the example included in our source so that
you have a few different ways you can go about trying to get your board working.
I'm going to start with getting your hardware and the Eclipse IDE working, then
talk about the example, and finally provide a few comments about your module.

First things first, there's a few things you'll need to know about the FPGA blade.
On the blade itself are several jumpers to determine how the FPGA is instantiated.
The important one if you're using all Netburner software to run things is JP2.
You'll want the cap for this jumper over pins 2 and 3. This sets the pins up so
that the board is brought up over SPI. I can't at this time tell you where in the
documentation it mentions this, but as this is the way my board is configured, I
believe you'll want to have yours set up this way as well. Next you should try
to get the example running. Even if you don't understand what's going on right now
(more on that in a moment), I would still go through the process of compiling the
code and downloading it to the PK70 to see that the serial output indeed matches
what is says it should (ie. "C001BEEF"). If you can't get it all working with the
documentation in \nburn\docs\Platform\PK70, you can import the compiled image from
the example folder and it may says something slightly different, "DEADBEEF" or
"CAFEBABE" if memory serves. If you have problems with these steps, let us know.

Secondly, let's open up that Verilog example and take a look at it to see what's
going on. Essentially, the .v file creates an interface that turns the FPGA into
an external memory port for the PK70. In main.cpp, we instantiate this external
memory device with the following.

Code: Select all

#define BASEADDRESS (0xC0000000)

sim.cs[2].csar = ( BASEADDRESS >> 16 );
sim.cs[2].cscr = 0x2140; /* 0010 0001 0110  0000 */
sim.cs[2].csmr = 0x001F0001;
volatile PBYTE pFpga=(volatile PBYTE) BASEADDRESS;
Now, whenever the Netburner device tries to read from a memory address that is an
offset of pFpga, it asks the FPGA what data is stored at that memory location. How
does it do this? The processor and the FPGA share a number of Address (referred to
as a in the verilog code) and Data lines (DataBus), along with a chip select (nCS2),
and a bit that determines whether the microprocessor is performing a read or a write (Rnw).
Similarly, whenever the processor writes to these locations, it drives this data into
the FPGA according to the addressing scheme. An example of this reading happens in the
following printf statement.

Code: Select all

iprintf("Locations readback                    %02X%02X%02X%02X %02X%02X\r\n",pFpga[10],pFpga[11],pFpga[12],pFpga[13],pFpga[14],pFpga[15]);
Whatever information is stored in address locations 10, 11, 12, 13, 14, and 15 is driven
onto the datalines and read by the processor. How does this work in the FPGA? Let's look
at the verilog file, XilinxBladGpio.v. The file instantiates one module, module XilinxBladeGpio.
The first few lines are verilog's way of instantiating the module with the given external
wire names. Then each of those wires has a type and size declared, followed by an internal
wiring or buffers used (here i, dir_reg, and drive_reg). Everything that follows is just the
behavioral definition of the module. First the direction and drive registers are set to 0,
then what follows is a description of what comes over the data bus as various memory addresses
are called from the micro-controller. As you can see, in addresses 10-15, the memory is
holding the string "C001BEEF". If you read the lower memory addresses, you could read the
state of the external pins on J2. Writing to the higher memory addresses modifies the direction
and drive registers which determine respectively whether the external pins are inputs or
outputs and if they are outputs what information is driven on those pins. Below that
assignment block, you can see how the direction and data registers drive individual pins
when used as outputs. You might at this point play around with the device, try to read some
of the pins, try to drive some of the pins, change the message and recompile the code, what
have you. If you're still with me so far, great, you should be most of the way there to
making your own application. Being able to make changes to your hdl and reload them onto
the module means you should be able to run whatever else you make on the blade.

Finally, it sounds like you're going to want to be using vhdl instead of verilog. It's not
my native hdl tongue unfortunately, so I can't tell you off hand if there were any problems
with your code. Usually what I end up doing with VHDL is making sure that the RTL image
generated by ISE what you expect it to be. If you see that the logic is being created the
way you expect it to be, and you've been able to confirm the board's hardware works so far,
the last things to check would be the external connections to the board. You've attached
a clock to one of the pins. I believe this is the flexbus clock, but I don't know off hand
what it's speed would be. If you have a scope, it would be a worthwhile activity to look
at the signal and see what speed it's actually coming out. If not, looking at the datasheets
for this is a good place to start. You'll also want to look at your external circuit. You're
driving J2_2 if you weren't aware. Is that the pin you are monitoring? If you're actually
using an LED, is there a current limiting resistor and is the diode arranged in the appropriate
direction? Just little questions to double check always good.

If anything here seems confusing or if you get stuck somewhere on here, tell us about it.
I'm sure there's a few people here that would be interested in hearing about your experience
like myself and rnixon. If you get everything working, great, let me know what kind of cool
stuff you end up building.
superbrew
Posts: 7
Joined: Mon Oct 21, 2013 7:13 pm

Re: FPGA Blade board

Post by superbrew »

Thank you mbrown. I have not tried all of your suggestions yet, but I appreciate the help. I will let you know how I make out.
superbrew
Posts: 7
Joined: Mon Oct 21, 2013 7:13 pm

Re: FPGA Blade board

Post by superbrew »

I am trying to get the demo working and I get the following in the output window:

**** Build of configuration Release for project FPGA_DEMO ****

**** Internal Builder is used for build ****
compfile XilinxDemo\BinPromImage.bin XilinxData XilinxSize XilinxDemo\XilinxImage.cpp
Reading file from XilinxDemo\BinPromImage.bin and putting them in XilinxDemo\XilinxImage.cpp with the name XilinxData Size var = XilinxSize
Build error occurred, build is stopped
Time consumed: 406 ms.

What could be causing this?

I have a NBEclipse project that I got from work that seems to work, in the sense that it compiles and loads.
mbrown
Posts: 61
Joined: Tue Jan 29, 2013 7:12 pm

Re: FPGA Blade board

Post by mbrown »

Hm, that's kind of an odd place to get an error. You did import a .bit file into your Eclipse workspace that was then generated into a .bin file correct? If you had a working image before (by importing a .bit file, and having it convert to a .bin, and eventually a .cpp file) then deleted the .bit file, Eclipse won't throw an error after running promgen, but will after running compfile. Usually the error is more that it has no variable information for XilinxData and XilinxSize after running a few more steps though. Apparently compfile doesn't return a lot of information when it runs. If you do have a XinilxImage.cpp file in your project, could you paste here the first few lines? They should be something like the following...

Code: Select all

/*Autogenerated data file */
extern const unsigned long XilinxSize; 
extern const unsigned char XilinxData[];
const unsigned long XilinxSize = 283776; 
const unsigned char XilinxData[283776] = {

255,255,255,255,85,153,170,102,12,0,1,128,0,0,0,224,
12,128,6,128,0,0,0,6,12,128,4,128,0,0,140,167,
12,128,3,128,128,67,4,201,12,0,3,128,0,0,0,0,
12,0,1,128,0,0,0,144,12,0,4,128,0,0,0,0,
12,0,1,128,0,0,0,128,12,0,2,0,10,128,40,89,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
Is this your first time going through all the steps in the user's guide, or have you been able to successfully generate a programming file, import the .bit file into Eclipse and have it generate a XilinxImage.cpp file before? I only ask because the error returned through Eclipse wasn't very helpful.
superbrew
Posts: 7
Joined: Mon Oct 21, 2013 7:13 pm

Re: FPGA Blade board

Post by superbrew »

I am dragging the .bit file that I generated in the Xilinx ISE into my NBEclipse project. I see the XilinxImage.cpp, but I don't see a .bin file anywhere.
Here is the first few lines of the XilinxImage.cpp:

Code: Select all

/*Autogenerated data file */
extern const unsigned long XilinxSize; 
extern const unsigned char XilinxData[];
const unsigned long XilinxSize = 283776;
const unsigned char XilinxData[283776] = {

255,255,255,255,85,153,170,102,12,0,1,128,0,0,0,224,
12,128,6,128,0,0,0,6,12,128,4,128,0,0,140,167,
12,128,3,128,128,67,4,201,12,0,3,128,0,0,0,0,
12,0,1,128,0,0,0,144,12,0,4,128,0,0,0,0,
12,0,1,128,0,0,0,128,12,0,2,0,10,128,40,89,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
It seems to be ok?

As a side note, I am sure that the PK70 is able to be programmed because I had another project where I am able to control the status LEDs.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: FPGA Blade board

Post by rnixon »

I never drag files because I don't know if its a copy operation or a link operation to a different location. I always use the import, which lets me confirm the file is copied into my project.
Post Reply