summaryrefslogtreecommitdiff
path: root/Makefile
blob: 522a7d5bdbc6200d369351262a80a3b242129e4d (plain) (blame)
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
SOURCES := $(shell find hdl sim -name \*.sv -o -name \*.cpp)
HEADERS := $(shell find hdl -name \*.svh)
MEMORIES := $(shell find mem -name \*.hex)
QUARTUS := $(shell find altera tcl -name \*.cdf -o -name \*.sdc -o -name \*.tcl)

OPTS ?=

sim: build/Vtop
	$<
.PHONY: sim

build/Vtop: $(SOURCES) $(HEADERS)
	@rm -rf verilator
	@mkdir -p build verilator
	verilator +1800-2017ext+sv -Wall -Wno-BLKSEQ -Wno-UNUSED -O3 -Ihdl $(OPTS) --Mdir verilator --trace --cc --build -j --exe --top-module top $(SOURCES)
	@ln -t build -f verilator/Vtop
	@rm -rf verilator

noncpu.sof: $(SOURCES) $(HEADERS) $(MEMORIES) $(QUARTUS)
	[ ! -e noncpu.qpf ] || quartus_sh -t tcl/clean.tcl
	quartus_sh -t tcl/init.tcl
	quartus_sh --flow compile noncpu.qpf

fpga: noncpu.sof
	quartus_pgm -c 1 -m JTAG -o "P;$<@1"
	nios2-terminal
.PHONY: fpga

clean:
	git clean -dfX
.PHONY: clean