scripts/icestorm: move SHIFT_COUNTER_BITS into Makefile

This makes it easier to build separate bitstreams for simulation targets
vs the real bitstream for hardware, without editing any source code.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2019-01-11 15:14:32 -06:00
parent 752790a4d7
commit 2944564ba8
2 changed files with 11 additions and 4 deletions

View File

@ -1,13 +1,19 @@
TOOLCHAIN_PREFIX = riscv32-unknown-elf-
# set to 4 for simulation
FIRMWARE_COUNTER_BITS=18
all: example.bin
## -------------------
## firmware generation
firmware.elf: firmware.S firmware.c firmware.lds
$(TOOLCHAIN_PREFIX)gcc -march=rv32i -Os -ffreestanding -nostdlib -o $@ firmware.S firmware.c \
--std=gnu99 -Wl,-Bstatic,-T,firmware.lds,-Map,firmware.map,--strip-debug -lgcc
$(TOOLCHAIN_PREFIX)gcc \
-DSHIFT_COUNTER_BITS=$(FIRMWARE_COUNTER_BITS) \
-march=rv32i -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

View File

@ -1,7 +1,8 @@
#include <stdint.h>
// use SHIFT_COUNTER_BITS=4 for simulation
#define SHIFT_COUNTER_BITS 18
#ifndef SHIFT_COUNTER_BITS
#error SHIFT_COUNTER_BITS must be defined as 4 (for simulation) or 18 (for hardware bitstreams)!
#endif
void output(uint8_t c)
{