mirror of
https://github.com/lowobservable/coax.git
synced 2026-02-27 01:19:52 +00:00
Verilog templating
This commit is contained in:
13
interface2/Makefile
Normal file
13
interface2/Makefile
Normal file
@@ -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
|
||||
3
interface2/rtl/.gitignore
vendored
Normal file
3
interface2/rtl/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*.json
|
||||
*.asc
|
||||
*.bin
|
||||
25
interface2/rtl/Makefile
Normal file
25
interface2/rtl/Makefile
Normal file
@@ -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
|
||||
15
interface2/rtl/coax_tx.v
Normal file
15
interface2/rtl/coax_tx.v
Normal file
@@ -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
|
||||
6
interface2/rtl/pins.pcf
Normal file
6
interface2/rtl/pins.pcf
Normal file
@@ -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
|
||||
14
interface2/rtl/top.v
Normal file
14
interface2/rtl/top.v
Normal file
@@ -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
|
||||
2
interface2/tests/.gitignore
vendored
Normal file
2
interface2/tests/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*_tb
|
||||
*.vcd
|
||||
19
interface2/tests/Makefile
Normal file
19
interface2/tests/Makefile
Normal file
@@ -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
|
||||
32
interface2/tests/coax_tx_tb.v
Normal file
32
interface2/tests/coax_tx_tb.v
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user