aboutsummaryrefslogtreecommitdiff
path: root/Makefile.example
blob: 484c279227263542159f4ec034263a0d4bf1a617 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# This Makefile is to be included by Makefile of each example

ifndef PROJ_DIR
PROJ_DIR := ../../
endif

def : simulate

include $(PROJ_DIR)/Makefile.util

DESIGN_DIR := $(PROJ_DIR)/design/
FONT := $(DESIGN_DIR)/font.mem

IVFLAGS += -I$(PROJ_DIR)/include/

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 $(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) $(EMBEDDED_ROM_DEFINES) -E $(filter %.v,$^) -o $@

clean :
	find . -name "*.vvp" -delete
	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