RTL_DIR = ../rtl
RTL_FILES = $(RTL_DIR)/ldpc_decoder_top.sv \
            $(RTL_DIR)/ldpc_decoder_core.sv \
            $(RTL_DIR)/wishbone_interface.sv

.PHONY: lint sim sim_vectors clean

lint:
	verilator --lint-only -Wall \
		-Wno-WIDTHEXPAND -Wno-WIDTHTRUNC -Wno-CASEINCOMPLETE \
		-Wno-BLKSEQ -Wno-BLKLOOPINIT -Wno-UNUSEDSIGNAL -Wno-UNUSEDPARAM \
		--unroll-count 1024 \
		$(RTL_FILES) --top-module ldpc_decoder_top

sim: obj_dir/Vtb_ldpc_decoder
	./obj_dir/Vtb_ldpc_decoder

obj_dir/Vtb_ldpc_decoder: tb_ldpc_decoder.sv $(RTL_FILES)
	verilator --binary --timing --trace \
		-o Vtb_ldpc_decoder \
		-Wno-WIDTHEXPAND -Wno-WIDTHTRUNC -Wno-CASEINCOMPLETE \
		-Wno-BLKSEQ -Wno-BLKLOOPINIT -Wno-UNUSEDSIGNAL -Wno-UNUSEDPARAM \
		--unroll-count 1024 \
		tb_ldpc_decoder.sv $(RTL_FILES) \
		--top-module tb_ldpc_decoder

sim_vectors: obj_dir/Vtb_ldpc_vectors
	./obj_dir/Vtb_ldpc_vectors

obj_dir/Vtb_ldpc_vectors: tb_ldpc_vectors.sv $(RTL_FILES)
	verilator --binary --timing --trace \
		-o Vtb_ldpc_vectors \
		-Wno-WIDTHEXPAND -Wno-WIDTHTRUNC -Wno-CASEINCOMPLETE \
		-Wno-BLKSEQ -Wno-BLKLOOPINIT -Wno-UNUSEDSIGNAL -Wno-UNUSEDPARAM \
		--unroll-count 1024 \
		tb_ldpc_vectors.sv $(RTL_FILES) \
		--top-module tb_ldpc_vectors

clean:
	rm -rf obj_dir *.vcd
