1 # TOP - Name of the top-level module
2 # DEVICE - Name of the FPGA device (device-package-speed)
3 # PRJ - Name of .prj file with names of all source files. See XST manual.
4 # UCF - Name of the user constraints file
5 # SEARCH_DIRS - Directories to search when searching for netlists (.ngc, ...).
7 # INTSTYLE - Style of screen output. (ise | xflow | silent)
10 # - synthesize : Synthesize all VHDL and Verilog source files, libraries, etc.
11 # defined in PRJ files and produces NGC file.
12 # - translate : Translate all netlist files (.ngc, ...) into the NGD file,
13 # where the design is described in terms of deneral logic elements
14 # such as (RAM, flip-flop, XOR, ...).
15 # - map : Map the general logic from NGD file to the components in the
16 # target FPGA and produces NCD_MAP file.
17 # - par : PAR stands for Plase & Route. This procedure takes NCD_MAP file,
18 # places all components and makes routes between them (depending
19 # on the chosen optimization mode) and produces NCD file.
20 # - clean : Clean build directory, dependency (*.d) files and call
21 # - gen : Transfer placed and routed NCD file into the bin file, which can
22 # be then used to configure particular FPGA (this is further packaged
23 # for SelectMap interface via the ARM CPU)
24 # - firmware : Builds the firmware for Tumbl core
26 # Dependicies are handled, so in most cases only 'download' target is called.
28 DEVICE := xc6slx9-2tqg144
33 REQB := $(OUT)/$(OUTB)
34 PRJ := lx_rocon_top.prj
36 SEARCH_DIRS := ipcore_dir
40 #===============================================================================
41 # Abbreviations of frequently used file names.
46 NCD_MAP := $(OUTB)_map.ncd
51 REQ_NGC := $(REQB).ngc
52 REQ_NGD := $(REQB).ngd
53 REQ_PCF := $(REQB).pcf
54 REQ_NCD_MAP := $(REQB)_map.ncd
55 REQ_NCD := $(REQB).ncd
56 REQ_BIN := $(REQB).bin
57 REQ_PKG := $(REQB).pkg
60 REQ_FIRMWARE := $(OUT)/imem.bin $(OUT)/imem.asm $(OUT)/dmem.bin $(OUT)/firmware.lst
62 #===============================================================================
64 MB_CROSS_COMPILE ?= mb-
65 TARGET_CC := $(MB_CROSS_COMPILE)gcc
66 TARGET_LD := $(MB_CROSS_COMPILE)ld
67 TARGET_OBJCOPY := $(MB_CROSS_COMPILE)objcopy
68 TARGET_OBJDUMP := $(MB_CROSS_COMPILE)objdump
70 C_OBJS := $(OUT)/firmware.o
72 CFLAGS := -mxl-soft-div -msoft-float -mno-xl-soft-mul -mxl-barrel-shift -Wno-main -Wl,-no-check-sections -fno-zero-initialized-in-bss -g -O2 -Wall
73 AFLAGS := -D__ASSEMBLY__ $(CFLAGS)
74 LDFLAGS := -static -nostdlib -defsym _STACK_SIZE=0x0200
76 OBJS := $(OUT)/start.o $(C_OBJS) $(A_OBJS)
78 FIRMWARE_DIR := ./lx-rocon_firmware
80 #===============================================================================
82 # Attempt to create a output directory.
83 $(shell [ -d ${OUT} ] || mkdir -p ${OUT})
85 # Verify if it was successful.
86 OUTPUT_DIR := $(shell cd $(OUT) && /bin/pwd)
87 $(if $(OUTPUT_DIR),,$(error output directory "$(OUT)" does not exist))
89 #===============================================================================
95 re-synthesize $(REQ_NGC): $(addprefix $(REQ_SRC)/,$(PRJ))
99 $(addprefix -ifn $(SRC)/,$(PRJ)) \
106 -keep_hierarchy soft \
107 -opt_level 1" | xst | tee xst.log
110 re-translate $(REQ_NGD): $(REQ_NGC) $(REQ_UCF)
112 ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
113 $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
118 re-map $(REQ_NCD_MAP) $(REQ_PCF): $(REQ_NGD)
120 map -intstyle $(INTSTYLE) -o $(NCD_MAP) $(NGD) $(PCF)
123 re-par $(REQ_NCD): $(REQ_NCD_MAP) $(REQ_PCF)
125 par -intstyle $(INTSTYLE) $(NCD_MAP) -w $(NCD) $(PCF)
128 re-gen $(REQ_BIN): $(REQ_NCD)
130 bitgen -g Binary:yes -g INIT_9K:Yes -g StartUpClk:Cclk -w $(NCD) $(OUTB) $(PCF)
133 packager $(OUT)/packager:
134 gcc packager.c -o $(OUT)/packager
137 re-pkg $(REQ_PKG): $(OUT)/packager $(REQ_BIN)
139 ./packager le $(BIN) $(PKG)
141 $(OUT)/%.o: $(FIRMWARE_DIR)/%.c
142 $(TARGET_CC) $(CFLAGS) -c $< -o $@
144 $(OUT)/%.o: $(FIRMWARE_DIR)/%.S
145 $(TARGET_CC) $(AFLAGS) -c $< -o $@
147 $(OUT)/firmware.elf: $(OBJS)
148 $(TARGET_LD) $(LDFLAGS) -T $(FIRMWARE_DIR)/utils/tumbl.ld-script -o $@ $(OBJS)
150 $(OUT)/mb-dasm: $(FIRMWARE_DIR)/utils/mb-dasm.cpp
153 $(OUT)/bin2mem: $(FIRMWARE_DIR)/utils/bin2mem.c
157 re-firmware $(REQ_FIRMWARE): $(REQ_PKG) $(OUT)/mb-dasm $(OUT)/bin2mem $(OUT)/firmware.elf
158 $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .text -S $(OUT)/imem.bin
159 $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .data -S $(OUT)/dmem.bin
160 $(TARGET_OBJDUMP) -DSCz $(OUT)/firmware.elf > $@
162 ./mb-dasm imem.bin > imem.asm
164 #===============================================================================
171 synthesize: $(REQ_NGC)
174 translate: $(REQ_NGD)
177 map: $(REQ_NCD_MAP) $(REQ_PCF)
186 pkg: $(OUT)/packager $(REQ_PKG)
189 firmware: $(OUT)/mb-dasm $(OUT)/bin2mem $(REQ_FIRMWARE)