aboutsummaryrefslogtreecommitdiff
path: root/Makefile.example
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-12-29 19:56:04 +0100
committerWojciech Kosior <kwojtus@protonmail.com>2020-12-29 19:56:04 +0100
commit68c80359ba0983bc21a18c0270025be9b441c0bb (patch)
treea06a04eb8756f96d05c55768bd356917847cdc95 /Makefile.example
parent5b6a3f3b216939a11ed1978d7da4dd6bbe4edc2a (diff)
downloadAGH-engineering-thesis-68c80359ba0983bc21a18c0270025be9b441c0bb.tar.gz
AGH-engineering-thesis-68c80359ba0983bc21a18c0270025be9b441c0bb.zip
add the ability to include additional data at the end of bitstream image and prepare an example, that reads thic data through SPI and displays it
Diffstat (limited to 'Makefile.example')
-rw-r--r--Makefile.example35
1 files changed, 28 insertions, 7 deletions
diff --git a/Makefile.example b/Makefile.example
index c85dc8f..484c279 100644
--- a/Makefile.example
+++ b/Makefile.example
@@ -13,28 +13,49 @@ FONT := $(DESIGN_DIR)/font.mem
IVFLAGS += -I$(PROJ_DIR)/include/
-ROM_DEFINES = \
+EMBEDDED_ROM_DEFINES = \
-DROM_WORDS_COUNT=$(call FILE_LINES,instructions.mem) \
-DEMBEDDED_ROM_FILE=\"instructions.mem\" \
-DFONT_FILE=\"$(FONT)\"
+ifdef FLASH_DATA
+INCLUDE_SPI_IMAGE = 1
+
+# We put some random data in the image so as not to waste time generating
+# bitstream when we're only working in a simulator.
+spi.mem : $(PROJ_DIR)/tools/bin2hex $(FLASH_DATA)
+ (dd if=/dev/urandom bs=135100 count=1; cat $(FLASH_DATA)) \
+ 2>/dev/null | $< > $@
+else
+FLASH_DATA = /dev/null
+endif
+
+ifdef INCLUDE_SPI_IMAGE
+SPI_ROM_DEFINES = \
+ -DSPI_ROM_FILE=\"spi.mem\" \
+ -DSPI_ROM_WORDS_COUNT=$(call FILE_LINES,spi.mem)
+
+example.vvp : spi.mem
+simulate : spi.mem
+endif
+
example.vvp : $(DESIGN_DIR)/*.v soc_with_peripherals.v flash_memory.v sram.v \
vga_display.v example_toplevel.v $(FONT) messages.vh \
instructions.mem
- $(IV) $(IVFLAGS) $(SIMFLAGS) -DSIMULATION $(ROM_DEFINES) \
- -s example $(filter %.v,$^) -o $@
+ $(IV) $(IVFLAGS) $(SIMFLAGS) -DSIMULATION $(EMBEDDED_ROM_DEFINES) \
+ $(SPI_ROM_DEFINES) -s example $(filter %.v,$^) -o $@
simulate : example.vvp
$(VVP) $<
if [ -f VGAdump.mem ]; then $(MAKE) VGAdump.ppm; fi
design.v : instructions.mem $(DESIGN_DIR)/*.v $(FONT)
- $(IV) $(IVFLAGS) $(ROM_DEFINES) -E $(filter %.v,$^) -o $@
+ $(IV) $(IVFLAGS) $(EMBEDDED_ROM_DEFINES) -E $(filter %.v,$^) -o $@
clean :
find . -name "*.vvp" -delete
- rm $(call FIND_GENERATED_FILES,.) $(addprefix design.,v json asc bin) \
- $(addsuffix .log,yosys pnr) VGAdump.mem VGAdump.ppm \
- 2>/dev/null || true
+ rm $(call FIND_GENERATED_FILES,.) $(addsuffix .log,yosys pnr) \
+ $(addprefix design.,v json asc bin) spi.mem \
+ VGAdump.mem VGAdump.ppm 2>/dev/null || true
.PHONY : def simulate clean