```module fpga_pov ( input clk, outp...
# clear
m
Copy code
module fpga_pov (
    input       clk,
    output reg [9:0] led
);

reg [17:0] cnt = 0;

always @(posedge clk)
    cnt <= cnt + 1;

always @(cnt)
    case(cnt[17:14])
         0: led <= 10'b0111111000;
         1: led <= 10'b1000000100;
         2: led <= 10'b1010010100;
         3: led <= 10'b1000000100;
         4: led <= 10'b1011110100;
         5: led <= 10'b1001100100;
         6: led <= 10'b1000000100;
         7: led <= 10'b0111111000;
        default: led <= 10'b0000000000;
    endcase
endmodule
πŸ‘ 2
f
Is it possible to share the pinout pcf file for this code and the firmare (C file). Is firmware C file necessary ? Many thanks
I had the code loading the bitstream
πŸ‘ 1
And pinmux settings and flashing a LED
Copy code
#include <common.h>
#include <fpga_pwm8.h>

static void delay(int delayTime) { volatile int i; for(i = 0; i < delayTime; i++); }

void configure_gpio_for_bitstream_programming()
{
	// FPGA IOs
	configure_gpio(1, GPIO_MODE_USER_STD_INPUT_NOPULL);	// FPGA isol_n
	configure_gpio(9, GPIO_MODE_USER_STD_INPUT_NOPULL);	// FPGA reset
	configure_gpio(23, GPIO_MODE_USER_STD_OUTPUT);		// FPGA ccff_tail
	configure_gpio(29, GPIO_MODE_USER_STD_INPUT_PULLUP);	// FPGA prog_reset
	configure_gpio(34, GPIO_MODE_USER_STD_INPUT_NOPULL);	// FPGA ccff_head
	configure_gpio(35, GPIO_MODE_USER_STD_INPUT_PULLUP);	// FPGA clk_sel
	configure_gpio(37, GPIO_MODE_USER_STD_INPUT_NOPULL);	// FPGA prog_clk

	// == Caravel IOs to drive FPGA IOs  
	configure_gpio(24, GPIO_MODE_MGMT_STD_OUTPUT);		// connected to prog_clk
	configure_gpio(19, GPIO_MODE_MGMT_STD_OUTPUT);		// connected to prog_rst
	configure_gpio(18, GPIO_MODE_MGMT_STD_OUTPUT);		// connected to op_rst
	configure_gpio(17, GPIO_MODE_MGMT_STD_OUTPUT);		// connected to isol_n
	configure_gpio(20, GPIO_MODE_MGMT_STD_OUTPUT);		// connected to ccff_head
	configure_gpio(21, GPIO_MODE_MGMT_STD_OUTPUT);		// connected to clk_sel

	// Load the GPIO configuration 
	gpio_config_load();
}

void main()
{
	int i;

	configure_gpio_for_bitstream_programming();
	process_bit_stream(fpga_smiley_size, fpga_smiley);

	configure_mgmt_gpio();
	mgmt_gpio_wr(1); // turn on the LED

	configure_gpio(36, GPIO_MODE_USER_STD_INPUT_PULLUP);
	//configure_gpio(21, GPIO_MODE_USER_STD_OUTPUT);
	//configure_gpio(24, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(25, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(26, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(27, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(28, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(30, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(31, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(32, GPIO_MODE_USER_STD_OUTPUT);
	configure_gpio(33, GPIO_MODE_USER_STD_OUTPUT);

	gpio_config_load();

	while (1) {
		for (i = 0; i < 0x100; i++) {
			delay(100000);
			mgmt_gpio_wr(i % 2); // toggle the LED
		}
	}
}
πŸ‘ 1
f
I wonder why clock is not assigned in fpga_smiley.pcf ? It's automatically detected and placed ?
On my program, the clock seems to be plugged on fpga_prg clock. Once fpga is configured (and gpio led is on) the pwm output (pin 24 -> fpga io 127) is 0 :(
m
The clock assignment in pcf is not clearly stated anywhere
Think there is only one clock and user pads cannot be used for the clock input. It is definitely not CLEARly documented.
πŸ‘ 1
f
But how did you connect the clock to the fpga_pwm8?
m
same way
but I was using LA line to drive the width and it was not working
Copy code
void main()
{
        int i;

        configure_gpio_for_bitstream_programming();
        process_bit_stream(fpga_pwm8_size, fpga_pwm8);

        configure_mgmt_gpio();
        mgmt_gpio_wr(1); // turn on the LED

        configure_gpio(30, GPIO_MODE_USER_STD_OUTPUT);  // pwm
        gpio_config_load();

        set_la_ien(LA_REG_3,0xFFFFFFFF);
        delay(100);
        set_la_oen(LA_REG_3,0x00000000);
        delay(100);
        gpio_config_load();

        while (1) {
                for (i = 0; i < 0x100; i++) {
                        set_la_reg(LA_REG_3, i << 23);
                        delay(100000);
                        mgmt_gpio_wr(i % 2); // toggle the LED
                }
        }
}
Copy code
module fpga_pwm8 (
    input       clk,
    input [7:0] duty,
    output      pwm
);

reg [7:0]   cnt = 0;

always @(posedge clk)
    cnt <= cnt + 1;

assign pwm = (cnt < duty) ? 1 : 0;

endmodule
if I used a fixed duty in the code it would work but did not work dynamically sweeping the duty
last ditch effort would be trying to slow the clock further
was not bored enough to write a bitbanged driver for the clock generation
especially because they didn't follow the schematic recommended by FTDI for i2c
supposed we could use a flying wire to inject a clock from external source
to me it seems there is clock issue with the design
f
Ok, thank