Michael Welling
07/08/2024, 3:38 AMmodule 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
endmoduleFabien Marteau
10/02/2024, 8:29 PMMichael Welling
10/02/2024, 8:50 PMMichael Welling
10/02/2024, 8:52 PMMichael Welling
10/02/2024, 8:53 PMMichael Welling
10/02/2024, 10:16 PM#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
}
}
}Fabien Marteau
10/03/2024, 8:39 AMFabien Marteau
10/03/2024, 7:07 PMMichael Welling
10/03/2024, 8:03 PMMichael Welling
10/03/2024, 8:11 PMFabien Marteau
10/04/2024, 7:12 AMMichael Welling
10/05/2024, 12:58 AMMichael Welling
10/05/2024, 12:58 AMMichael Welling
10/05/2024, 12:59 AMvoid 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
}
}
}Michael Welling
10/05/2024, 1:31 AMmodule 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;
endmoduleMichael Welling
10/05/2024, 1:37 AMMichael Welling
10/05/2024, 1:38 AMMichael Welling
10/05/2024, 1:39 AMMichael Welling
10/05/2024, 1:40 AMMichael Welling
10/05/2024, 1:41 AMMichael Welling
10/05/2024, 1:46 AMFabien Marteau
10/06/2024, 6:20 PM