]> rtime.felk.cvut.cz Git - fpga/lx-cpu1/lx-rocon.git/blob - hw/Makefile
Add FPGA sources with Makefile
[fpga/lx-cpu1/lx-rocon.git] / hw / Makefile
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, ...).
6 #                 See NGDBUILD manual.
7 # INTSTYLE      - Style of screen output. (ise | xflow | silent)
8
9 # Targets desctiption:
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 #  - all        : Transfer placed and routed NCD file into the bit file, which can
22 #                 be then used to configure particular FPGA
23
24 # Dependicies are handled, so in most cases only 'download' target is called.
25
26 DEVICE := xc6slx9-2tqg144
27
28 TOP    := lx_rocon_top
29 OUT    := _build
30 OUTB   := lx-rocon
31 REQB   := $(OUT)/$(OUTB)
32 PRJ    := lx_rocon_top.prj
33 UCF    := lx-rocon.ucf
34 SEARCH_DIRS := ipcore_dir
35 INTSTYLE    := xflow
36 SRC         := ..
37
38 #===============================================================================
39 # Abbreviations of frequently used file names.
40
41 NGC            := $(OUTB).ngc
42 NGD            := $(OUTB).ngd
43 PCF            := $(OUTB).pcf
44 NCD_MAP        := $(OUTB)_map.ncd
45 NCD            := $(OUTB).ncd
46 BIT            := $(OUTB).bit
47
48 REQ_NGC            := $(REQB).ngc
49 REQ_NGD            := $(REQB).ngd
50 REQ_PCF            := $(REQB).pcf
51 REQ_NCD_MAP        := $(REQB)_map.ncd
52 REQ_NCD            := $(REQB).ncd
53 REQ_BIT            := $(REQB).bit
54 REQ_SRC            := .
55
56 #===============================================================================
57
58 # Attempt to create a output directory.
59 $(shell [ -d ${OUT} ] || mkdir -p ${OUT})
60
61 # Verify if it was successful.
62 OUTPUT_DIR := $(shell cd $(OUT) && /bin/pwd)
63 $(if $(OUTPUT_DIR),,$(error output directory "$(OUT)" does not exist))
64
65 #===============================================================================
66
67 .PHONY: all
68 all: gen
69
70 .PHONY: re-synthesize
71 re-synthesize $(REQ_NGC): $(addprefix $(REQ_SRC)/,$(PRJ))
72         cd $(OUT); \
73         echo " \
74           run \
75           $(addprefix -ifn $(SRC)/,$(PRJ)) \
76           -ifmt mixed \
77           -ofn $(NGC) \
78           -ofmt NGC \
79           -top $(TOP) \
80           -p $(DEVICE) \
81           -opt_mode Speed \
82           -keep_hierarchy soft \
83           -opt_level 1" | xst | tee xst.log
84
85 .PHONY: re-translate
86 re-translate $(REQ_NGD): $(REQ_NGC) $(REQ_UCF)
87         cd $(OUT); \
88         ngdbuild -intstyle $(INTSTYLE) -p $(DEVICE) -uc $(SRC)/$(UCF) \
89           $(addprefix -sd $(SRC)/,$(SEARCH_DIRS)) \
90           $(NGC) \
91           $(NGD)
92
93 .PHONY: re-map
94 re-map $(REQ_NCD_MAP) $(REQ_PCF): $(REQ_NGD)
95         cd $(OUT); \
96         map -intstyle $(INTSTYLE) -o $(NCD_MAP) $(NGD) $(PCF)
97
98 .PHONY: re-par
99 re-par $(REQ_NCD): $(REQ_NCD_MAP) $(REQ_PCF)
100         cd $(OUT); \
101         par -intstyle $(INTSTYLE) $(NCD_MAP) -w $(NCD) $(PCF)
102
103 .PHONY: re-gen
104 re-gen $(REQ_BIT): $(REQ_NCD)
105         cd $(OUT); \
106         bitgen -w $(NCD) $(OUTB) $(PCF)
107
108 #===============================================================================
109
110 .PHONY: clean
111 clean:
112         rm -rf $(OUT)
113
114 .PHONY: synthesize
115 synthesize: $(REQ_NGC)
116
117 .PHONY: translate
118 translate: $(REQ_NGD)
119
120 .PHONY: map
121 map: $(REQ_NCD_MAP) $(REQ_PCF)
122
123 .PHONY: par
124 par: $(REQ_NCD)
125
126 .PHONY: gen
127 gen: $(REQ_BIT)