XB-100 GPIO expansion board

Discussions related to embedded firmware, driver, and user mode application software development
Post Reply
aaron
Posts: 1
Joined: Sat Mar 14, 2015 3:13 am

XB-100 GPIO expansion board

Post by aaron »

I got this board to play and learn about the FPGA, but it seems there is little documentation about how to use it. So here is (the first?) thread about the GPIO board.
I am a programmer but pretty much new to FPGAs. Here is what I have done so far. Maybe someone can find my mistakes helpful, or just find my mistakes :D .

I started a quartus project from scratch. I read the readme and I realize there is supposed to be a cool way to make a new revision of the bladerf base, but that seemed too complicated for me. I don't really want to use (learn) the Quartus software if I don't have to. I am not a GUI fan when it comes to coding. So I have a single qsf file and a verilog file. Then I can compile from the command line:

Code: Select all

# Everyone says to run this command first to set up the shell environment, so OK.
> /opt/altera/13.1/nios2eds/nios2_command_shell.sh

# I only have a qsf file so I start like this
> quartus_map -r led_blink.qsf

# That creates a .qpf project file so I can then just use the basename
> quartus_fit led_blink
> quartus_asm led_blink

# Then load it up
> bladeRF-cli -l output_files/led_blink.rbf
I just copied the pin definitions from base.qsf to my own qsf file. I renamed some of the exp_gpio pins in the qsf file to have more helpful names.

Code: Select all

# switches
	set_location_assignment PIN_A16 -to sw[1]
	set_location_assignment PIN_A15 -to sw[2]
	set_location_assignment PIN_A13 -to sw[3]
	set_location_assignment PIN_D15 -to sw[4]
# buttons
	set_location_assignment PIN_C15 -to btn[6]
	set_location_assignment PIN_B15 -to btn[7]
	set_location_assignment PIN_B14 -to btn[8]
	set_location_assignment PIN_C13 -to btn[9]
	set_location_assignment PIN_F11 -to btn[10]
# expansion leds (I renamed the three main-board LEDs to main_led)
	set_location_assignment PIN_B19 -to led[1]
	set_location_assignment PIN_A18 -to led[2]
	set_location_assignment PIN_A20 -to led[3]
	set_location_assignment PIN_A17 -to led[4]
	set_location_assignment PIN_B18 -to led[5]
	set_location_assignment PIN_A14 -to led[6]
	set_location_assignment PIN_A19 -to led[7]
	set_location_assignment PIN_B20 -to led[8]
# the RGB leds
	set_location_assignment PIN_C17 -to ledR
	set_location_assignment PIN_B17 -to ledG
	set_location_assignment PIN_B16 -to ledB
After trying to drive the expansion LEDs like the main-board LEDs (logic high and low), I realized that the LEDs is driven by 5v power. So even driving a logic high (1.8v) still leaves the LED dimly lit. I tried changing the IO_STANDARD to 2.5v and maybe broke something that way. Finally, I realized I should just drive it low for on and high-z for off (duh).
Drive the expansion board LEDs with 1'b0 (on) and 1'bz (off)
I found they were really bright so I also changed the drive strength to 2mA. This also disables the 50ohm termintation resistor (for better or worse).

Code: Select all

set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[1]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[2]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[3]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[4]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[5]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[6]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[7]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to led[8]
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to ledR
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to ledG
set_instance_assignment -name CURRENT_STRENGTH_NEW 2MA -to ledB
For the switches and buttons they should have the pullup resistor enabled.

Code: Select all

set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to btn[6]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to btn[7]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to btn[8]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to btn[9]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to btn[10]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to sw[1]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to sw[2]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to sw[3]
set_instance_assignment -name WEAK_PULL_UP_RESISTOR ON -to sw[4]
Then I have some verilog code to turn on some LEDs. I left out the code to drive the default values for all the other peripherals (lms, fx3, etc...). That info comes directly from the bladerf-base.vhd source file.

Code: Select all


module drive_LED(clk, led, strength);
	input [7:0] strength;
	input clk;
	output led;
	
	reg led;
	reg [7:0] counter;

	always @ (posedge clk) begin
		counter = counter + 1;
		if (strength == 0) begin
			led <= 1'bz;
		end else begin
			if (counter <= strength) begin
				led <= 1'b0;
			end else begin
				led <= 1'bz;
			end
		end
	end
endmodule

module btn_to_LED(clk, btn, led);
	input clk, btn;
	output led;
	reg led;
	
	always @ (posedge clk) begin
		if (!btn) begin
			led <= 1'b0;
		end else begin
			led <= 1'bz;
		end
	end
endmodule

module led_blink(c4_clock, ledR, ledG, ledB, btn, led, sw);
	input c4_clock;

	// Expansion Interface
	input [10:6] btn;
	input [4:1] sw;
	output [8:1] led;
	output ledB, ledG, ledR;

	btn_to_LED(c4_clock, btn[10], led[1]);
	btn_to_LED(c4_clock, btn[9], led[2]);
	btn_to_LED(c4_clock, btn[8], led[3]);
	btn_to_LED(c4_clock, btn[7], led[4]);
	btn_to_LED(c4_clock, btn[6], led[5]);
	
        drive_LED(c4_clock, led[6], 8'd1);
	drive_LED(c4_clock, led[7], 8'd128);
	drive_LED(c4_clock, led[8], 8'd255);
	
	drive_LED(c4_clock, ledR, 8'd128);
	drive_LED(c4_clock, ledG, 8'd64);
	drive_LED(c4_clock, ledB, 8'd32);
	
endmodule
And that's all I've learned so far. I think I managed to break a button and three LEDs. Button 10 is stuck low for some reason. LED4, LED5, and LED6 are always dimly on. I can't get them to turn fully off, but they still turn on brightly when commanded to. ledR and ledG of the big RGB LED have this same problem. Does anyone else have problems like this? Is there something I can do to fix this or did I fry the pin?

Is anyone else working with the GPIO board?
Hamza
Posts: 6
Joined: Wed Jan 28, 2015 8:32 pm

Re: XB-100 GPIO expansion board

Post by Hamza »

hi Aaron ...

i have just procured the expansion board. Like you i am building my project from scratch and using expansion board to help me in my FPGA learning. However i am completely naive towards coding fpga via VHDL ( i was more of a LabView guy :) ) . my main goal is to implement a DDS operation in fpga. its a beautiful project But, i know, a long journey remains ahead.

Anyways u asked for assistance, which i would be more then happy to provide but at the present moment i am not at that level. i will keep on sharing my results in forum hope that would be of some help to you too ,meanwhile with your experience on board and fpga i will be grateful if u can give me a jump start in the same direction. This would definitely save a lot of time and help me bring my results to community at earliest.

Regards !
Post Reply