ASIC/FPGA Design and Verification Out Source Services
IP TTL filter digital design, implemented in VHDL.
-
This project implements an IP TTL filter in hardware. If an IPV4
packet is identified, the DUT checks its TTL field. Based on previous values of TTL in former packets,
the machine decides if the packet is spoofed or not. The main page
of this
project.;
-
This page describes the simulation script: compile and run simulation is done using the free VHDL simulator:
GHDL.
-
To compile: ./ghdl_cmp.unx
To simulate with VCD waves: ./ghdl_cmp.unx vcd
To simulate without VCD waves: ./ghdl_cmp.unx run
-
The script tries to figure out on each stage if the job ended okay. If not
it stops and prints some info.
#!/bin/bash
#clear - removes the compilation directory before start
if [ "$1" = "clear" ] ; then
#clear any former compilation results
rm -fr work
shift
fi
if [ -d "work" ] ; then
echo "work directory exists"
else
mkdir work
fi
skip="f"
if [ "$1" = "vcd" ] ; then
skip="t"
else
if [ "$1" = "run" ] ; then
skip="t"
fi
fi
if [ "$skip" = "f" ] ; then
ghdl -i --workdir=work --ieee=synopsys tb_rx_top.vhd rx_top.vhd ip_ttl_extract.vhd ip_ttl_control.vhd mem_model.vhd <& cmp.log
grep vhd cmp.log < /dev/null
if [ $? -eq 0 ] ; then
echo "compilation failed"
cat cmp.log
exit 1
else
ghdl -m --workdir=work --ieee=synopsys tb_rx_top
fi
grep "simulation ended okay" ghdl.log
if [ $? -ne 0 ] ; then
echo "test failed"
fi
fi
ghdl_run="./tb_rx_top --stop-time=100us --assert-level=error"
if [ "$1" = "vcd" ] ; then
ghdl_run=$ghdl_run" --vcdgz=ghdl.vcd.gz >& ghdl.log"
eval $ghdl_run
grep "simulation ended okay" ghdl.log
if [ $? -ne 0 ] ; then
echo "test failed"
fi
fi
if [ "$1" = "run" ] ; then
eval $ghdl_run" >& ghdl.log"
fi
-
I have also prepared a Makefile
for the project. Makefiles are much more
easier to maintain, and add some c code to enhance the test-bench:
GHDL c interfaces.
The makefile can be downloaded from:
Makefile.gz
The makefile is divided to three parts:
-
The first part is used to declare variables for the makefile: flags and
compilers.
#variables
CC = gcc
CFLAGS = -c -g
#-MD
SHELL := /bin/bash
GG = ghdl
...
-
The second one are options to run simulation, with or without VCD wave
record.
...
.PHONY : run
run :
./tb_rx_top $(RUN) |& tee ghdl.log
.PHONY : vcd
vcd :
./tb_rx_top $(RUN) $(VCD) |& tee ghdl.log
-
The last one is compilation. Note this step involves c code compilation
(gcc) and VHDL compilation
(ghdl).A few lines of the
compilation are listed below:
.PHONY : all
all : pkg g_rand.o work exe
.PHONY : exe
exe : work
$(GG) $(EFLAGS) -Pmy_lib --workdir=work --ieee=synopsys tb_rx_top
.PHONY : work
work : my_package.vhd ...
-
For more details on this project, please send an e-mail
and put in the subject:
IP TTL filter.
|