# Syntax of a Makefile target: # # target: dependency1 dependency2 ... # process (command to generate target from dependencies) # If no targets are specified when calling make, it will build the first target # in the file. The first target is usually called 'all' all: tb_leds.ghw leds.bin # Phony targets are always executed, even if a file with the same name exists # These are typically short names for other recipes .PHONY: all prog clean ################## ### Simulation ### ################## # Analyze vhdl sources for simulation leds.o: leds.vhd ghdl -a leds.vhd tb_leds.o: tb_leds.vhd ghdl -a tb_leds.vhd # Generate simulation executable tb_leds: tb_leds.o leds.o ghdl -e tb_leds # Generate simulation waveform tb_leds.ghw: tb_leds ./tb_leds --wave=tb_leds.ghw # Open gtkwave view: tb_leds.ghw gtkwave tb_leds.ghw ###################### ### Implementation ### ###################### # Synthesize leds.json: leds.vhd yosys -m ghdl -p 'ghdl leds.vhd -e leds; synth_ice40 -json leds.json' # Place and route leds.asc: leds.json nextpnr-ice40 --up5k --package sg48 --pcf leds.pcf --json leds.json --asc leds.asc # Bitstream generation leds.bin: leds.asc icepack leds.asc leds.bin # Configure the FPGA prog: leds.bin iceprog leds.bin ############### ### Cleanup ### ############### # Clean: clean: rm -f *.o *.ghw work-obj??.cf tb_leds rm -f *.json *.asc *.bin