<commit_before>
TOOLCHAIN_PREFIX = riscv32-unknown-elf-

all: example.bin

firmware.elf: firmware.S firmware.c firmware.lds
	$(TOOLCHAIN_PREFIX)gcc -Os -ffreestanding -nostdlib -o firmware.elf firmware.S firmware.c \
			--std=gnu99 -Wl,-Bstatic,-T,firmware.lds,-Map,firmware.map,--strip-debug -lgcc
	chmod -x firmware.elf

firmware.bin: firmware.elf
	$(TOOLCHAIN_PREFIX)objcopy -O binary firmware.elf firmware.bin
	chmod -x firmware.bin

firmware.hex: firmware.bin
	python3 ../../firmware/makehex.py firmware.bin 128 > firmware.hex

synth.blif: example.v ../../picorv32.v firmware.hex
	yosys -v3 -l synth.log -p 'synth_ice40 -top top -blif $@; write_verilog -attr2comment synth.v' $(filter %.v, $^)

example.asc: synth.blif
	arachne-pnr -d 8k -o example.asc -p example.pcf synth.blif

example.bin: example.asc
	icepack example.asc example.bin

example_tb.vvp: example_tb.v example.v firmware.hex
	iverilog -o example_tb.vvp -s testbench example.v example_tb.v ../../picorv32.v
	chmod -x example_tb.vvp

example_sim: example_tb.vvp
	vvp -N example_tb.vvp

example_sim_vcd: example_tb.vvp
	vvp -N example_tb.vvp +vcd

synth_tb.vvp: example_tb.v synth.blif
	iverilog -o synth_tb.vvp -s testbench synth.v example_tb.v `yosys-config --datdir/ice40/cells_sim.v`
	chmod -x synth_tb.vvp

synth_sim: synth_tb.vvp
	vvp -N synth_tb.vvp

synth_sim_vcd: synth_tb.vvp
	vvp -N synth_tb.vvp +vcd

route.v: example.asc
	icebox_vlog -L -n top -sp example.pcf example.asc > route.v

route_tb.vvp: example_tb.v route.v
	iverilog -o route_tb.vvp -s testbench route.v example_tb.v `yosys-config --datdir/ice40/cells_sim.v`
	chmod -x route_tb.vvp

route_sim: route_tb.vvp
	vvp -N route_tb.vvp

route_sim_vcd: route_tb.vvp
	vvp -N route_tb.vvp +vcd

prog_sram:
	iceprog -S example.bin

view:
	gtkwave example.vcd example.gtkw

clean:
	rm -f firmware.elf firmware.map firmware.bin firmware.hex
	rm -f synth.log synth.v synth.blif route.v example.asc example.bin
	rm -f example_tb.vvp synth_tb.vvp route_tb.vvp example.vcd

.PHONY: all prog_sram view clean
.PHONY: example_sim synth_sim route_sim
.PHONY: example_sim_vcd synth_sim_vcd route_sim_vcd
<commit_msg>scripts/icestorm: touch up Makefile a bit<commit_after>
TOOLCHAIN_PREFIX = riscv32-unknown-elf-

all: example.bin

firmware.elf: firmware.S firmware.c firmware.lds
	$(TOOLCHAIN_PREFIX)gcc -Os -ffreestanding -nostdlib -o $@ firmware.S firmware.c \
			--std=gnu99 -Wl,-Bstatic,-T,firmware.lds,-Map,firmware.map,--strip-debug -lgcc
	chmod -x $@

firmware.bin: firmware.elf
	$(TOOLCHAIN_PREFIX)objcopy -O binary $< $@
	chmod -x $@

firmware.hex: firmware.bin
	python3 ../../firmware/makehex.py $< 128 > $@

synth.blif: example.v ../../picorv32.v firmware.hex
	yosys -v3 -l synth.log -p 'synth_ice40 -top top -blif $@; write_verilog -attr2comment synth.v' $(filter %.v, $^)

example.asc: synth.blif example.pcf
	arachne-pnr -d 8k -o $@ -p example.pcf $<

example.bin: example.asc
	icepack $< $@

example_tb.vvp: example.v example_tb.v ../../picorv32.v firmware.hex
	iverilog -o $@ -s testbench $(filter %.v, $^)
	chmod -x $@

example_sim: example_tb.vvp
	vvp -N $<

example_sim_vcd: example_tb.vvp
	vvp -N $< +vcd

synth_tb.vvp: example_tb.v synth.blif
	iverilog -o $@ -s testbench synth.v example_tb.v `yosys-config --datdir/ice40/cells_sim.v`
	chmod -x $@

synth_sim: synth_tb.vvp
	vvp -N $<

synth_sim_vcd: synth_tb.vvp
	vvp -N $< +vcd

route.v: example.asc example.pcf
	icebox_vlog -L -n top -sp example.pcf $< > $@

route_tb.vvp: route.v example_tb.v
	iverilog -o $@ -s testbench $^ `yosys-config --datdir/ice40/cells_sim.v`
	chmod -x $@

route_sim: route_tb.vvp
	vvp -N $<

route_sim_vcd: route_tb.vvp
	vvp -N $< +vcd

prog_sram: example.bin
	iceprog -S $<

view: example.vcd
	gtkwave $< example.gtkw

clean:
	rm -f firmware.elf firmware.map firmware.bin firmware.hex
	rm -f synth.log synth.v synth.blif route.v example.asc example.bin
	rm -f example_tb.vvp synth_tb.vvp route_tb.vvp example.vcd

.PHONY: all prog_sram view clean
.PHONY: example_sim synth_sim route_sim
.PHONY: example_sim_vcd synth_sim_vcd route_sim_vcd
{'fraction_non_alphanumeric': 0.12891298989401034, 'fraction_numerical': 0.010352477199901405, 'mean_word_length': 3.696759259259259, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1748887', 'n_tokens_mistral': 1865, 'n_tokens_neox': 1701, 'n_words': 386}