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 #===============================================================================
67 MAP_EQUIVALENT_REGISTER_REMOVAL := off
68 MAP_LUT_COMBINING := off
70 #===============================================================================
73 MB_CROSS_COMPILE ?= mb-
74 TARGET_CC := $(MB_CROSS_COMPILE)gcc
75 TARGET_LD := $(MB_CROSS_COMPILE)ld
76 TARGET_OBJCOPY := $(MB_CROSS_COMPILE)objcopy
77 TARGET_OBJDUMP := $(MB_CROSS_COMPILE)objdump
79 C_OBJS := $(OUT)/firmware.o
81 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
82 AFLAGS := -D__ASSEMBLY__ $(CFLAGS)
83 LDFLAGS := -static -nostdlib -defsym _STACK_SIZE=0x0200
85 OBJS := $(OUT)/start.o $(C_OBJS) $(A_OBJS)
87 FIRMWARE_DIR := ./lx-rocon_firmware
89 #===============================================================================
91 # Attempt to create a output directory.
92 $(shell [ -d ${OUT} ] || mkdir -p ${OUT})
94 # Verify if it was successful.
95 OUTPUT_DIR := $(shell cd $(OUT) && /bin/pwd)
96 $(if $(OUTPUT_DIR),,$(error output directory "$(OUT)" does not exist))
98 #===============================================================================
103 .PHONY: re-synthesize
104 re-synthesize $(REQ_NGC): $(addprefix $(REQ_SRC)/,$(PRJ))
108 $(addprefix -ifn $(SRC)/,$(PRJ)) \
115 -keep_hierarchy soft \
116 -opt_level 1" | xst | tee xst.log
119 re-translate $(REQ_NGD): $(REQ_NGC) $(REQ_UCF)
121 ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
122 $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
127 re-map $(REQ_NCD_MAP) $(REQ_PCF): $(REQ_NGD)
129 map -w -intstyle $(INTSTYLE) -p $(DEVICE) -logic_opt $(MAP_LOGIC_OPT) -ol high -t 1 -xt 0 \
130 -r 4 -global_opt $(MAP_GLOBAL_OPT) -mt off -ir off -pr off -lc $(MAP_LUT_COMBINING) \
131 -power off -equivalent_register_removal $(MAP_EQUIVALENT_REGISTER_REMOVAL) \
132 -o $(NCD_MAP) $(NGD) $(PCF) | tee map.log
135 re-par $(REQ_NCD): $(REQ_NCD_MAP) $(REQ_PCF)
137 par -w -intstyle $(INTSTYLE) -ol high -mt off $(NCD_MAP) $(NCD) $(PCF) | tee par.log
140 re-gen $(REQ_BIN): $(REQ_NCD)
142 bitgen -w -g Binary:yes -g INIT_9K:Yes -g StartUpClk:Cclk $(NCD) $(OUTB) $(PCF) | tee bitgen.log
145 packager $(OUT)/packager:
146 gcc packager.c -o $(OUT)/packager
149 re-pkg $(REQ_PKG): $(OUT)/packager $(REQ_BIN)
151 ./packager le $(BIN) $(PKG)
153 $(OUT)/%.o: $(FIRMWARE_DIR)/%.c
154 $(TARGET_CC) $(CFLAGS) -c $< -o $@
156 $(OUT)/%.o: $(FIRMWARE_DIR)/%.S
157 $(TARGET_CC) $(AFLAGS) -c $< -o $@
159 $(OUT)/firmware.elf: $(OBJS)
160 $(TARGET_LD) $(LDFLAGS) -T $(FIRMWARE_DIR)/utils/tumbl.ld-script -o $@ $(OBJS)
162 $(OUT)/bin2mem: $(FIRMWARE_DIR)/utils/bin2mem.c
166 re-firmware $(REQ_FIRMWARE): $(REQ_PKG) $(OUT)/bin2mem $(OUT)/firmware.elf
167 $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .text -S $(OUT)/imem.bin
168 $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .data -S $(OUT)/dmem.bin
169 $(TARGET_OBJDUMP) -DSCz $(OUT)/firmware.elf > $@
171 $(TARGET_OBJDUMP) -b binary -mmbtumbl -EB -D imem.bin | sed -e 's/.data/.text/' > imem.asm
173 #===============================================================================
180 synthesize: $(REQ_NGC)
183 translate: $(REQ_NGD)
186 map: $(REQ_NCD_MAP) $(REQ_PCF)
195 pkg: $(OUT)/packager $(REQ_PKG)
198 firmware: $(REQ_FIRMWARE)