diff --git a/interface2/Makefile b/interface2/Makefile new file mode 100644 index 0000000..55caf30 --- /dev/null +++ b/interface2/Makefile @@ -0,0 +1,13 @@ +SUBDIRS = tests rtl + +all: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@ + +clean: + for dir in $(SUBDIRS); do \ + $(MAKE) -C $$dir clean; \ + done + +.PHONY: all $(SUBDIRS) clean diff --git a/interface2/rtl/.gitignore b/interface2/rtl/.gitignore new file mode 100644 index 0000000..a7ca026 --- /dev/null +++ b/interface2/rtl/.gitignore @@ -0,0 +1,3 @@ +*.json +*.asc +*.bin diff --git a/interface2/rtl/Makefile b/interface2/rtl/Makefile new file mode 100644 index 0000000..1c306fe --- /dev/null +++ b/interface2/rtl/Makefile @@ -0,0 +1,25 @@ +YOSYS ?= yosys +NEXTPNR ?= nextpnr-ice40 +ICEPACK ?= icepack +TINYPROG ?= tinyprog + +all: top.bin + +top.json: top.v coax_tx.v + +prog: top.bin + $(TINYPROG) -p top.bin + +clean: + rm -f *.json *.asc *.bin + +%.json: + $(YOSYS) -p 'synth_ice40 -top top -json $@' $^ + +%.asc: %.json pins.pcf + $(NEXTPNR) --lp8k --package cm81 --json $< --pcf pins.pcf --asc $@ + +%.bin: %.asc + $(ICEPACK) $< $@ + +.PHONY: all prog clean diff --git a/interface2/rtl/coax_tx.v b/interface2/rtl/coax_tx.v new file mode 100644 index 0000000..8b18625 --- /dev/null +++ b/interface2/rtl/coax_tx.v @@ -0,0 +1,15 @@ +`default_nettype none + +module coax_tx ( + input clk, + output tx +); + reg state = 0; + + always @(posedge clk) + begin + state <= ~state; + end + + assign tx = state; +endmodule diff --git a/interface2/rtl/pins.pcf b/interface2/rtl/pins.pcf new file mode 100644 index 0000000..3371559 --- /dev/null +++ b/interface2/rtl/pins.pcf @@ -0,0 +1,6 @@ +set_io --warn-no-port tx B8 + +# 16MHz clock +set_io --warn-no-port clk B2 + +set_io --warn-no-port usb_pu A3 diff --git a/interface2/rtl/top.v b/interface2/rtl/top.v new file mode 100644 index 0000000..2ef62e6 --- /dev/null +++ b/interface2/rtl/top.v @@ -0,0 +1,14 @@ +`default_nettype none + +module top ( + input clk, + output tx, + output usb_pu +); + coax_tx coax_tx ( + .clk(clk), + .tx(tx) + ); + + assign usb_pu = 0; +endmodule diff --git a/interface2/tests/.gitignore b/interface2/tests/.gitignore new file mode 100644 index 0000000..4500487 --- /dev/null +++ b/interface2/tests/.gitignore @@ -0,0 +1,2 @@ +*_tb +*.vcd diff --git a/interface2/tests/Makefile b/interface2/tests/Makefile new file mode 100644 index 0000000..643ef91 --- /dev/null +++ b/interface2/tests/Makefile @@ -0,0 +1,19 @@ +IVERILOG ?= iverilog +VVP ?= vvp + +RTL = ../rtl + +all: coax_tx_tb.vcd + +coax_tx_tb: coax_tx_tb.v $(RTL)/coax_tx.v + +clean: + rm -f *_tb *.vcd + +%_tb: + $(IVERILOG) -o $@ $^ + +%_tb.vcd: %_tb + $(VVP) -N $< -lxt2 + +.PHONY: all, clean diff --git a/interface2/tests/coax_tx_tb.v b/interface2/tests/coax_tx_tb.v new file mode 100644 index 0000000..b284cbd --- /dev/null +++ b/interface2/tests/coax_tx_tb.v @@ -0,0 +1,32 @@ +`default_nettype none + +module coax_tx_tb(); + reg clk = 0; + + initial + begin + clk <= 1'h0; + + forever + begin + #1 clk <= ~clk; + end + end + + wire tx; + + coax_tx dut ( + .clk(clk), + .tx(tx) + ); + + initial + begin + $dumpfile("coax_tx_tb.vcd"); + $dumpvars(0, coax_tx_tb); + + repeat(100) @(posedge clk); + + $finish; + end +endmodule