微處理器 - Lattice LCMXO2-1200HC-4SG32C - Verilog - LED



top.v

module main (
    input clk,
    output reg led
);
    
reg [23:0] cnt;

always @(posedge clk) begin
    if (cnt == 1000000) begin
        cnt = 0;
        led <= ~led;
    end else
        cnt = cnt + 1;
end
endmodule

top.lpf

LOCATE COMP "led" SITE "27";
LOCATE COMP "clk" SITE "28";

Makefile

all:
	yosys -p "synth_lattice -family xo2 -json top.json" top.v
	nextpnr-machxo2 --device LCMXO2-1200HC-4SG32C --lpf top.lpf --json top.json --textcfg top.txt
	ecppack --compress --jed-note "DESIGN NAME: top.ncd" --jed-note "DEVICE NAME: LCMXO2-1200HC-4QFN32" top.txt top.bit --jed top.jed

clean:
	rm -rf top.txt top.bit top.json top.jed

編譯

$ make

插入開發板到PC後,會新增一個隨身碟,只要將top.jed複製到該隨身碟即可完成燒錄