mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #805 from eddiehung/dff_init
write_verilog to write initial statement for initial flop state
This commit is contained in:
commit
2a8e5bf953
|
@ -1310,6 +1310,15 @@ void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reg_ct.count(cell->type) && cell->hasPort("\\Q")) {
|
||||||
|
std::stringstream ss;
|
||||||
|
dump_reg_init(ss, cell->getPort("\\Q"));
|
||||||
|
if (!ss.str().empty()) {
|
||||||
|
f << stringf("%sinitial %s.Q", indent.c_str(), cell_name.c_str());
|
||||||
|
f << ss.str();
|
||||||
|
f << ";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_conn(std::ostream &f, std::string indent, const RTLIL::SigSpec &left, const RTLIL::SigSpec &right)
|
void dump_conn(std::ostream &f, std::string indent, const RTLIL::SigSpec &left, const RTLIL::SigSpec &right)
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
module dff0_test(n1, n1_inv, clk);
|
||||||
|
input clk;
|
||||||
|
output n1;
|
||||||
|
reg n1 = 32'd0;
|
||||||
|
output n1_inv;
|
||||||
|
always @(posedge clk)
|
||||||
|
n1 <= n1_inv;
|
||||||
|
assign n1_inv = ~n1;
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module dff1_test(n1, n1_inv, clk);
|
||||||
|
input clk;
|
||||||
|
(* init = 32'd1 *)
|
||||||
|
output n1;
|
||||||
|
reg n1 = 32'd1;
|
||||||
|
output n1_inv;
|
||||||
|
always @(posedge clk)
|
||||||
|
n1 <= n1_inv;
|
||||||
|
assign n1_inv = ~n1;
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module dff0a_test(n1, n1_inv, clk);
|
||||||
|
input clk;
|
||||||
|
(* init = 32'd0 *) // Must be consistent with reg initialiser below
|
||||||
|
output n1;
|
||||||
|
reg n1 = 32'd0;
|
||||||
|
output n1_inv;
|
||||||
|
always @(posedge clk)
|
||||||
|
n1 <= n1_inv;
|
||||||
|
assign n1_inv = ~n1;
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module dff1a_test(n1, n1_inv, clk);
|
||||||
|
input clk;
|
||||||
|
(* init = 32'd1 *) // Must be consistent with reg initialiser below
|
||||||
|
output n1;
|
||||||
|
reg n1 = 32'd1;
|
||||||
|
output n1_inv;
|
||||||
|
always @(posedge clk)
|
||||||
|
n1 <= n1_inv;
|
||||||
|
assign n1_inv = ~n1;
|
||||||
|
endmodule
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
OPTIND=1
|
||||||
|
seed="" # default to no seed specified
|
||||||
|
while getopts "S:" opt
|
||||||
|
do
|
||||||
|
case "$opt" in
|
||||||
|
S) arg="${OPTARG#"${OPTARG%%[![:space:]]*}"}" # remove leading space
|
||||||
|
seed="SEED=$arg" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift "$((OPTIND-1))"
|
||||||
|
|
||||||
|
# check for Icarus Verilog
|
||||||
|
if ! which iverilog > /dev/null ; then
|
||||||
|
echo "$0: Error: Icarus Verilog 'iverilog' not found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp ../simple/*.v .
|
||||||
|
exec ${MAKE:-make} -f ../tools/autotest.mk $seed *.v EXTRA_FLAGS="-B \"-defparam\""
|
|
@ -28,7 +28,7 @@ if [ ! -f $toolsdir/cmp_tbdata -o $toolsdir/cmp_tbdata.c -nt $toolsdir/cmp_tbdat
|
||||||
( set -ex; ${CC:-gcc} -Wall -o $toolsdir/cmp_tbdata $toolsdir/cmp_tbdata.c; ) || exit 1
|
( set -ex; ${CC:-gcc} -Wall -o $toolsdir/cmp_tbdata $toolsdir/cmp_tbdata.c; ) || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts xmGl:wkjvref:s:p:n:S:I:-: opt; do
|
while getopts xmGl:wkjvref:s:p:n:S:I:B:-: opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
x)
|
x)
|
||||||
use_xsim=true ;;
|
use_xsim=true ;;
|
||||||
|
@ -65,6 +65,8 @@ while getopts xmGl:wkjvref:s:p:n:S:I:-: opt; do
|
||||||
include_opts="$include_opts -I $OPTARG"
|
include_opts="$include_opts -I $OPTARG"
|
||||||
xinclude_opts="$xinclude_opts -i $OPTARG"
|
xinclude_opts="$xinclude_opts -i $OPTARG"
|
||||||
minclude_opts="$minclude_opts +incdir+$OPTARG" ;;
|
minclude_opts="$minclude_opts +incdir+$OPTARG" ;;
|
||||||
|
B)
|
||||||
|
backend_opts="$backend_opts $OPTARG" ;;
|
||||||
-)
|
-)
|
||||||
case "${OPTARG}" in
|
case "${OPTARG}" in
|
||||||
xfirrtl)
|
xfirrtl)
|
||||||
|
@ -82,7 +84,7 @@ while getopts xmGl:wkjvref:s:p:n:S:I:-: opt; do
|
||||||
;;
|
;;
|
||||||
esac;;
|
esac;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 [-x|-m] [-G] [-w] [-k] [-j] [-v] [-r] [-e] [-l libs] [-f frontend] [-s script] [-p cmdstring] [-n iters] [-S seed] [-I incdir] [--xfirrtl FIRRTL test exclude file] [--firrtl2verilog command to generate verilog from firrtl] verilog-files\n" >&2
|
echo "Usage: $0 [-x|-m] [-G] [-w] [-k] [-j] [-v] [-r] [-e] [-l libs] [-f frontend] [-s script] [-p cmdstring] [-n iters] [-S seed] [-I incdir] [-B backend_opt] [--xfirrtl FIRRTL test exclude file] [--firrtl2verilog command to generate verilog from firrtl] verilog-files\n" >&2
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue