summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile31
-rw-r--r--bin2bcd.sv2
-rw-r--r--build.bat3
-rw-r--r--clocks.sdc1
-rw-r--r--init.bat3
-rw-r--r--init.tcl24
-rw-r--r--programmer.cdf13
7 files changed, 41 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 9eff3ef..f532ce2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,38 +1,15 @@
1VERILOG := $(wildcard **.sv) 1SOURCES := $(wildcard **.sv **.cpp)
2HEADERS := $(wildcard **.svh) 2COLLATERAL := $(wildcard **.hex **.svh)
3CPPSRCS := $(wildcard **.cpp)
4COLLATERAL := $(wildcard **.hex)
5 3
6OPTS ?= 4OPTS ?=
7 5
8QUARTUS ?= /opt/quartus-lite/20.1.1.720/
9
10QUARTUS_SH := $(QUARTUS)/quartus/bin/quartus_sh
11
12sim: build/Vtop 6sim: build/Vtop
13 $< 7 $<
14.PHONY: sim 8.PHONY: sim
15 9
16gui: build/toycpu.qpf 10build/Vtop: $(SOURCES) $(COLLATERAL)
17 cd build; $(QUARTUS_SH) --gui toycpu
18.PHONY: gui
19
20qpf: build/toycpu.qpf
21.PHONY: qpf
22
23pof: build/toycpu.pof
24.PHONY: pof
25
26build/Vtop: $(VERILOG) $(HEADERS) $(CPPSRCS) $(COLLATERAL)
27 @mkdir -p build
28 verilator +1800-2017ext+sv -Wall -Wno-BLKSEQ -O3 $(OPTS) --Mdir build --trace --cc --build --exe --top-module top $(VERILOG) $(CPPSRCS)
29
30build/toycpu.pof: build/toycpu.qpf $(VERILOG) $(COLLATERAL)
31 cd build; $(QUARTUS_SH) --flow compile toycpu
32
33build/toycpu.qpf: init.tcl
34 @mkdir -p build 11 @mkdir -p build
35 cd build; $(QUARTUS_SH) -t ../$< $(addprefix $(PWD),$(VERILOG)) 12 verilator +1800-2017ext+sv -Wall -Wno-BLKSEQ -O3 $(OPTS) --Mdir build --trace --cc --build --exe --top-module top $(SOURCES)
36 13
37clean: 14clean:
38 rm -rf build 15 rm -rf build
diff --git a/bin2bcd.sv b/bin2bcd.sv
index 8e618c6..5e2dbd3 100644
--- a/bin2bcd.sv
+++ b/bin2bcd.sv
@@ -21,7 +21,7 @@ localparam DIGITS = $rtoi($ceil($ln(1 << BITS) / $ln(BASE)));
21bit bin_b_valid; 21bit bin_b_valid;
22bit [BITS-1:0] bin_b_data; 22bit [BITS-1:0] bin_b_data;
23 23
24bit [DIGITS-1:0][BASE_BITS-1:0] bcd;; 24bit [DIGITS-1:0][BASE_BITS-1:0] bcd;
25 25
26bit [$clog2(BITS):0] work; 26bit [$clog2(BITS):0] work;
27 27
diff --git a/build.bat b/build.bat
new file mode 100644
index 0000000..730d487
--- /dev/null
+++ b/build.bat
@@ -0,0 +1,3 @@
1init.bat
2
3quartus_sh.exe --flow compile toycpu
diff --git a/clocks.sdc b/clocks.sdc
new file mode 100644
index 0000000..f613011
--- /dev/null
+++ b/clocks.sdc
@@ -0,0 +1 @@
create_clock -period "50 MHz" clk
diff --git a/init.bat b/init.bat
new file mode 100644
index 0000000..20ea117
--- /dev/null
+++ b/init.bat
@@ -0,0 +1,3 @@
1if not exist toycpu.qpf {
2 quartus_sh.exe -t init.tcl
3}
diff --git a/init.tcl b/init.tcl
index 66cea3f..33897e5 100644
--- a/init.tcl
+++ b/init.tcl
@@ -1,18 +1,26 @@
1global quartus
2
3project_new toycpu -revision toycpu -overwrite 1project_new toycpu -revision toycpu -overwrite
4 2
5set_global_assignment -name DEVICE 10CL025YU256I7G 3set_global_assignment -name DEVICE 10CL025YU256I7G
6 4
7set_global_assignment -name TOP_LEVEL_ENTITY top 5set_global_assignment -name TOP_LEVEL_ENTITY top
6set_global_assignment -name VERILOG_INPUT_VERSION SYSTEMVERILOG_2005
7set_global_assignment -name VERILOG_MACRO "SYNTHESIS=1"
8
9set_location_assignment PIN_E1 -to clk
10set_location_assignment PIN_J15 -to reset_n
8 11
9set_location_assignment -to clk PIN_E1 12set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to clk
10set_location_assignment -to reset_n PIN_J15 13set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to reset_n
11 14
12create_base_clock -fmax "50 MHz" -target clk clock_50m 15create_base_clock -fmax "50 MHz" clk
13 16
14foreach arg $quartus(args) { 17set_global_assignment -name CDF_FILE programmer.cdf
15 set_global_assignment -name VERILOG_FILE $arg 18set_global_assignment -name HEX_FILE rom.hex
16} 19set_global_assignment -name SDC_FILE clocks.sdc
20set_global_assignment -name VERILOG_FILE bin2bcd.sv
21set_global_assignment -name VERILOG_FILE fibseq.sv
22set_global_assignment -name VERILOG_FILE jtag_uart.sv
23set_global_assignment -name VERILOG_FILE ntoa.sv
24set_global_assignment -name VERILOG_FILE top.sv
17 25
18project_close 26project_close
diff --git a/programmer.cdf b/programmer.cdf
new file mode 100644
index 0000000..cbe240b
--- /dev/null
+++ b/programmer.cdf
@@ -0,0 +1,13 @@
1/* XXX Copy this from a working setup on Ducky hardware */
2JedecChain;
3 FileRevision(JESD32A);
4 DefaultMfr(6E);
5
6 P ActionCode(Cfg)
7 Device PartName(10CL025YU256) Path("C:/Users/mike/Desktop/toycpu/") File("toycpu.pof") MfrSpec(OpMask(1));
8
9ChainEnd;
10
11AlteraBegin;
12 ChainType(JTAG);
13AlteraEnd;