Hi there,
first of all, many thanks for this piece of code! I really appreciate the effort and am happy that I don't have to rely on any IP cores.
For my current project, I want the Tang Nano 9K development board to act as a USB audio class device. So I loaded the fpga_top_usb_audio.v example, substituted the Altera PLL for a Gowin one, synthesized and uploaded. However, I couldn't get my Linux to recognize the USB device no matter what. I tried all the stupid things, I tried different USB cables, different FPGA pins, different computers, short cables, long cables, everything but it just wouldn't work. Now, I finally got it to work somehow, but its weird. Thats why I am opening an issue about it. Maybe other people who got it working on Sipeed devboards can share their experiences or people looking for errors in the future will find some guidance here.
So, what did make it work in the end?
wire clk60mhz;
Gowin_rPLL gen60mhz( // generate the 60 MHz clock for the USB library from the onboard 27 MHz crystal oscillator with an IP core
.clkout(clk60mhz), //output clkout
.clkin(clk27mhz) //input clkin
);
// the following code has no actual use, but it makes the USB stuff work somehow:
always @(posedge clk27mhz) begin // the sensitivity list can be any signal, for example clk27mhz, clk60mhz or button (coming from the physical reset button)
toggle <= ~toggle; // toggle is an output pin
end
So, yeah, just adding a random output that toggles sometimes makes the USB library work for me. When not toggling the output but setting it to a static 0 or 1, it doesn't work. When toggling the toggle register, but not assigning it to any physical output pin, it also doesn't work. Does anybody have an idea what could cause this behaviour or how I could make it work in another way? I am not really experienced with FPGAs, I only started out a few weeks ago.
Whats also suspicious is the led which should show whether USB is connected or not. On reset, the pin is 0 but goes to 1 after maybe three seconds without the cable ever plugged into a computer. When I plug the cable in, the led pin goes to 0 for a short amount of time and stays 1 afterwards forever, even if I unplug the cable again.
As for my physical constraints, they look like this:

Hi there,
first of all, many thanks for this piece of code! I really appreciate the effort and am happy that I don't have to rely on any IP cores.
For my current project, I want the Tang Nano 9K development board to act as a USB audio class device. So I loaded the fpga_top_usb_audio.v example, substituted the Altera PLL for a Gowin one, synthesized and uploaded. However, I couldn't get my Linux to recognize the USB device no matter what. I tried all the stupid things, I tried different USB cables, different FPGA pins, different computers, short cables, long cables, everything but it just wouldn't work. Now, I finally got it to work somehow, but its weird. Thats why I am opening an issue about it. Maybe other people who got it working on Sipeed devboards can share their experiences or people looking for errors in the future will find some guidance here.
So, what did make it work in the end?
So, yeah, just adding a random output that toggles sometimes makes the USB library work for me. When not toggling the output but setting it to a static 0 or 1, it doesn't work. When toggling the toggle register, but not assigning it to any physical output pin, it also doesn't work. Does anybody have an idea what could cause this behaviour or how I could make it work in another way? I am not really experienced with FPGAs, I only started out a few weeks ago.
Whats also suspicious is the led which should show whether USB is connected or not. On reset, the pin is 0 but goes to 1 after maybe three seconds without the cable ever plugged into a computer. When I plug the cable in, the led pin goes to 0 for a short amount of time and stays 1 afterwards forever, even if I unplug the cable again.
As for my physical constraints, they look like this: