Add simple multiboot example for ECP5-EVN Signed-off-by: Jens Andersen <jens.andersen@gmail.com>
diff --git a/examples/ecp5_evn_multiboot/Makefile b/examples/ecp5_evn_multiboot/Makefile new file mode 100644 index 0000000..948aad5 --- /dev/null +++ b/examples/ecp5_evn_multiboot/Makefile
@@ -0,0 +1,23 @@ +all: multiboot.mcs + +%.json: %.v + yosys -p "synth_ecp5 -json $@" $< + +%_out.config: %.json + nextpnr-ecp5 --json $< --textcfg $@ --um5g-85k --package CABGA381 --lpf ecp5evn.lpf + +%.bit: %_out.config + ecppack $< $@ + + +multiboot.bin: blinky1.bit blinky2.bit + ecpmulti --flashsize 128 --input blinky1.bit --input blinky2.bit --address 0x00250000 $@ + +multiboot.mcs: multiboot.bin + srec_cat $< -Binary -unfill 0xFF -Bit_Reverse=2 -Byte-Swap -o $@ -Intel + +clean: + rm -f *.svf *.bit *.config *.json multiboot.bin multiboot.mcs + +.PHONY: prog clean +.PRECIOUS: blinky1.json blinky1_out.config blinky1.bit blinky2.json blinky2_out.config blinky2.bit multiboot.bin multiboot.mcs
diff --git a/examples/ecp5_evn_multiboot/README.md b/examples/ecp5_evn_multiboot/README.md new file mode 100644 index 0000000..2f78a3a --- /dev/null +++ b/examples/ecp5_evn_multiboot/README.md
@@ -0,0 +1,18 @@ +# Purpose +This example contains two separate verilog implementations +1) Blinks LED 0 on EVN board +2) Blinks LED 7 on EVN board + +It generates a multiboot.bin file as well as a suitable multiboot.mcs file. +Once flashed, pressing PROGRAMN button will switch between the available +bitstreams. + +# Usage +In order to use, it must be flashed to the ECP5-EVN board. +This can be done with the official programmer from lattice. +The generated MCS (Intel Hex) file is sufficiently compatible with Lattice to +allow flashing. +However, flashing the bin/hex any other way should also work. +Due to padding with SPI Flash erase byte, it will be significantly faster to +flash the hex file. +
diff --git a/examples/ecp5_evn_multiboot/blinky1.v b/examples/ecp5_evn_multiboot/blinky1.v new file mode 100644 index 0000000..f4fac91 --- /dev/null +++ b/examples/ecp5_evn_multiboot/blinky1.v
@@ -0,0 +1,9 @@ +module top(input clk, input btn, output [7:0] led); + reg [23:0] cnt = 0; + + always@(posedge clk) begin + cnt <= cnt + 1; + end + assign led[0] = cnt[22]; + assign led[7:1] = 7'b1111111; +endmodule
diff --git a/examples/ecp5_evn_multiboot/blinky2.v b/examples/ecp5_evn_multiboot/blinky2.v new file mode 100644 index 0000000..d2fc694 --- /dev/null +++ b/examples/ecp5_evn_multiboot/blinky2.v
@@ -0,0 +1,9 @@ +module top(input clk, input btn, output [7:0] led); + reg [23:0] cnt = 0; + + always@(posedge clk) begin + cnt <= cnt + 1; + end + assign led[7] = cnt[22]; + assign led[6:0] = 7'b1111111; +endmodule
diff --git a/examples/ecp5_evn_multiboot/ecp5evn.lpf b/examples/ecp5_evn_multiboot/ecp5evn.lpf new file mode 100644 index 0000000..bd32c6d --- /dev/null +++ b/examples/ecp5_evn_multiboot/ecp5evn.lpf
@@ -0,0 +1,23 @@ +LOCATE COMP "clk" SITE "A10"; +IOBUF PORT "clk" IO_TYPE=LVCMOS33; + +LOCATE COMP "btn" SITE "P4"; +IOBUF PORT "btn" IO_TYPE=LVCMOS33; + +LOCATE COMP "led[0]" SITE "A13"; +LOCATE COMP "led[1]" SITE "A12"; +LOCATE COMP "led[2]" SITE "B19"; +LOCATE COMP "led[3]" SITE "A18"; +LOCATE COMP "led[4]" SITE "B18"; +LOCATE COMP "led[5]" SITE "C17"; +LOCATE COMP "led[6]" SITE "A17"; +LOCATE COMP "led[7]" SITE "B17"; + +IOBUF PORT "led[0]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[1]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[2]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[3]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[4]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[5]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[6]" IO_TYPE=LVCMOS33; +IOBUF PORT "led[7]" IO_TYPE=LVCMOS33;