diff --git a/Makefile b/Makefile index 9b27fcc..79a3415 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,7 @@ log: $(SYNTH) -q -E $@.d -p "synth_ice40 -top $(*F)" -b json -o $@ -f verilog $< -l log/$(*F).synth define run-jsontov = - ( echo '`include "common.vh"'; grep timescale $*.v; \ - $(SYNTH) -q -p "write_verilog -defparam -noattr" -f json $< ) | \ - sed 's/endmodule/`DUMP(1)\n\0/g' > $@ + ( grep timescale $*.v; $(SYNTH) -q -p "write_verilog -defparam -noattr" -f json $< ) > $@ endef %.synth.v: %.synth.json %.v @@ -35,28 +33,29 @@ endef # Don't warn about including the timescale from common.vh IFLAGS := -g2012 -gspecify -Wall -Wno-timescale +EXTRA_V := rtl/iverilog_dump.v define run-icarus = -$(ICARUS) $(IFLAGS) -I$( $@.d; RET=$$?; rm -f $@.pre; exit $$RET endef %.vvp: TOP = $(*F) -%.vvp: %.v +%.vvp: %.v rtl/iverilog_dump.v $(run-icarus) %.synth.vvp: TOP = $(*F) -%.synth.vvp %.place.vvp: EXTRA_V := $(shell $(SYNTH)-config --datdir)/ice40/cells_sim.v +%.synth.vvp %.place.vvp: EXTRA_V += $(shell $(SYNTH)-config --datdir)/ice40/cells_sim.v # Don't warn about unused SB_IO ports %.synth.vvp: IFLAGS += -Wno-portbind -%.synth.vvp: %.synth.v +%.synth.vvp: %.synth.v rtl/iverilog_dump.v $(run-icarus) %.place.vvp: TOP = top # Don't warn about unused SB_IO ports %.place.vvp: IFLAGS += -Wno-portbind %.place.vvp: IFLAGS += -DTIMING -Ttyp -%.place.vvp: %.place.v +%.place.vvp: %.place.v rtl/iverilog_dump.v $(run-icarus) %.asc %.sdf %.place.json &: %.synth.json | log @@ -79,13 +78,15 @@ define run-vvp = MODULE=tb.$* $(VVP) $(VVPFLAGS) $< $(PLUSARGS) endef +%.fst: PLUSARGS += +levels=0 %.fst: rtl/%.vvp tb/%.py FORCE $(run-vvp) +%.synth.fst: PLUSARGS += +levels=1 %.synth.fst: rtl/%.synth.vvp tb/%.py FORCE $(run-vvp) -%.place.fst: PLUSARGS += +sdf=rtl/$*.sdf +%.place.fst: PLUSARGS += +levels=1 +sdf=rtl/$*.sdf %.place.fst: rtl/%.place.vvp rtl/%.sdf tb/%.py FORCE $(run-vvp) diff --git a/rtl/common.vh b/rtl/common.vh index 4376074..1940f28 100644 --- a/rtl/common.vh +++ b/rtl/common.vh @@ -9,19 +9,4 @@ `default_nettype none `timescale 1ns/1ns -`ifdef SYNTHESIS -`define DUMP(levels) -`else -`define DUMP(levels) \ - reg [4096:0] vcdfile, sdffile; \ - initial begin \ - if ($value$plusargs("vcd=%s", vcdfile)) begin \ - $dumpfile(vcdfile); \ - $dumpvars(levels); \ - end \ - if ($value$plusargs("sdf=%s", sdffile)) \ - $sdf_annotate(sdffile); \ - end -`endif - `endif /* COMMON_VH */ diff --git a/rtl/descramble.v b/rtl/descramble.v index 16fdc21..20706da 100644 --- a/rtl/descramble.v +++ b/rtl/descramble.v @@ -115,6 +115,4 @@ module descramble ( end end - `DUMP(0) - endmodule diff --git a/rtl/iverilog_dump.v b/rtl/iverilog_dump.v new file mode 100644 index 0000000..8b08680 --- /dev/null +++ b/rtl/iverilog_dump.v @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: AGPL-3.0-Only +/* + * Copyright (C) 2022 Sean Anderson + */ + +module iverilog_dump(); + integer levels; + reg [4096:0] vcdfile, sdffile; + initial begin + if ($value$plusargs("vcd=%s", vcdfile) && + $value$plusargs("levels=%d", levels)) begin + $dumpfile(vcdfile); + $dumpvars(levels, `TOP); + end + if ($value$plusargs("sdf=%s", sdffile)) + $sdf_annotate(sdffile, `TOP); + end +endmodule diff --git a/rtl/mdio.v b/rtl/mdio.v index b7086c9..fa08a80 100644 --- a/rtl/mdio.v +++ b/rtl/mdio.v @@ -216,6 +216,4 @@ module mdio ( end `endif - `DUMP(0) - endmodule diff --git a/rtl/mdio_io.v b/rtl/mdio_io.v index b79fb37..2e99b61 100644 --- a/rtl/mdio_io.v +++ b/rtl/mdio_io.v @@ -78,6 +78,4 @@ module mdio_io ( oe <= 0; end - `DUMP(0) - endmodule diff --git a/rtl/mdio_regs.v b/rtl/mdio_regs.v index e99d56a..c9be29d 100644 --- a/rtl/mdio_regs.v +++ b/rtl/mdio_regs.v @@ -149,6 +149,4 @@ module mdio_regs ( data_read <= data_read_next; end - `DUMP(0) - endmodule diff --git a/rtl/mii_io_rx.v b/rtl/mii_io_rx.v index a73da71..0dbeadb 100644 --- a/rtl/mii_io_rx.v +++ b/rtl/mii_io_rx.v @@ -121,6 +121,4 @@ module mii_io_rx ( end `endif - `DUMP(0) - endmodule diff --git a/rtl/mii_io_tx.v b/rtl/mii_io_tx.v index eefc463..5566e77 100644 --- a/rtl/mii_io_tx.v +++ b/rtl/mii_io_tx.v @@ -113,6 +113,4 @@ module mii_io_tx ( end `endif - `DUMP(0) - endmodule diff --git a/rtl/nrzi_decode.v b/rtl/nrzi_decode.v index adae854..ece1326 100644 --- a/rtl/nrzi_decode.v +++ b/rtl/nrzi_decode.v @@ -34,6 +34,4 @@ module nrzi_decode ( nrz <= nrz_next; end - `DUMP(0) - endmodule diff --git a/rtl/nrzi_encode.v b/rtl/nrzi_encode.v index 5f9ae4c..ea667d1 100644 --- a/rtl/nrzi_encode.v +++ b/rtl/nrzi_encode.v @@ -20,6 +20,4 @@ module nrzi_encode ( always @(posedge clk) nrzi <= nrzi_next; - `DUMP(0) - endmodule diff --git a/rtl/pcs.v b/rtl/pcs.v index cd8bf58..7a343b9 100644 --- a/rtl/pcs.v +++ b/rtl/pcs.v @@ -90,8 +90,6 @@ module pcs ( assign col = transmitting && receiving; assign crs = transmitting || receiving; - `DUMP(0) - endmodule /* Transmit process */ diff --git a/rtl/pmd_io.v b/rtl/pmd_io.v index daef1f7..b6b9ee1 100644 --- a/rtl/pmd_io.v +++ b/rtl/pmd_io.v @@ -213,6 +213,4 @@ module pmd_io ( end `endif - `DUMP(0) - endmodule diff --git a/rtl/scramble.v b/rtl/scramble.v index 85bb7ad..3dbc643 100644 --- a/rtl/scramble.v +++ b/rtl/scramble.v @@ -23,6 +23,4 @@ module scramble ( always @(posedge clk) lfsr = { lfsr[9:0], lfsr_next }; - `DUMP(0) - endmodule