微處理器 - Gowin GW2AR-LV18QN88C8/I7 (Lichee Tang Nano 20K) - Verilog - LED



參考資訊:
https://github.com/YosysHQ/apicula/tree/master/examples
https://github.com/YosysHQ/apicula/wiki/Nextpnr%E2%80%90Himbaechel-Gowin

main.v

module main (
    input clk,
    output reg led
);
  
reg [23:0] clk_cnt;
  
always @(posedge clk) begin
    if (clk_cnt == 24'd10000000)
        clk_cnt <= 24'd0;
    else
        clk_cnt <= clk_cnt + 1;
 
    if (clk_cnt == 24'd10000000)
        led <= ~led;
end
  
endmodule

main.cst

IO_LOC "led" 15;
IO_LOC "clk" 4;

Makefile

all:
	yosys -p "synth_gowin -json main.json -top main" main.v
	nextpnr-himbaechel --json main.json --write main.pack --device GW2AR-LV18QN88C8/I7 --vopt family=GW2A-18C --vopt cst=main.cst
	gowin_pack -d GW2AR-LV18QN88C8/I7 -o main.fs main.pack

ram:
	openFPGALoader -m -b tangnano20k main.fs

flash:
	openFPGALoader -f -b tangnano20k main.fs

clean:
	rm -f *.json *.fs *.pack

編譯、下載

$ make
$ make ram

完成