Skip to content

Commit 934c49c

Browse files
committed
Use fpga-tools as submodule
1 parent b7603d3 commit 934c49c

16 files changed

+20
-1014
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "verilog/fpga-tools"]
2+
path = verilog/fpga-tools
3+
url = https://github.com/pwmarcz/fpga-tools

docs/fpga.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ We'll be working in the `verilog` directory.
88

99
## Setup
1010

11-
1. You will need Verilog setup from the [previous step](verilog.html).
11+
1. You will need Verilog setup from the [previous step](verilog.html). Remember
12+
to also initialize the Git submodule with libraries:
13+
14+
git submodule update --init
1215

1316
2. Then, install the [Icestorm toolchain](http://www.clifford.at/icestorm/). The
1417
easiest way is using the [apio](https://github.com/FPGAwars/apio) project:
@@ -71,8 +74,8 @@ The build process has the following steps:
7174

7275
## Pins
7376

74-
You can find the available pins in [pcf/icestick.pcf](https://github.com/pwmarcz/fpga-tutorial/blob/master/verilog/pcf/icestick.pcf) and
75-
[pcf/bx.pcf](https://github.com/pwmarcz/fpga-tutorial/blob/master/verilog/pcf/bx.pcf) files. Your module will reference these.
77+
You can find the available pins in [pcf/icestick.pcf](https://github.com/pwmarcz/fpga-tools/blob/master/pcf/icestick.pcf) and
78+
[pcf/bx.pcf](https://github.com/pwmarcz/fpga-tools/blob/master/pcf/bx.pcf) files. Your module will reference these.
7679

7780
Here are the pinouts for reference:
7881

docs/verilog.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ shouldn't look there before trying to solve the exercises yourself.
1111

1212
## Prerequisites
1313

14+
First, initialize the Git submodule with libraries:
15+
16+
git submodule update --init
17+
1418
You will need the following:
1519

1620
- An editor that understands Verilog. Atom or Sublime Text should be fine.

verilog/Makefile

+1-120
Original file line numberDiff line numberDiff line change
@@ -1,120 +1 @@
1-
2-
# Don't run anything by default
3-
.PHONY: all
4-
all:
5-
6-
# Custom project configuration
7-
-include ./project.mk
8-
9-
# Don't delete these
10-
.PRECIOUS: build/%.d build/%.blif build/%.bin build/%.asc
11-
12-
# Top module
13-
TOP ?= top
14-
15-
# Tool paths
16-
17-
# Use apio toolchain
18-
TOOLCHAIN = $(HOME)/.apio/packages/toolchain-icestorm/bin
19-
export PATH := $(TOOLCHAIN):$(PATH)
20-
21-
YOSYS ?= yosys
22-
PNR ?= arachne-pnr
23-
ICEPACK ?= icepack
24-
ICEPROG ?= iceprog
25-
TINYPROG ?= tinyprog
26-
ICETIME ?= icetime
27-
IVERILOG ?= iverilog
28-
GTKWAVE ?= gtkwave
29-
30-
SHARE_ICEBOX = $$(dirname $$(which $(ICETIME)))/../share/icebox
31-
32-
ifeq ($(USE_SUDO),1)
33-
ICEPROG := sudo $$(which $(ICEPROG))
34-
TINYPROG := sudo $$(which $(TINYPROG))
35-
endif
36-
37-
MAKEDEPS = ./make-deps
38-
39-
# Board-specific configuration
40-
41-
BOARD ?= icestick
42-
43-
YOSYS_OPTS =
44-
45-
ifeq ($(BOARD),icestick)
46-
PNR_OPTS = -d 1k -P tq144
47-
DEVICE = hx1k
48-
CHIPDB = 1k
49-
PROG = $(ICEPROG)
50-
endif
51-
52-
ifeq ($(BOARD),bx)
53-
PNR_OPTS = -d 8k -P cm81
54-
DEVICE = lp8k
55-
CHIPDB = 8k
56-
PROG = $(TINYPROG) -p
57-
endif
58-
59-
ifndef VERBOSE
60-
PNR_OPTS := -q $(PNR_OPTS)
61-
YOSYS_OPTS := -q $(YOSYS_OPTS)
62-
endif
63-
64-
# Dependencies
65-
66-
build/%.d: %.v $(MAKEDEPS)
67-
@mkdir -p $(dir $@)
68-
@$(MAKEDEPS) $(@:.d=.bx.blif) $< > $@
69-
@$(MAKEDEPS) $(@:.d=.icestick.blif) $< >> $@
70-
@$(MAKEDEPS) $(@:.d=.out) $< >> $@
71-
72-
# Synthesis
73-
74-
build/%.$(BOARD).blif: %.v build/%.d
75-
$(YOSYS) $(YOSYS_OPTS) \
76-
-p "verilog_defines -DBOARD_$(BOARD) -DBOARD=$(BOARD)" \
77-
-p "read_verilog -noautowire $<" \
78-
-p "synth_ice40 -top $(TOP) -blif $@"
79-
80-
build/%.$(BOARD).asc: build/%.$(BOARD).blif pcf/$(BOARD).pcf
81-
$(PNR) -p pcf/$(BOARD).pcf $(PNR_OPTS) $< -o $@
82-
83-
build/%.bin: build/%.asc
84-
$(ICEPACK) $< $@
85-
86-
# Simulation
87-
88-
build/%.out: %.v build/%.d
89-
$(IVERILOG) -DVCD_FILE=\"build/$(<:.v=.vcd)\" -o $@ $<
90-
91-
# Top-level goals (flash, sim, run, time)
92-
93-
flash sim run time::
94-
ifeq ($(V),)
95-
$(error Define target name first, e.g.: make run V=myfile.v)
96-
endif
97-
98-
.PHONY: flash
99-
flash:: build/$(V:.v=.$(BOARD).bin)
100-
$(PROG) $<
101-
102-
.PHONY: sim
103-
sim:: run
104-
$(GTKWAVE) build/$(V:.v=.vcd)
105-
106-
.PHONY: run
107-
run:: build/$(V:.v=.out)
108-
./$<
109-
110-
.PHONY: time
111-
time:: build/$(V:.v=.$(BOARD).asc)
112-
$(ICETIME) -d $(DEVICE) -C $(SHARE_ICEBOX)/chipdb-$(CHIPDB).txt $<
113-
114-
# Cleanup
115-
116-
.PHONY: clean
117-
clean:
118-
rm -f build/*
119-
120-
include $(wildcard build/*.d)
1+
include fpga-tools/fpga.mk

verilog/fpga-tools

Submodule fpga-tools added at eb481c0

verilog/make-deps

-20
This file was deleted.

0 commit comments

Comments
 (0)