Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ BITGEN_OPTS ?=
TRACE_OPTS ?=
FUSE_OPTS ?= -incremental

TEST_POSTFIX ?= _tb

PROGRAMMER ?= none

IMPACT_OPTS ?= -batch impact.cmd
Expand Down Expand Up @@ -67,6 +69,8 @@ else
PATH := $(PATH):$(XILINX)/bin/$(XILINX_PLATFORM)
endif

VTEST = $(foreach file,$(wildcard *$(TEST_POSTFIX).v),$(file))
VHDTEST = $(foreach file,$(wildcard *$(TEST_POSTFIX).vhd),$(file))
TEST_NAMES = $(foreach file,$(VTEST) $(VHDTEST),$(basename $(file)))
TEST_EXES = $(foreach test,$(TEST_NAMES),build/isim_$(test)$(EXE))

Expand Down Expand Up @@ -138,24 +142,23 @@ trace: project.cfg $(BITFILE)
$(call RUN,trce) $(COMMON_OPTS) $(TRACE_OPTS) \
$(PROJECT).ncd $(PROJECT).pcf

test: $(TEST_EXES)
test: buildtest runtest

runtest: ${TEST_NAMES}

${TEST_NAMES}:
@grep --no-filename --no-messages 'ISIM:' $@.{v,vhd} | cut -d: -f2 > build/isim_$@.cmd
@echo "run all" >> build/isim_$@.cmd
cd build ; ./isim_$@$(EXE) -tclbatch isim_$@.cmd ;

build/isim_%$(EXE): build/$(PROJECT)_sim.prj $(VSOURCE) $(VHDSOURCE) $(VTEST) $(VHDTEST)
buildtest: ${TEST_EXES}

build/isim_%$(EXE): build/$(PROJECT)_sim.prj $(VSOURCE) $(VHDSOURCE) ${VTEST} $(VHDTEST)
$(call RUN,fuse) $(COMMON_OPTS) $(FUSE_OPTS) \
-prj $(PROJECT)_sim.prj \
-o isim_$*$(EXE) \
work.$* work.glbl

isim: build/isim_$(TB)$(EXE)
@grep --no-filename --no-messages 'ISIM:' $(TB).{v,vhd} | cut -d: -f2 > build/isim_$(TB).cmd
@echo "run all" >> build/isim_$(TB).cmd
cd build ; ./isim_$(TB)$(EXE) -tclbatch isim_$(TB).cmd

isimgui: build/isim_$(TB)$(EXE)
@grep --no-filename --no-messages 'ISIM:' $(TB).{v,vhd} | cut -d: -f2 > build/isim_$(TB).cmd
@echo "run all" >> build/isim_$(TB).cmd
cd build ; ./isim_$(TB)$(EXE) -gui -tclbatch isim_$(TB).cmd


###########################################################################
# Programming
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ The Xilinx ISE Makefile implements the following targets:

Builds the bitstream.

* `make test`

Runs any testbenches.

* `make clean`

Removes the build directory.
Expand All @@ -152,7 +156,17 @@ The Xilinx ISE Makefile implements the following targets:
Running unit tests
------------------

is a work in progress.
Test `test` target will build and run any testbenches that have been created.

A testbench is any file with a file finishing in `_tb` (overridden by `TEST_POSTFIX`).


Caviates
--------

* Module names need to match the filename they are within.

* Module names cannot start with a number.


Unimplemented features
Expand Down