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

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
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
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).Drive the expansion board LEDs with 1'b0 (on) and 1'bz (off)
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
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]
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
Is anyone else working with the GPIO board?