Commit 4a182d70 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Refined Makefile for parallel jobs, added new path concept to user guide

parent 7a461a4d
......@@ -180,8 +180,24 @@ Once a netlist is loaded, the user may start with selecting a net to be
instrumented. This is done using a filter dialog which is opened by pressing
the \textit{Select} button next to the net entry field (1).
An example for this dialog is shown in Figure~\ref{fig:netsel}. The entry field across
the top may be used to specify a net or perl-style regular expression
to search the netlist for. Once the user presses the \textit{Search} button, all matching
the top may be used to specify a hierarchical path to a net as perl-style regular expression\footnote{This means that the backslashes and other regex meta characters in escaped identifiers need to be escaped themselves, e.g. for net ``\texttt{{\textbackslash}escaped.identifier }'' write ``\texttt{{\textbackslash}{\textbackslash}escaped{\textbackslash}.identifier }''}.
A hierarchical path shall be constructed as follows:
\begin{verbatim}
<hierarchical-path> ::= <top> "/" <net> | <top> <cell-list> "/" <net>
<cell-list> ::= "/" <cell> | <cell-list> "/" <cell>
<top> ::= Toplevel module name
<net> ::= Net name
<cell> ::= Cell name
\end{verbatim}
A hierarchical path starts with the name of the toplevel module, then
contains a path of instantiation names, and finally, the name of a net.
The forward slash character \texttt{`/'} is used as a separator between
module, instantiation, and net names.
Once the user presses the \textit{Search} button, all matching
nets are displayed in the left list box (``Matching nets''). The desired net
can now be selected for fault injection by first selecting it in the
left list box and then pressing the ``\textgreater'' button. Once a net is selected,
......
SHELL:=/bin/bash
MORIG:=$(MAKEFLAGS)
MAKEFLAGS=$(MORIG) -j --output-sync=recurse
RUN_SIMULATION_DO=$(realpath run_simulation.do)
# Directory setup
FIJI_DIR=$(realpath ../../../)
BINDIR=$(FIJI_DIR)/bin
CFGDIR=fiji
NETLISTDIR=netlists
NETLISTS_DIR=$(realpath netlists)
TB_DIR=$(realpath tb)
SIMDIR=simulation
INSTDIR=instrument
INSTRUMENT_DIR=$(realpath instrument)
# Testcases are defined by the netlists in the netlist dir
NETLISTS=$(shell find $(NETLISTDIR) -type f -iname '*.v')
NETLISTS=$(shell find $(NETLISTS_DIR) -type f -iname '*.v')
# All other file categories are based on the available netlists
CONFIGURATIONS=$(foreach x, $(NETLISTS), $(CFGDIR)/$(basename $(notdir $x)).cfg)
INSTRUMENTED_NETLISTS=$(foreach x, $(NETLISTS), $(INSTDIR)/$(basename $(notdir $x))/test_instrumented.vqm)
SYNPLIFY_LOGS=$(foreach x, $(NETLISTS), $(INSTDIR)/$(basename $(notdir $x))/synplify_stdio.log)
INSTRUMENTED_NETLISTS=$(foreach x, $(NETLISTS), $(INSTRUMENT_DIR)/$(basename $(notdir $x))/test_instrumented.vqm)
SYNPLIFY_LOGS=$(foreach x, $(NETLISTS), $(INSTRUMENT_DIR)/$(basename $(notdir $x))/synplify_stdio.log)
SYNPLIFY_OUT=$(foreach x, $(NETLISTS), $(INSTRUMENT_DIR)/$(basename $(notdir $x))/CycloneV)
SIMULATION_LOGS=$(foreach x, $(NETLISTS), $(SIMDIR)/$(basename $(notdir $x))/questasim.log)
INSTRUMENT_PER=$(shell find $(BINDIR) -type f \( -iname '*.pl' -o -iname '*.pm' \))
# String matching functions: thank you http://stackoverflow.com/a/12324443
containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))
# ------------------------------------------------------- Default target
tests : $(INSTRUMENTED_NETLISTS) $(SYNPLIFY_LOGS) $(SIMULATION_LOGS)
tests : simulation synthesis
simulation : $(SIMULATION_LOGS)
synthesis : $(SYNPLIFY_LOGS)
# ---------------------------------------------------------------- Setup
$(CONFIGURATIONS): $(CFGDIR)/%.cfg : $(NETLISTDIR)/%.v
@perl ../../../bin/fiji_setup.pl -n "$<" -s "$@" || \
(echo "Setup error" && echo -n "Press [Enter] to continue..." && read -r)
$(CONFIGURATIONS): $(CFGDIR)/%.cfg : $(NETLISTS_DIR)/%.v
@echo -ne "Configuring $(notdir $(basename $<))...\r\e[72C"
@perl ../../../bin/fiji_setup.pl -n "$<" -s "$@" > /dev/null && echo -e "[\e[32mOK\e[0m]" || \
(echo -e "[\e[31mFAILED\e[0m]" && echo -n "Press [Enter] to continue..." && read -r)
# ------------------------------------------------------ Instrumentation
$(INSTRUMENTED_NETLISTS): $(INSTDIR)/%/test_instrumented.vqm : $(NETLISTDIR)/%.v $(CFGDIR)/%.cfg
@perl ../../../bin/fiji_instrument.pl -n "$<" -s "fiji/$(basename $(notdir $<)).cfg" -o $(@D) -p test > /dev/null || \
(echo "Instrument error" && echo -n "Press [Enter] to continue..." && read -r)
$(INSTRUMENTED_NETLISTS): $(INSTRUMENT_DIR)/%/test_instrumented.vqm : $(NETLISTS_DIR)/%.v $(CFGDIR)/%.cfg $(INSTRUMENT_PERL)
@echo -ne "Instrumenting $(notdir $(basename $<))...\r\e[72C"
@perl ../../../bin/fiji_instrument.pl -n "$<" -s "fiji/$(basename $(notdir $<)).cfg" -o $(@D) -p test > /dev/null && echo -e "[\e[32mOK\e[0m]" || \
(echo -e "[\e[31mFAILED\e[0m]" && echo -n "Press [Enter] to continue..." && read -r)
# ------------------------------------------------------ Synthesis Check
$(SYNPLIFY_LOGS): $(INSTDIR)/%/synplify_stdio.log : $(INSTDIR)/%/test_instrumented.vqm synplify.sh
@echo -en "Checking syntax of $(notdir $(basename $(@D)))...\r\e[72C"
@./synplify.sh $(@D) $< || echo "Syntax check error for $<" >&2
$(SYNPLIFY_LOGS): $(INSTRUMENT_DIR)/%/synplify_stdio.log : $(INSTRUMENT_DIR)/%/test_instrumented.vqm synplify.sh
@echo -en "Synthesizing $(notdir $(basename $(@D)))...\r\e[72C"
@./synplify.sh $(@D) $< || /bin/true
# ----------------------------------------------------------- Simulation
# For designs instrumenting buses
$(call containing,bus,$(SIMULATION_LOGS)): $(SIMDIR)/%/questasim.log : $(INSTDIR)/%/test_instrumented.vqm simlib/work/.compiled simlib/ori/.compiled run_simulation.do
$(call containing,bus,$(SIMULATION_LOGS)): $(SIMDIR)/%/questasim.log : $(INSTRUMENT_DIR)/%/test_instrumented.vqm run_simulation.do
@mkdir -p $(@D)
@echo -en "Simulating $(notdir $(basename $(@D)))...\r\e[72C"
@vsim -c -do "do run_simulation.do $(notdir $(basename $(@D))) 1" -quiet -nostdout 2>&1 > /dev/null && mv transcript $@ && echo -e "[\e[32mOK\e[0m]" || \
(mv transcript $@ && echo -e "[\e[31mFAILED\e[0m]" && echo "Simulation error, see $@" >&2) \
@mv wave.vcd $(@D) 2> /dev/null || echo "No vcd generated."
@cp simlib.mk $(@D)/Makefile
@$(MAKE) -s -C $(@D) RUN_SIMULATION_DO=$(RUN_SIMULATION_DO) \
NETLISTS_DIR=$(NETLISTS_DIR) \
INSTRUMENT_DIR=$(INSTRUMENT_DIR) \
FIJI_DIR=$(FIJI_DIR) \
TB_DIR=$(TB_DIR) \
TESTCASE_NAME=$(notdir $(basename $(@D))) \
BUS=1
# For designs instrumenting single-bit signals
$(call not-containing,bus,$(SIMULATION_LOGS)): $(SIMDIR)/%/questasim.log : $(INSTDIR)/%/test_instrumented.vqm simlib/work/.compiled simlib/ori/.compiled run_simulation.do
$(call not-containing,bus,$(SIMULATION_LOGS)): $(SIMDIR)/%/questasim.log : $(INSTRUMENT_DIR)/%/test_instrumented.vqm run_simulation.do
@mkdir -p $(@D)
@echo -en "Simulating $(notdir $(basename $(@D)))...\r\e[72C"
@vsim -c -do "do run_simulation.do $(notdir $(basename $(@D))) 0" -quiet -nostdout 2>&1 > /dev/null && mv transcript $@ && echo -e "[\e[32mOK\e[0m]" || \
(mv transcript $@ && echo -e "[\e[31mFAILED\e[0m]" && echo "Simulation error, see $@" >&2) \
@mv wave.vcd $(@D) 2> /dev/null || echo "No vcd generated."
# -------------------------------------------------------- Clean targets
@cp simlib.mk $(@D)/Makefile
@$(MAKE) -s -C $(@D) RUN_SIMULATION_DO=$(RUN_SIMULATION_DO) \
NETLISTS_DIR=$(NETLISTS_DIR) \
INSTRUMENT_DIR=$(INSTRUMENT_DIR) \
FIJI_DIR=$(FIJI_DIR) \
TB_DIR=$(TB_DIR) \
TESTCASE_NAME=$(notdir $(basename $(@D))) \
BUS=0
clean-all: clean-instrumented clean-synplify clean-simulation
rm -f all
......@@ -73,6 +92,7 @@ clean-instrumented:
rm -f $(INSTRUMENTED_NETLISTS)
clean-synplify:
rm -rf $(SYNPLIFY_OUT)
rm -f $(SYNPLIFY_LOGS)
clean-simulation:
......@@ -80,30 +100,3 @@ clean-simulation:
# --------------------------------------------- Simulation library setup
simlib/.created :
vlib simlib
touch $@
simlib/ori/.created : simlib/.created
vlib ./simlib/ori
vmap ori simlib/ori
touch $@
simlib/ori/.compiled : simlib/ori/.created
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_primitives.v -work ori
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/cyclonev_atoms.v -work ori
touch $@
simlib/work/.created : simlib/.created
vlib ./simlib/work
vmap work simlib/work
touch $@
simlib/work/.compiled : simlib/work/.created
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_primitives.v
vcom $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_primitives_components.vhd
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/cyclonev_atoms.v
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_lnsim.sv
vcom $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_lnsim_components.vhd
touch $@
......@@ -21,42 +21,11 @@ do
then
echo "FIJI::Instrument reported an error: $ret" >&2
echo "See $fiji_log" >&2
exit $ret
echo -n "Press [Enter] to continue..."; read -r
else
echo "FIJI::Instrument OK" >&2
fi
LC_ALL=C synplify_pro -batch \
-licensetype synplifypremierdp \
-tcl synplify.tcl \
$output_dir/ \
test_instrumented.vqm \
synplify.out.vqm synplify.log 2>&1 > "${output_dir}/synplify_stdio.log"
ret=$?
# Synplify does not seem to allow suppression of warnings by ID for syntax checks (yes, really)
# There are log_filter and message_override TCL commands but they have no effect whatsoever,
# therefore... grep logfile FTW
warnings_filter="^@W: CG146"
if [ -e "$output_dir/CycloneV/syntax.log" ]; then
warnings=$(grep '^@[WE]:' "$output_dir/CycloneV/syntax.log" | grep -v "$warnings_filter")
else
warnings="The syntax file was not even generated by synplify. This can't be good..."
fi
if [ "$ret" -ne 0 -a -n "$warnings" ]
then
printf "Synplify reported error code $ret for $instrumened_list, warnings:\n\n" >&2
echo "$warnings" >&2
printf "\nSee $(realpath $fiji_log)\n" >&2
printf "$(realpath ${output_dir}/synplify_stdio.log)\n" >&2
printf "$(realpath $output_dir/CycloneV/syntax.log)\n" >&2
exit $ret
else
echo "Synplify OK for $instrumened_list" >&2
fi
# diff <(cat "$netlist_file" | grep -Ev '^[\t ]*//' | sort) <(cat "$instrumened_list" | grep -Ev '^[\t ]*//' | sort)
echo >&2
echo -en "Synthesizing $instrumented_list...\r\e[72C"
./synplify.sh $output_dir $instrumened_list
done
# Simulation script for QuestaSim
# Compiles sources & performs checks during simulation
set testcase_name $1
set bus $2
set netlists_dir $1
set instrument_dir $2
set fiji_dir $3
set tb_dir $4
set testcase_name $5
set bus $6
transcript file "questasim.log"
set vcdfile "$testcase_name.vcd"
echo $testcase_name
echo $bus
......@@ -37,19 +45,19 @@ onbreak {
# compile source files
catch {
vlog -quiet "netlists/$testcase_name.v" -work ori
vlog -quiet "instrument/$testcase_name/test_instrumented.vqm"
vcom -quiet "../../../hw/rtl/fault_selection_type_pkg.vhd"
vcom -quiet "../../../hw/rtl/private_config_pkg.vhd"
vcom -quiet "instrument/$testcase_name/test_config_pkg.vhd"
vcom -quiet "../../../hw/rtl/fault_injection_top_pkg.vhd"
vcom -quiet "instrument/$testcase_name/test_wrapper.vhd"
vlog -quiet "$netlists_dir/$testcase_name.v" -work ori
vlog -quiet "$instrument_dir/$testcase_name/test_instrumented.vqm"
vcom -quiet "$fiji_dir/hw/rtl/fault_selection_type_pkg.vhd"
vcom -quiet "$fiji_dir/hw/rtl/private_config_pkg.vhd"
vcom -quiet "$instrument_dir/$testcase_name/test_config_pkg.vhd"
vcom -quiet "$fiji_dir/hw/rtl/fault_injection_top_pkg.vhd"
vcom -quiet "$instrument_dir/$testcase_name/test_wrapper.vhd"
# compile test bench
if { $bus == "1" } {
vcom tb/txt_util.vhd
vcom tb/tb_template_bus.vhd
vcom "$tb_dir/txt_util.vhd"
vcom "$tb_dir/tb_template_bus.vhd"
} else {
vcom tb/tb_template_sb.vhd
vcom "$tb_dir/tb_template_sb.vhd"
}
} rv
......@@ -59,14 +67,15 @@ if { $rv != "" } {
}
# load design
catch {vsim -quiet -c "work.tb(sim)" -t ps -nostdout} rv
echo "RV-> $rv"
if { [catch { vsim -quiet -c "work.tb(sim)" -t ps -nostdout } rv ] } {
echo $rv
quit -force -code 7
}
# VCD setup: dump wave to file
vcd file "wave.vcd"
vcd on "wave.vcd"
vcd file "$vcdfile"
vcd on "$vcdfile"
foreach sig [find signals *] { # add only toplevel signals (for all, add -recursive)
vcd add $sig
......@@ -80,7 +89,7 @@ foreach sig [find signals fiji* -recursive] { # add fiji signals
run 1 sec
# write vcd
vcd flush "wave.vcd"
vcd flush "$vcdfile"
# check if the simulation finished or was interrupted by an error
if {$broken == 1} {
......
questasim.log : work/.compiled ori/.compiled
@printf "Simulating $(TESTCASE_NAME)...\r\033[72C"
@(vsim -c -do "do $(RUN_SIMULATION_DO) $(NETLISTS_DIR) $(INSTRUMENT_DIR) $(FIJI_DIR) $(TB_DIR) $(TESTCASE_NAME) $(BUS) $(notdir $(basename $(@D))) 1" -quiet -nostdout -errorfile questasim.err 2>&1 > /dev/null && printf "[\033[32mOK\033[0m]\n\n") || \
(printf "[\033[31mFAILED\033[0m]\n\n" && printf "Simulation error, see $$PWD/$@\n\n" >&2)
ori/.created :
vlib ori
touch $@
ori/.compiled : ori/.created
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_primitives.v -work ori
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/cyclonev_atoms.v -work ori
touch $@
work/.created :
vlib work
touch $@
work/.compiled : work/.created
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_primitives.v
vcom $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_primitives_components.vhd
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/cyclonev_atoms.v
vlog $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_lnsim.sv
vcom $(QUARTUS_ROOTDIR)/eda/sim_lib/altera_lnsim_components.vhd
touch $@
......@@ -5,9 +5,10 @@ output_dir=$1
shift
instrumented_list=$1
LC_ALL=C synplify_pro -batch \
LC_ALL=C synplify_pro -tcl synplify.tcl \ \
-licensetype synplifypremierdp \
-tcl synplify.tcl \
-license_wait \
-batch \
$output_dir/ \
test_instrumented.vqm \
synplify.out.vqm synplify.log 2>&1 > "${output_dir}/synplify_stdio.log"
......@@ -31,11 +32,10 @@ done
if [ "$ret" -ne "0" -a -n "$warnings" ]
then
echo -e "[\e[31mFailed\e[0m]"
printf "Synplify reported error code $ret for \"$instrumented_list\" warnings:\n\n" >&2
echo "$warnings" >&2
echo -e "[\e[31mFAILED\e[0m]"
printf "Synplify reported error code $ret for \"$instrumented_list\"" >&2
printf " \nSee $(realpath ${output_dir}/synplify_stdio.log)\n" >&2
printf "$(realpath $output_dir/CycloneV/synlog/test_instrumented_premap.srr)\n" >&2
printf "$(realpath $output_dir/CycloneV/synlog/test_instrumented.srr)\n" >&2
exit 1
else
echo -e "[\e[32mOK\e[0m]"
......
if { $argc == 11 } {
set projectPath [lindex $argv 7]
set netlistFile [lindex $argv 8]
set resultFile [lindex $argv 9]
set logFile [lindex $argv 10]
puts $argv
if { $argc == 13 } {
set projectPath [lindex $argv 9]
set netlistFile [lindex $argv 10]
set resultFile [lindex $argv 11]
set logFile [lindex $argv 12]
puts $projectPath
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment