From 2944564ba803dbd4635e02a7a17f62e6dfeeefc3 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Fri, 11 Jan 2019 15:14:32 -0600 Subject: [PATCH] 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 --- scripts/icestorm/Makefile | 10 ++++++++-- scripts/icestorm/firmware.c | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/icestorm/Makefile b/scripts/icestorm/Makefile index 7a3ece3..eead7df 100644 --- a/scripts/icestorm/Makefile +++ b/scripts/icestorm/Makefile @@ -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 diff --git a/scripts/icestorm/firmware.c b/scripts/icestorm/firmware.c index a5e5236..80a4661 100644 --- a/scripts/icestorm/firmware.c +++ b/scripts/icestorm/firmware.c @@ -1,7 +1,8 @@ #include -// 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) {