# TOP - Name of the top-level module # DEVICE - Name of the FPGA device (device-package-speed) # PRJ - Name of .prj file with names of all source files. See XST manual. # UCF - Name of the user constraints file # SEARCH_DIRS - Directories to search when searching for netlists (.ngc, ...). # See NGDBUILD manual. # INTSTYLE - Style of screen output. (ise | xflow | silent) # Targets desctiption: # - synthesize : Synthesize all VHDL and Verilog source files, libraries, etc. # defined in PRJ files and produces NGC file. # - translate : Translate all netlist files (.ngc, ...) into the NGD file, # where the design is described in terms of deneral logic elements # such as (RAM, flip-flop, XOR, ...). # - map : Map the general logic from NGD file to the components in the # target FPGA and produces NCD_MAP file. # - par : PAR stands for Plase & Route. This procedure takes NCD_MAP file, # places all components and makes routes between them (depending # on the chosen optimization mode) and produces NCD file. # - clean : Clean build directory, dependency (*.d) files and call # - gen : Transfer placed and routed NCD file into the bin file, which can # be then used to configure particular FPGA (this is further packaged # for SelectMap interface via the ARM CPU) # - firmware : Builds the firmware for Tumbl core # Dependicies are handled, so in most cases only 'download' target is called. DEVICE := xc6slx9-2tqg144 TOP := lx_rocon_top OUT := _build OUTB := lx-rocon REQB := $(OUT)/$(OUTB) PRJ := lx_rocon_top.prj UCF := lx-rocon.ucf SEARCH_DIRS := ipcore_dir INTSTYLE := xflow SRC := .. #=============================================================================== # Abbreviations of frequently used file names. NGC := $(OUTB).ngc NGD := $(OUTB).ngd PCF := $(OUTB).pcf NCD_MAP := $(OUTB)_map.ncd NCD := $(OUTB).ncd BIN := $(OUTB).bin PKG := $(OUTB).pkg TWR := $(OUTB).twr TSI := $(OUTB).tsi REQ_NGC := $(REQB).ngc REQ_NGD := $(REQB).ngd REQ_PCF := $(REQB).pcf REQ_NCD_MAP := $(REQB)_map.ncd REQ_NCD := $(REQB).ncd REQ_BIN := $(REQB).bin REQ_PKG := $(REQB).pkg REQ_SRC := . REQ_FIRMWARE := $(OUT)/imem.bin $(OUT)/imem.asm $(OUT)/dmem.bin $(OUT)/firmware.lst #=============================================================================== # Sythesis settings (SmartXplorer) XST_GLOB_OPT := AllClockNets XST_OPT_LEVEL := 2 XST_OPT_MODE := Speed XST_IOB_PACKING := False XST_POWER := NO XST_KEEP_HIEARCHY := No XST_NETLIST_HIEARCHY := As_Optimized XST_READ_CORES := YES XST_WRITE_TIMING_CONSTRAINTS := NO XST_CROSS_CLOCK_ANALYSIS := NO XST_CASE := Maintain XST_REDUCE_CONTROL_SETS := Auto XST_REGISTER_DUPLICATION := YES XST_REGISTER_BALANCING := Yes XST_MOVE_FIRST_STAGE := YES XST_MOVE_LAST_STAGE := YES XST_OPTIMIZE_PRIMITIVES := NO XST_USE_CLOCK_ENABLE := AUTO XST_EQUIVALENT_REGISTER_REMOVAL := YES XST_IOBUF := YES XST_MAX_FANOUT := 100000 XST_RESOURCE_SHARING := YES XST_SLICE_UTILIZATION_RATIO_MARGIN := 5 XST_SLICE_UTILIZATION_RATIO := 100 XST_BRAM_UTILIZATION_RATIO := 100 XST_DSP_UTILIZATION_RATIO := 100 XST_USE_DSP48 := Auto XST_USE_SYNC_SET := Auto XST_USE_SYNC_RESET := Auto XST_SAFE_IMPLEMENTATION := No MAP_PLACER_COST_TABLE := 2 MAP_LOGIC_OPT := on MAP_GLOBAL_OPT := off MAP_EQUIVALENT_REGISTER_REMOVAL := off MAP_LUT_COMBINING := off #=============================================================================== # Firmware MB_CROSS_COMPILE ?= mbtumbl-elf- TARGET_CC := $(MB_CROSS_COMPILE)gcc TARGET_LD := $(MB_CROSS_COMPILE)ld TARGET_OBJCOPY := $(MB_CROSS_COMPILE)objcopy TARGET_OBJDUMP := $(MB_CROSS_COMPILE)objdump C_OBJS := $(OUT)/firmware.o A_OBJS := CFLAGS := -mxl-soft-div -msoft-float -Wno-main -Wl,-no-check-sections -ffunction-sections -fno-zero-initialized-in-bss -g -O2 -Wall AFLAGS := -D__ASSEMBLY__ $(CFLAGS) LDFLAGS := -static -nostdlib -relax -defsym _STACK_SIZE=0x0200 --gc-sections OBJS := $(OUT)/start.o $(C_OBJS) $(A_OBJS) FIRMWARE_DIR := ./lx-rocon_firmware #=============================================================================== # Attempt to create a output directory. $(shell [ -d ${OUT} ] || mkdir -p ${OUT}) # Verify if it was successful. OUTPUT_DIR := $(shell cd $(OUT) && /bin/pwd) $(if $(OUTPUT_DIR),,$(error output directory "$(OUT)" does not exist)) #=============================================================================== .PHONY: all all: pkg firmware .PHONY: re-synthesize re-synthesize $(REQ_NGC): $(addprefix $(REQ_SRC)/,$(PRJ)) cd $(OUT); \ echo " \ run \ $(addprefix -ifn $(SRC)/,$(PRJ)) \ -ifmt mixed \ -ofn $(NGC) \ -ofmt NGC \ -top $(TOP) \ -p $(DEVICE) \ -keep_hierarchy $(XST_KEEP_HIEARCHY) \ -glob_opt $(XST_GLOB_OPT) \ -opt_mode $(XST_OPT_MODE) \ -opt_level $(XST_OPT_LEVEL) \ -power $(XST_POWER) \ -iob $(XST_IOB_PACKING) \ -read_cores $(XST_READ_CORES) \ -write_timing_constraints $(XST_WRITE_TIMING_CONSTRAINTS) \ -cross_clock_analysis $(XST_CROSS_CLOCK_ANALYSIS) \ -case $(XST_CASE) \ -reduce_control_sets $(XST_REDUCE_CONTROL_SETS) \ -resource_sharing $(XST_RESOURCE_SHARING) \ -iobuf $(XST_IOBUF) \ -max_fanout $(XST_MAX_FANOUT) \ -register_duplication $(XST_REGISTER_DUPLICATION) \ -register_balancing $(XST_REGISTER_BALANCING) \ -move_first_stage $(XST_MOVE_FIRST_STAGE) \ -move_last_stage $(XST_MOVE_LAST_STAGE) \ -optimize_primitives $(XST_OPTIMIZE_PRIMITIVES) \ -use_clock_enable $(XST_USE_CLOCK_ENABLE) \ -equivalent_register_removal $(XST_EQUIVALENT_REGISTER_REMOVAL) \ -slice_utilization_ratio_maxmargin $(XST_SLICE_UTILIZATION_RATIO_MARGIN) \ -slice_utilization_ratio $(XST_SLICE_UTILIZATION_RATIO) \ -bram_utilization_ratio $(XST_BRAM_UTILIZATION_RATIO) \ -dsp_utilization_ratio $(XST_DSP_UTILIZATION_RATIO)" | xst | tee xst.log .PHONY: re-translate re-translate $(REQ_NGD): $(REQ_NGC) $(REQ_UCF) cd $(OUT); \ ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -nt timestamp -uc $(SRC)/$(UCF) \ $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \ $(NGC) \ $(NGD) .PHONY: re-map re-map $(REQ_NCD_MAP) $(REQ_PCF): $(REQ_NGD) cd $(OUT); \ map -w -intstyle $(INTSTYLE) -p $(DEVICE) -logic_opt $(MAP_LOGIC_OPT) -ol high -t $(MAP_PLACER_COST_TABLE) -xt 0 \ -r 4 -global_opt $(MAP_GLOBAL_OPT) -mt off -ir off -pr off -lc $(MAP_LUT_COMBINING) \ -power off -equivalent_register_removal $(MAP_EQUIVALENT_REGISTER_REMOVAL) \ -o $(NCD_MAP) $(NGD) $(PCF) | tee map.log .PHONY: re-par re-par $(REQ_NCD): $(REQ_NCD_MAP) $(REQ_PCF) cd $(OUT); \ par -w -intstyle $(INTSTYLE) -ol high -xe n -mt off $(NCD_MAP) $(NCD) $(PCF) | tee par.log cd $(OUT); \ trce -e 20 -tsi $(TSI) -o $(TWR) $(NCD) $(PCF) .PHONY: re-gen re-gen $(REQ_BIN): $(REQ_NCD) cd $(OUT); \ bitgen -w -g Binary:yes -g INIT_9K:Yes -g StartUpClk:Cclk $(NCD) $(OUTB) $(PCF) | tee bitgen.log .PHONY: packager packager $(OUT)/packager: gcc packager.c -o $(OUT)/packager .PHONY: re-pkg re-pkg $(REQ_PKG): $(OUT)/packager $(REQ_BIN) cd $(OUT); \ ./packager le $(BIN) $(PKG) $(OUT)/%.o: $(FIRMWARE_DIR)/%.c $(TARGET_CC) $(CFLAGS) -c $< -o $@ $(OUT)/%.o: $(FIRMWARE_DIR)/%.S $(TARGET_CC) $(AFLAGS) -c $< -o $@ $(OUT)/firmware.elf: $(OBJS) $(TARGET_LD) $(LDFLAGS) -T $(FIRMWARE_DIR)/utils/tumbl.ld-script -o $@ $(OBJS) $(OUT)/bin2mem: $(FIRMWARE_DIR)/utils/bin2mem.c gcc $< -o $@ .PHONY: re-firmware re-firmware $(REQ_FIRMWARE): $(REQ_PKG) $(OUT)/bin2mem $(OUT)/firmware.elf $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .text -S $(OUT)/imem.bin $(TARGET_OBJCOPY) -O binary $(OUT)/firmware.elf -j .data -S $(OUT)/dmem.bin $(TARGET_OBJDUMP) -DSCz $(OUT)/firmware.elf >$(OUT)/firmware.lst cd $(OUT); \ $(TARGET_OBJDUMP) -b binary -mmbtumbl -EB -D imem.bin | sed -e 's/.data/.text/' > imem.asm # imem # watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80000000 -l 0x200 -f dump -u - # dmem # watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80001000 -l 0x200 -f dump -u - # PC # watch -d ./usb_sendhex -d 0x1669:0x1023 -t 4 -s 0x80003008 -l 0x4 -f dump -u - #=============================================================================== .PHONY: clean clean: rm -rf $(OUT) .PHONY: synthesize synthesize: $(REQ_NGC) .PHONY: translate translate: $(REQ_NGD) .PHONY: map map: $(REQ_NCD_MAP) $(REQ_PCF) .PHONY: par par: $(REQ_NCD) .PHONY: gen gen: $(REQ_BIN) .PHONY: pkg pkg: $(OUT)/packager $(REQ_PKG) .PHONY: firmware firmware: $(REQ_FIRMWARE)