diff --git a/.gitignore b/.gitignore index 46912fbdc..a7f4cd4df 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ examples/abc/scala/project examples/abc/scala/target tests/**/*.v +*.pdf +*.dot diff --git a/.gitmodules b/.gitmodules index 9dd29a4d5..ed682c923 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,144 +7,190 @@ [submodule "lib/pybind11"] path = lib/pybind11 url = https://github.com/pybind/pybind11.git + ignore = dirty [submodule "lib/boost/any"] path = lib/boost/any url = https://github.com/boostorg/any.git + ignore = dirty [submodule "lib/boost/bind"] path = lib/boost/bind url = https://github.com/boostorg/bind.git + ignore = dirty [submodule "lib/boost/config"] path = lib/boost/config url = https://github.com/boostorg/config.git + ignore = dirty [submodule "lib/boost/core"] path = lib/boost/core url = https://github.com/boostorg/core.git + ignore = dirty [submodule "lib/boost/detail"] path = lib/boost/detail url = https://github.com/boostorg/detail.git + ignore = dirty [submodule "lib/boost/function"] path = lib/boost/function url = https://github.com/boostorg/function.git + ignore = dirty [submodule "lib/boost/iterator"] path = lib/boost/iterator url = https://github.com/boostorg/iterator.git + ignore = dirty [submodule "lib/boost/lexical_cast"] path = lib/boost/lexical_cast url = https://github.com/boostorg/lexical_cast.git + ignore = dirty [submodule "lib/boost/program_options"] path = lib/boost/program_options url = https://github.com/boostorg/program_options.git + ignore = dirty [submodule "lib/boost/smart_ptr"] path = lib/boost/smart_ptr url = https://github.com/boostorg/smart_ptr.git + ignore = dirty [submodule "lib/boost/static_assert"] path = lib/boost/static_assert url = https://github.com/boostorg/static_assert.git + ignore = dirty [submodule "lib/boost/throw_exception"] path = lib/boost/throw_exception url = https://github.com/boostorg/throw_exception.git + ignore = dirty [submodule "lib/boost/tokenizer"] path = lib/boost/tokenizer url = https://github.com/boostorg/tokenizer.git + ignore = dirty [submodule "lib/boost/type_traits"] path = lib/boost/type_traits url = https://github.com/boostorg/type_traits.git + ignore = dirty [submodule "lib/kahypar"] path = lib/kahypar url = https://github.com/lnis-uofu/kahypar.git [submodule "lib/boost/assert"] path = lib/boost/assert url = https://github.com/boostorg/assert.git + ignore = dirty [submodule "lib/boost/type_index"] path = lib/boost/type_index url = https://github.com/boostorg/type_index.git + ignore = dirty [submodule "lib/boost/preprocessor"] path = lib/boost/preprocessor url = https://github.com/boostorg/preprocessor.git + ignore = dirty [submodule "lib/boost/integer"] path = lib/boost/integer url = https://github.com/boostorg/integer.git + ignore = dirty [submodule "lib/boost/range"] path = lib/boost/range url = https://github.com/boostorg/range.git + ignore = dirty [submodule "lib/boost/mpl"] path = lib/boost/mpl url = https://github.com/boostorg/mpl.git + ignore = dirty [submodule "lib/boost/array"] path = lib/boost/array url = https://github.com/boostorg/array.git + ignore = dirty [submodule "lib/boost/move"] path = lib/boost/move url = https://github.com/boostorg/move.git + ignore = dirty [submodule "lib/boost/utility"] path = lib/boost/utility url = https://github.com/boostorg/utility.git + ignore = dirty [submodule "lib/boost/io"] path = lib/boost/io url = https://github.com/boostorg/io.git + ignore = dirty [submodule "lib/boost/numeric_conversion"] path = lib/boost/numeric_conversion url = https://github.com/boostorg/numeric_conversion.git + ignore = dirty [submodule "lib/boost/container"] path = lib/boost/container url = https://github.com/boostorg/container.git + ignore = dirty [submodule "lib/boost/concept_check"] path = lib/boost/concept_check url = https://github.com/boostorg/concept_check.git + ignore = dirty [submodule "lib/boost/container_hash"] path = lib/boost/container_hash url = https://github.com/boostorg/container_hash.git + ignore = dirty [submodule "lib/boost/regex"] path = lib/boost/regex url = https://github.com/boostorg/regex.git + ignore = dirty [submodule "lib/boost/optional"] path = lib/boost/optional url = https://github.com/boostorg/optional.git + ignore = dirty [submodule "lib/boost/tuple"] path = lib/boost/tuple url = https://github.com/boostorg/tuple.git + ignore = dirty [submodule "lib/boost/intrusive"] path = lib/boost/intrusive url = https://github.com/boostorg/intrusive.git + ignore = dirty [submodule "lib/boost/predef"] path = lib/boost/predef url = https://github.com/boostorg/predef.git + ignore = dirty [submodule "lib/boost/winapi"] path = lib/boost/winapi url = https://github.com/boostorg/winapi.git + ignore = dirty [submodule "lib/boost/conversion"] path = lib/boost/conversion url = https://github.com/boostorg/conversion.git + ignore = dirty [submodule "lib/boost/typeof"] path = lib/boost/typeof url = https://github.com/boostorg/typeof.git + ignore = dirty [submodule "lib/boost/fusion"] path = lib/boost/fusion url = https://github.com/boostorg/fusion.git + ignore = dirty [submodule "lib/boost/function_types"] path = lib/boost/function_types url = https://github.com/boostorg/function_types.git + ignore = dirty [submodule "lib/boost/dynamic_bitset"] path = lib/boost/dynamic_bitset url = https://github.com/boostorg/dynamic_bitset.git + ignore = dirty [submodule "lib/boost/algorithm"] path = lib/boost/algorithm url = https://github.com/boostorg/algorithm.git + ignore = dirty [submodule "lib/boost/unordered"] path = lib/boost/unordered url = https://github.com/boostorg/unordered.git + ignore = dirty [submodule "lib/boost/exception"] path = lib/boost/exception url = https://github.com/boostorg/exception.git + ignore = dirty [submodule "lib/googletest"] path = lib/googletest url = https://github.com/google/googletest.git + ignore = dirty [submodule "lib/OpenSTA"] path = lib/OpenSTA url = https://github.com/The-OpenROAD-Project/OpenSTA.git + ignore = dirty [submodule "lib/json"] path = lib/json url = https://github.com/nlohmann/json.git + ignore = dirty [submodule "benchmarks/techmapping/tigfet/sclib"] path = benchmarks/techmapping/tigfet/sclib url = https://github.com/lnis-uofu/TIGFET-10nm-SCLIB.git diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore index 0418e9f73..a94025f50 100644 --- a/benchmarks/.gitignore +++ b/benchmarks/.gitignore @@ -3,11 +3,12 @@ *.migscript.* *.abc.* -*.direct_*.* -*.mixed_*.* *.unoptimized.* +*.exploded.* *.xmgscript.* *.lsoracle_old.* +*.*_plugin.* +*.*_direct.* *.timing_direct*.* *.timing_yosys*.* *.mapped.v diff --git a/benchmarks/EPFL/adder.sdc b/benchmarks/EPFL/adder.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/adder.sdc +++ b/benchmarks/EPFL/adder.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/arbiter.sdc b/benchmarks/EPFL/arbiter.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/arbiter.sdc +++ b/benchmarks/EPFL/arbiter.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/bar.sdc b/benchmarks/EPFL/bar.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/bar.sdc +++ b/benchmarks/EPFL/bar.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/i2c.sdc b/benchmarks/EPFL/i2c.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/i2c.sdc +++ b/benchmarks/EPFL/i2c.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/log2.sdc b/benchmarks/EPFL/log2.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/log2.sdc +++ b/benchmarks/EPFL/log2.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/max.sdc b/benchmarks/EPFL/max.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/max.sdc +++ b/benchmarks/EPFL/max.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/mem_ctrl.sdc b/benchmarks/EPFL/mem_ctrl.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/mem_ctrl.sdc +++ b/benchmarks/EPFL/mem_ctrl.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/EPFL/multiplier.sdc b/benchmarks/EPFL/multiplier.sdc index 56d00e8f7..5993152de 100644 --- a/benchmarks/EPFL/multiplier.sdc +++ b/benchmarks/EPFL/multiplier.sdc @@ -1,3 +1,3 @@ -create_clock -period 0 -name virtual_io_clock -set_input_delay -clock virtual_io_clock -max 0 [get_ports {*}] -set_output_delay -clock virtual_io_clock -max 0 [get_ports {*}] \ No newline at end of file +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/Makefile b/benchmarks/Makefile index fb7a4831b..1dd18abb8 100644 --- a/benchmarks/Makefile +++ b/benchmarks/Makefile @@ -26,6 +26,7 @@ CLK_PERIOD := 10 STA := sta LSORACLE := lsoracle +LSORACLE_PLUGIN := oracle ABC := yosys-abc YOSYS := yosys YOSYS_PLUGIN := oracle @@ -33,34 +34,39 @@ TEE := cat - > FM := fm_shell PART_SIZE := 2048 +EXPLODE := 10 ISCAS85 := iscas85/c432.v iscas85/c880a.v iscas85/c3540a.v iscas85/c5288.v iscas85/c2670a.v iscas85/c5315a.v iscas85/c3540.v iscas85/c1908a.v iscas85/c7552.v iscas85/c499.v iscas85/c2670.v iscas85/c1908.v iscas85/c5315.v iscas85/c1335.v ISCAS89 := iscas89/s1196.v iscas89/s1238.v iscas89/s15850.v iscas89/s298.v OPDB := opdb/chip_bridge.pickle.v opdb/fpu.pickle.v opdb/gng.pickle.v # opdb/sparc_core.pickle.v EPFL := EPFL/adder.v EPFL/arbiter.v EPFL/bar.v EPFL/i2c.v EPFL/log2.v EPFL/max.v EPFL/mem_ctrl.v EPFL/multiplier.v #EPFL/sin.v EPFL/sqrt.v EPFL/square.v EPFL/voter.v -ORIGINAL_FILES := picorv32/picorv32.v ${EPFL} ibex/ibex.v # ${OPDB} # ${ISCAS85} ${ISCAS89} -LIBERTY_FILES := techmapping/skywater/sky130_fd_sc_hd__tt_025C_1v80.lib #\ -# techmapping/tigfet/sclib_tigfet10_hpall_tt_0p70v_25c.lib \ -# techmapping/tigfet/sclib_tigfet10_hpnw1_tt_0p70v_25c.lib \ -# techmapping/tigfet/sclib_tigfet10_hpnw4_tt_0p70v_25c.lib \ -# techmapping/tigfet/sclib_tigfet10_hpnw8_tt_0p70v_25c.lib \ -# techmapping/tigfet/sclib_tigfet10_hpnw12_tt_0p70v_25c.lib \ -# techmapping/gf12/sc9mcpp84_12lp_base_rvt_c14_tt_nominal_max_0p70v_25c.lib +DESIGNS := ${EPFL} ${OPDB} # picorv32/picorv32.v + +LIBERTY_FILES := techmapping/skywater/sky130_fd_sc_hd__tt_025C_1v80.lib +# techmapping/tigfet/sclib_tigfet10_hpall_tt_0p70v_25c.lib \ +# techmapping/tigfet/sclib_tigfet10_hpnw1_tt_0p70v_25c.lib \ +# techmapping/tigfet/sclib_tigfet10_hpnw4_tt_0p70v_25c.lib \ +# techmapping/tigfet/sclib_tigfet10_hpnw8_tt_0p70v_25c.lib \ +# techmapping/tigfet/sclib_tigfet10_hpnw12_tt_0p70v_25c.lib +# techmapping/gf12/sc9mcpp84_12lp_base_rvt_c14_tt_nominal_max_0p70v_25c.lib + LIBERTY_LIBS := $(foreach LIB,${LIBERTY_FILES},$(shell basename ${LIB} .lib)) TECHMAPPING_SCRIPTS := $(patsubst %.lib,%.synth.tcl,${LIBERTY_FILES}) -RUNS := abc lsoracle_old migscript aigscript mixed_nodes mixed_depth mixed_ndp mixed_resynth timing_direct timing_direct_internal direct_ndp unoptimized +RUNS := unoptimized timing_direct timing_direct_old ndp_direct resynth_direct +# timing_internal_direct timing_internal_direct_old +#abc depth_direct nodes_direct abc_part_direct nodes_plugin depth_plugin ndp_plugin resynth_plugin migscript aigscript ################################################################ ######################## Targets ############################### ################################################################ -SYNTH_OUTPUTS := $(patsubst %.v,%.unoptimized.rtl,${ORIGINAL_FILES}) +SYNTH_OUTPUTS := $(patsubst %.v,%.unoptimized.rtl,${DESIGNS}) -PARTITION_OUTPUTS := $(patsubst %.v,%.direct.parts,${ORIGINAL_FILES}) +PARTITION_OUTPUTS := $(patsubst %.v,%.direct.parts,${DESIGNS}) -OPTIMIZE_OUTPUTS := $(foreach RUN,${RUNS},$(patsubst %.v,%.${RUN}.rtl,${ORIGINAL_FILES})) +OPTIMIZE_OUTPUTS := $(foreach RUN,${RUNS},$(patsubst %.v,%.${RUN}.rtl,${DESIGNS})) TECHMAP_OUTPUTS := $(foreach TECH,${LIBERTY_FILES},$(patsubst %.rtl,%.$(shell basename ${TECH} .lib).mapped.v,${OPTIMIZE_OUTPUTS})) @@ -125,15 +131,15 @@ skywater: sky130_fd_sc_hd__tt_025C_1v80.pdf # gf12: sc9mcpp84_12lp_base_rvt_c14_tt_nominal_max_0p70v_25c.pdf -# tigfet: sclib_tigfet10_hpall_tt_0p70v_25c.pdf +tigfet: sclib_tigfet10_hpall_tt_0p70v_25c.pdf -# tigfet1: sclib_tigfet10_hpnw1_tt_0p70v_25c.pdf +tigfet1: sclib_tigfet10_hpnw1_tt_0p70v_25c.pdf -# tigfet4: sclib_tigfet10_hpnw4_tt_0p70v_25c.pdf +tigfet4: sclib_tigfet10_hpnw4_tt_0p70v_25c.pdf -# tigfet8: sclib_tigfet10_hpnw8_tt_0p70v_25c.pdf +tigfet8: sclib_tigfet10_hpnw8_tt_0p70v_25c.pdf -# tigfet12: sclib_tigfet10_hpnw12_tt_0p70v_25c.pdf +tigfet12: sclib_tigfet10_hpnw12_tt_0p70v_25c.pdf ################################################################ ######################### SYNTHESIS ############################ @@ -164,42 +170,51 @@ skywater: sky130_fd_sc_hd__tt_025C_1v80.pdf ################################################################ # TODO add a single internal-to-yosys partition file -%.mixed_ndp.stats.json %.mixed_ndp.rtl %.mixed_ndp.optimize.log &: %.unoptimized.rtl - $(eval TEMP=$*.mixed_ndp.script) +%.ndp_plugin.stats.json %.ndp_plugin.rtl %.ndp_plugin.optimize.log &: %.unoptimized.rtl + $(eval TEMP=$*.ndp_plugin.script) @ echo "ps -a" > ${TEMP} @ echo "kahypar --size ${PART_SIZE} --epsilon 0.05" >> ${TEMP} @ echo "optimize --ndp --abc_exec ${ABC}" >> ${TEMP} @ echo "ps -g" >> ${TEMP} - @ echo "write_stats -g --name $(shell basename $*) --optimization mixed_ndp $*.mixed_ndp.stats.json" >> ${TEMP} - ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.mixed_ndp.rtl" | ${TEE} $*.mixed_ndp.optimize.log + @ echo "write_stats -g --name $(shell basename $*) --optimization ndp_plugin $*.ndp_plugin.stats.json" >> ${TEMP} + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.ndp_plugin.rtl" | ${TEE} $*.ndp_plugin.optimize.log -%.mixed_depth.stats.json %.mixed_depth.rtl %.mixed_depth.optimize.log &: %.unoptimized.rtl - $(eval TEMP=$*.mixed_depth.script) +%.depth_plugin.stats.json %.depth_plugin.rtl %.depth_plugin.optimize.log &: %.unoptimized.rtl + $(eval TEMP=$*.depth_plugin.script) @ echo "ps -a" > ${TEMP} @ echo "kahypar --size ${PART_SIZE} --epsilon 0.05" >> ${TEMP} @ echo "optimize --depth --abc_exec ${ABC}" >> ${TEMP} @ echo "ps -g" >> ${TEMP} - @ echo "write_blif -g $*.mixed_depth.internal.blif" - @ echo "write_stats --name $(shell basename $*) --optimization mixed_depth -g $*.mixed_depth.stats.json" >> ${TEMP} - ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -nonames -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.mixed_depth.rtl" | ${TEE} $*.mixed_depth.optimize.log + @ echo "write_blif -g $*.depth_plugin.internal.blif" + @ echo "write_stats --name $(shell basename $*) --optimization depth_plugin -g $*.depth_plugin.stats.json" >> ${TEMP} + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -nonames -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.depth_plugin.rtl" | ${TEE} $*.depth_plugin.optimize.log -%.mixed_nodes.stats.json %.mixed_nodes.rtl %.mixed_nodes.optimize.log &: %.unoptimized.rtl - $(eval TEMP=$*.mixed_nodes.script) +%.nodes_plugin.stats.json %.nodes_plugin.rtl %.nodes_plugin.optimize.log &: %.unoptimized.rtl + $(eval TEMP=$*.nodes_plugin.script) @ echo "ps -a" > ${TEMP} @ echo "kahypar --size ${PART_SIZE} --epsilon 0.05" >> ${TEMP} @ echo "optimize --nodes --abc_exec ${ABC}" >> ${TEMP} @ echo "ps -g" >> ${TEMP} - @ echo "write_stats --name $(shell basename $*) --optimization mixed_nodes -g $*.mixed_nodes.stats.json" >> ${TEMP} - ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.mixed_nodes.rtl" | ${TEE} $*.mixed_nodes.optimize.log + @ echo "write_stats --name $(shell basename $*) --optimization nodes_plugin -g $*.nodes_plugin.stats.json" >> ${TEMP} + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.nodes_plugin.rtl" | ${TEE} $*.nodes_plugin.optimize.log + +%.exploded.stats.json %.exploded.rtl %.exploded.optimize.log &: %.unoptimized.rtl + $(eval TEMP=$*.exploded.script) + @ echo "ps -a" > ${TEMP} + @ echo "exploderize --abc_exec ${ABC} --depth ${EXPLODE}" >> ${TEMP} + @ echo "ps -g" >> ${TEMP} + @ echo "write_stats --name $(shell basename $*) --optimization exploded -g $*.exploded.stats.json" >> ${TEMP} + @ echo "write_blif -g $*.exploded.blif" >> ${TEMP} + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; stat; techmap; opt -purge; stat; write_rtlil $*.exploded.rtl" | ${TEE} $*.exploded.optimize.log -%.mixed_resynth.stats.json %.mixed_resynth.rtl %.mixed_resynth.optimize.log &: %.unoptimized.rtl - $(eval TEMP=$*.mixed_resynth.script) +%.resynth_plugin.stats.json %.resynth_plugin.rtl %.resynth_plugin.optimize.log &: %.unoptimized.rtl + $(eval TEMP=$*.resynth_plugin.script) @ echo "ps -a" > ${TEMP} @ echo "kahypar --size ${PART_SIZE} --epsilon 0.05" >> ${TEMP} @ echo "optimize --resynth --abc_exec ${ABC}" >> ${TEMP} @ echo "ps -g" >> ${TEMP} - @ echo "write_stats --name $(shell basename $*) --optimization mixed_resynth -g $*.mixed_resynth.stats.json" >> ${TEMP} - ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.mixed_resynth.rtl" | ${TEE} $*.mixed_resynth.optimize.log + @ echo "write_stats --name $(shell basename $*) --optimization resynth_plugin -g $*.resynth_plugin.stats.json" >> ${TEMP} + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_rtlil $<; lsoracle -xmg_out -lso_exe ${LSORACLE} -script ${TEMP}; techmap; opt -purge; stat; write_rtlil $*.resynth_plugin.rtl" | ${TEE} $*.resynth_plugin.optimize.log %.lsoracle_old.stats.json %.lsoracle_old.rtl %.lsoracle_old.optimize.log &: %.unoptimized.rtl $(eval TEMP=$*.lsoracle_old.script) @@ -241,19 +256,74 @@ skywater: sky130_fd_sc_hd__tt_025C_1v80.pdf %.migscript.stats.json: %.migscript.blif ${LSORACLE} -e -c "read_blif -m $<; write_stats --name $(shell basename $*) --optimization migscript -m $@" -%.mixed_ndp_direct.stats.json %.direct_ndp.blif %.direct_ndp.optimize.log &: %.unoptimized.blif %.direct.parts - $(eval TEMP=$*.direct_ndp.script) +%.abc_part_direct.stats.json %.abc_part_direct.blif %.abc_part_direct.optimize.log &: %.unoptimized.blif %.direct.parts + $(eval TEMP=$*.abc_part_direct.script) + @ echo "read_blif -a $<" > ${TEMP} + @ echo "ps -a" >> ${TEMP} + @ echo "external_partition $*.direct.parts" >> ${TEMP} + @ echo "abc_part --abc_exec ${ABC}" >> ${TEMP} + @ echo "write_blif -a --filename $*.abc_part_direct.blif" >> ${TEMP} + @ echo "write_stats -a --name $(shell basename $*) --optimization abc_part_direct $*.abc_part_direct.stats.json" >> ${TEMP} + ${LSORACLE} -e -f ${TEMP} | ${TEE} $*.abc_part_direct.optimize.log + +%.abc_part_direct.rtl &: %.abc_part_direct.blif + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.abc_part_direct.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.abc_part_direct.rtl" | ${TEE} $*.abc_part_direct.optimize_rtl.log + +%.ndp_direct.stats.json %.ndp_direct.blif %.ndp_direct.optimize.log &: %.unoptimized.blif %.direct.parts + $(eval TEMP=$*.ndp_direct.script) @ echo "read_blif -a $<" > ${TEMP} @ echo "ps -a" >> ${TEMP} @ echo "external_partition $*.direct.parts" >> ${TEMP} @ echo "optimize --ndp --abc_exec ${ABC}" >> ${TEMP} @ echo "ps -g" >> ${TEMP} - @ echo "write_blif -g --filename $*.direct_ndp.blif" >> ${TEMP} - @ echo "write_stats -g --name $(shell basename $*) --optimization direct_ndp $*.direct_ndp.stats.json" >> ${TEMP} - ${LSORACLE} -e -f ${TEMP} | ${TEE} $*.direct_ndp.optimize.log + @ echo "write_blif -g --filename $*.ndp_direct.blif" >> ${TEMP} + @ echo "write_stats -g --name $(shell basename $*) --optimization ndp_direct $*.ndp_direct.stats.json" >> ${TEMP} + ${LSORACLE} -e -f ${TEMP} | ${TEE} $*.ndp_direct.optimize.log + +%.ndp_direct.rtl &: %.ndp_direct.blif + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.ndp_direct.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.ndp_direct.rtl" | ${TEE} $*.ndp_direct.optimize_rtl.log + +%.depth_direct.stats.json %.depth_direct.blif %.depth_direct.optimize.log &: %.unoptimized.blif %.direct.parts + $(eval TEMP=$*.depth_direct.script) + @ echo "read_blif -a $<" > ${TEMP} + @ echo "ps -a" >> ${TEMP} + @ echo "external_partition $*.direct.parts" >> ${TEMP} + @ echo "optimize --depth --abc_exec ${ABC}" >> ${TEMP} + @ echo "ps -g" >> ${TEMP} + @ echo "write_blif -g --filename $*.depth_direct.blif" >> ${TEMP} + @ echo "write_stats -g --name $(shell basename $*) --optimization depth_direct $*.depth_direct.stats.json" >> ${TEMP} + ${LSORACLE} -e -f ${TEMP} | ${TEE} $*.depth_direct.optimize.log + +%.depth_direct.rtl &: %.depth_direct.blif + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.depth_direct.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.depth_direct.rtl" | ${TEE} $*.depth_direct.optimize_rtl.log + +%.nodes_direct.stats.json %.nodes_direct.blif %.nodes_direct.optimize.log &: %.unoptimized.blif %.direct.parts + $(eval TEMP=$*.nodes_direct.script) + @ echo "read_blif -a $<" > ${TEMP} + @ echo "ps -a" >> ${TEMP} + @ echo "external_partition $*.direct.parts" >> ${TEMP} + @ echo "optimize --nodes --abc_exec ${ABC}" >> ${TEMP} + @ echo "ps -g" >> ${TEMP} + @ echo "write_blif -g --filename $*.nodes_direct.blif" >> ${TEMP} + @ echo "write_stats -g --name $(shell basename $*) --optimization nodes_direct $*.nodes_direct.stats.json" >> ${TEMP} + ${LSORACLE} -e -f ${TEMP} | ${TEE} $*.nodes_direct.optimize.log + +%.nodes_direct.rtl &: %.nodes_direct.blif + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.nodes_direct.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.nodes_direct.rtl" | ${TEE} $*.nodes_direct.optimize_rtl.log + +%.resynth_direct.stats.json %.resynth_direct.blif %.resynth_direct.optimize.log &: %.unoptimized.blif %.direct.parts + $(eval TEMP=$*.resynth_direct.script) + @ echo "read_blif -a $<" > ${TEMP} + @ echo "ps -a" >> ${TEMP} + @ echo "external_partition $*.direct.parts" >> ${TEMP} + @ echo "optimize --resynth --abc_exec ${ABC}" >> ${TEMP} + @ echo "ps -g" >> ${TEMP} + @ echo "write_blif -g --filename $*.resynth_direct.blif" >> ${TEMP} + @ echo "write_stats -g --name $(shell basename $*) --optimization resynth_direct $*.resynth_direct.stats.json" >> ${TEMP} + ${LSORACLE} -e -f ${TEMP} | ${TEE} $*.resynth_direct.optimize.log -%.direct_ndp.rtl &: %.direct_ndp.blif - ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.direct_ndp.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.direct_ndp.rtl" | ${TEE} $*.direct_ndp.optimize_rtl.log +%.resynth_direct.rtl &: %.resynth_direct.blif + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.resynth_direct.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.resynth_direct.rtl" | ${TEE} $*.resynth_direct.optimize_rtl.log define TIMING_SYNTH = # Yosys name mangling is causing conflicts, not currently working. @@ -267,25 +337,46 @@ define TIMING_SYNTH = # @ echo "write_stats --name $$(shell basename $$*) --optimization timing -g $$*.timing_yosys.stats.json" >> $${TEMP} # $${YOSYS} -m $${YOSYS_PLUGIN} -Q -p "read_rtlil $$<; lsoracle -xmg_out -lso_exe $${LSORACLE} -script $${TEMP}; techmap; opt -purge; stat; write_rtlil $$*.timing_yosys.rtl" | $${TEE} $$*.timing_yosys.optimize.log -%.timing_direct_internal.${2}.v %.timing_direct.optimize.log %.timing_direct.stats.json %.timing_direct_internal.stats.json %.timing_direct.blif &: %.unoptimized.blif %.timing_direct.${2}.sdc %.direct.parts +%.timing_internal_direct.${2}.mapped.v %.timing_direct.optimize.log %.timing_direct.stats.json %.timing_internal_direct.stats.json %.timing_direct.blif &: %.unoptimized.blif %.timing_direct.${2}.sdc %.direct.parts # $$(eval TEMP=$$(shell mktemp)) $$(eval TEMP=$$*.timing_direct.script) @ echo "read_blif -a $$<" > $${TEMP} @ echo "ps -a" >> $${TEMP} @ echo "external_partition $$*.direct.parts" >> $${TEMP} - @ echo "optimize_timing --clock clk --sdc $$*.timing_direct.${2}.sdc --output $$*.timing_direct_internal.${2}.v --abc_exec $${ABC} --liberty ${1} --mapping ${3}" >> $${TEMP} + @ echo "optimize_timing --clock clk --sdc $$*.timing_direct.${2}.sdc --output $$*.timing_internal_direct.${2}.mapped.v --abc_exec $${ABC} --liberty ${1} --mapping ${3} --temp-prefix $$*.timing_direct" >> $${TEMP} @ echo "ps -g" >> $${TEMP} @ echo "write_blif -g --filename $$*.timing_direct.blif" >> $${TEMP} @ echo "write_stats --name $$(shell basename $$*) --optimization timing_direct -g $$*.timing_direct.stats.json" >> $${TEMP} - @ echo "write_stats --name $$(shell basename $$*) --optimization timing_direct_internal -g $$*.timing_direct_internal.stats.json" >> $${TEMP} + @ echo "write_stats --name $$(shell basename $$*) --optimization timing_internal_direct -g $$*.timing_internal_direct.stats.json" >> $${TEMP} $${LSORACLE} -e -f $${TEMP} | $${TEE} $$*.timing_direct.optimize.log + + +%.timing_internal_direct_old.${2}.mapped.v %.timing_direct_old.optimize.log %.timing_direct_old.stats.json %.timing_internal_direct_old.stats.json %.timing_direct_old.blif &: %.unoptimized.blif %.timing_direct_old.${2}.sdc %.direct.parts +# $$(eval TEMP=$$(shell mktemp)) + $$(eval TEMP=$$*.timing_direct_old.script) + @ echo "read_blif -a $$<" > $${TEMP} + @ echo "ps -a" >> $${TEMP} + @ echo "external_partition $$*.direct.parts" >> $${TEMP} + @ echo "optimize_timing2 --clock clk --sdc $$*.timing_direct_old.${2}.sdc --output $$*.timing_internal_direct_old.${2}.mapped.v --abc_exec $${ABC} --liberty ${1} --mapping ${3} --temp-prefix $$*.timing_direct" >> $${TEMP} + @ echo "ps -g" >> $${TEMP} + @ echo "write_blif -g --filename $$*.timing_direct_old.blif" >> $${TEMP} + @ echo "write_stats --name $$(shell basename $$*) --optimization timing_direct_old -g $$*.timing_direct_old.stats.json" >> $${TEMP} + @ echo "write_stats --name $$(shell basename $$*) --optimization timing_internal_direct_old -g $$*.timing_internal_direct_old.stats.json" >> $${TEMP} + $${LSORACLE} -e -f $${TEMP} | $${TEE} $$*.timing_direct_old.optimize.log + endef $(foreach LIB,${LIBERTY_FILES},$(eval $(call TIMING_SYNTH,${LIB},$(shell basename ${LIB} .lib),$(patsubst %.lib,%.mapping.v,${LIB})))) %.timing_direct.rtl &: %.timing_direct.blif - ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.timing_direct.blif; stat; techmap; stat; opt -purge; stat; write_rtlil $*.timing_direct.rtl" | ${TEE} $*.timing_direct.optimize_rtl.log + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.timing_direct.blif; stat; simplemap; stat; techmap; stat; opt -purge; stat; write_rtlil $*.timing_direct.rtl" | ${TEE} $*.timing_direct.optimize_rtl.log + +%.timing_direct_old.rtl &: %.timing_direct_old.blif + ${YOSYS} -m ${YOSYS_PLUGIN} -Q -p "read_blif $*.timing_direct_old.blif; stat; simplemap; stat; techmap; stat; opt -purge; stat; write_rtlil $*.timing_direct_old.rtl" | ${TEE} $*.timing_direct_old.optimize_rtl.log -%.timing_direct_internal.rtl: %.timing_direct.rtl +%.timing_internal_direct.rtl: %.timing_direct.rtl + cp $< $@ + +%.timing_internal_direct_old.rtl: %.timing_direct_old.rtl cp $< $@ %.abc.rtl %.abc.blif %.abc.optimize.log &: %.unoptimized.rtl @@ -296,8 +387,6 @@ $(foreach LIB,${LIBERTY_FILES},$(eval $(call TIMING_SYNTH,${LIB},$(shell basenam ################################################################ define TECHMAPPING = -$(2).test: - echo foo %.$(2).mapped.v %.$(2).tech.log &: %.rtl CIRCUIT_INPUT=$$< OUTPUT_FILE=$$*.$(2).mapped.v $${YOSYS} -Q -c $(1) | ${TEE} $$*.$(2).tech.log endef @@ -363,6 +452,12 @@ define TIMING_JSON = @ echo generating report $$@ @ echo '{ "liberty_file": "$(2)" }' > $$@ +%.timing_internal_direct.$(2).gates: %.timing_internal_direct.$(2).mapped.flatten.v + ${YOSYS} -Q -p "read_verilog $$<; stat -liberty $(1)" > $$@ + +%.timing_internal_direct_old.$(2).gates: %.timing_internal_direct_old.$(2).mapped.flatten.v + ${YOSYS} -Q -p "read_verilog $$<; stat -liberty $(1)" > $$@ + %.$(2).gates: %.$(2).mapped.v ${YOSYS} -Q -p "read_verilog $$<; stat -liberty $(1)" > $$@ endef @@ -406,6 +501,6 @@ everything.tsv: ${JSON_REPORTS} define GRAPHS = ${LIB}.pdf: ${JSON_REPORTS} - python3 plot_bars.py $$@.pdf **/*.${LIB}.report.json + python3 plot_bars.py $$@ **/*.${LIB}.report.json endef $(foreach LIB,$(LIBERTY_LIBS),$(eval ${GRAPHS})) diff --git a/benchmarks/ibex/ibex.sdc b/benchmarks/ibex/ibex.sdc index 17af5eaff..2d2ee1ce7 100644 --- a/benchmarks/ibex/ibex.sdc +++ b/benchmarks/ibex/ibex.sdc @@ -1,3 +1,3 @@ -create_clock -name clk -period 10 {clk} +create_clock -name clk -period 1 {clk} set_input_delay -clock clk -max 0 [all_inputs] set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c1335.sdc b/benchmarks/iscas85/c1335.sdc index 46ef36115..5993152de 100644 --- a/benchmarks/iscas85/c1335.sdc +++ b/benchmarks/iscas85/c1335.sdc @@ -1,78 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -G9 -G8 -G7 -G6 -G5 -G41 -G40 -G4 -G39 -G38 -G37 -G36 -G35 -G34 -G33 -G32 -G31 -G30 -G3 -G29 -G28 -G27 -G26 -G25 -G24 -G23 -G22 -G21 -G20 -G2 -G19 -G18 -G17 -G16 -G15 -G14 -G13 -G12 -G11 -G10 -G1 -} -set_output_delay -clock clk 0 { -G1355 -G1354 -G1353 -G1352 -G1351 -G1350 -G1349 -G1348 -G1347 -G1346 -G1345 -G1344 -G1343 -G1342 -G1341 -G1340 -G1339 -G1338 -G1337 -G1336 -G1335 -G1334 -G1333 -G1332 -G1331 -G1330 -G1329 -G1328 -G1327 -G1326 -G1325 -G1324 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c1908.sdc b/benchmarks/iscas85/c1908.sdc index 4c48f27df..5993152de 100644 --- a/benchmarks/iscas85/c1908.sdc +++ b/benchmarks/iscas85/c1908.sdc @@ -1,63 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N99 -N94 -N91 -N88 -N85 -N82 -N79 -N76 -N72 -N7 -N69 -N66 -N63 -N60 -N56 -N53 -N49 -N46 -N43 -N40 -N4 -N37 -N34 -N31 -N28 -N25 -N22 -N19 -N16 -N13 -N104 -N10 -N1 -} -set_output_delay -clock clk 0 { -N2899 -N2892 -N2891 -N2890 -N2889 -N2888 -N2887 -N2886 -N2811 -N2787 -N2786 -N2785 -N2784 -N2783 -N2782 -N2781 -N2780 -N2779 -N2768 -N2767 -N2762 -N2756 -N2755 -N2754 -N2753 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c1908a.sdc b/benchmarks/iscas85/c1908a.sdc index 9f4e9cfa2..5993152de 100644 --- a/benchmarks/iscas85/c1908a.sdc +++ b/benchmarks/iscas85/c1908a.sdc @@ -1,63 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -G9 -G8 -G7 -G6 -G5 -G4 -G33 -G32 -G31 -G30 -G3 -G29 -G28 -G27 -G26 -G25 -G24 -G23 -G22 -G21 -G20 -G2 -G19 -G18 -G17 -G16 -G15 -G14 -G13 -G12 -G11 -G10 -G1 -} -set_output_delay -clock clk 0 { -G1908 -G1907 -G1906 -G1905 -G1904 -G1903 -G1902 -G1901 -G1900 -G1899 -G1898 -G1897 -G1896 -G1895 -G1894 -G1893 -G1892 -G1891 -G1890 -G1889 -G1888 -G1887 -G1886 -G1885 -G1884 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c2670.sdc b/benchmarks/iscas85/c2670.sdc index 1dfbf1ace..5993152de 100644 --- a/benchmarks/iscas85/c2670.sdc +++ b/benchmarks/iscas85/c2670.sdc @@ -1,378 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N99 -N96 -N95 -N94 -N93 -N92 -N91 -N90 -N89 -N88 -N87 -N86 -N85 -N82 -N81 -N80 -N8 -N79 -N78 -N77 -N76 -N75 -N74 -N73 -N72 -N7 -N69 -N68 -N67 -N66 -N65 -N64 -N63 -N62 -N61 -N60 -N6 -N57 -N56 -N55 -N54 -N53 -N52 -N51 -N50 -N5 -N49 -N48 -N47 -N44 -N43 -N40 -N4 -N37 -N36 -N355 -N352 -N35 -N349 -N346 -N343 -N340 -N34 -N337 -N334 -N331 -N33 -N328 -N325 -N322 -N32 -N319 -N316 -N313 -N309 -N305 -N301 -N3 -N297 -N294 -N290 -N29 -N287 -N284 -N281 -N28 -N278 -N275 -N272 -N27 -N269 -N266 -N263 -N262 -N26 -N259 -N256 -N253 -N25 -N246 -N241 -N24 -N237 -N234 -N231 -N230 -N23 -N227 -N224 -N22 -N219 -N218_I -N217_I -N216_I -N215_I -N214_I -N213_I -N212_I -N211_I -N210_I -N21 -N209_I -N208_I -N207_I -N206_I -N205_I -N204_I -N203_I -N202_I -N201_I -N200_I -N20 -N2 -N199_I -N198_I -N197_I -N196_I -N195_I -N194_I -N193_I -N192_I -N191_I -N190_I -N19 -N189_I -N188_I -N187_I -N186_I -N185_I -N184_I -N183_I -N182_I -N181_I -N180_I -N179_I -N178_I -N177_I -N176_I -N175_I -N174_I -N173_I -N172_I -N171_I -N170_I -N169_I -N168_I -N167_I -N166_I -N165_I -N164_I -N163_I -N162_I -N161_I -N160_I -N16 -N159_I -N158_I -N157_I -N156_I -N155_I -N154_I -N153_I -N152_I -N151_I -N150_I -N15 -N149_I -N148_I -N147_I -N146_I -N145_I -N144_I -N143_I -N142 -N141 -N140 -N14 -N139 -N138 -N137 -N136 -N135 -N132 -N131 -N130 -N129 -N128 -N127 -N126 -N125 -N124 -N123 -N120 -N119 -N118 -N117 -N116 -N115 -N114 -N113 -N112 -N111 -N11 -N108 -N107 -N106 -N105 -N104 -N103 -N102 -N101 -N100 -N1 -} -set_output_delay -clock clk 0 { -N805 -N799 -N792 -N494 -N493 -N492 -N491 -N490 -N489 -N488 -N487 -N458 -N457 -N456 -N420 -N419 -N401 -N400 -N398 -N3882 -N3881 -N3875 -N3851 -N3809 -N3804 -N3803 -N3671 -N3546 -N3079 -N3038 -N2971 -N2970 -N2925 -N2891 -N2644 -N2643 -N2496 -N2390 -N2389 -N2388 -N2387 -N218_O -N217_O -N216_O -N215_O -N214_O -N213_O -N212_O -N211_O -N210_O -N209_O -N208_O -N207_O -N206_O -N205_O -N204_O -N203_O -N202_O -N2022 -N2020 -N201_O -N2018 -N2016 -N2014 -N2012 -N2010 -N200_O -N199_O -N198_O -N197_O -N1971 -N1970 -N196_O -N1969 -N195_O -N194_O -N193_O -N192_O -N191_O -N190_O -N189_O -N188_O -N187_O -N186_O -N185_O -N184_O -N183_O -N182_O -N1821 -N1820 -N181_O -N1819 -N1818 -N1817 -N1816 -N180_O -N179_O -N178_O -N177_O -N176_O -N175_O -N174_O -N173_O -N172_O -N1726 -N171_O -N170_O -N169_O -N168_O -N167_O -N166_O -N165_O -N164_O -N163_O -N162_O -N161_O -N160_O -N159_O -N158_O -N157_O -N156_O -N155_O -N154_O -N153_O -N152_O -N151_O -N150_O -N149_O -N148_O -N147_O -N146_O -N145_O -N144_O -N1448 -N143_O -N1277 -N1269 -N1029 -N1028 -N1026 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c2670a.sdc b/benchmarks/iscas85/c2670a.sdc index 1fc06e3b4..5993152de 100644 --- a/benchmarks/iscas85/c2670a.sdc +++ b/benchmarks/iscas85/c2670a.sdc @@ -1,226 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -G99 -G98 -G97 -G96 -G95 -G94 -G93 -G92 -G91 -G90 -G9 -G89 -G88 -G87 -G86 -G85 -G84 -G83 -G82 -G81 -G80 -G8 -G79 -G78 -G77 -G76 -G75 -G74 -G73 -G72 -G71 -G70 -G7 -G69 -G68 -G67 -G66 -G65 -G64 -G63 -G62 -G61 -G60 -G6 -G59 -G58 -G57 -G56 -G55 -G54 -G53 -G52 -G51 -G50 -G5 -G49 -G48 -G47 -G46 -G45 -G44 -G43 -G42 -G41 -G40 -G4 -G39 -G38 -G37 -G36 -G35 -G34 -G33 -G32 -G31 -G30 -G3 -G29 -G28 -G27 -G26 -G25 -G24 -G23 -G22 -G21 -G20 -G2 -G19 -G18 -G17 -G16 -G157 -G156 -G155 -G154 -G153 -G152 -G151 -G150 -G15 -G149 -G148 -G147 -G146 -G145 -G144 -G143 -G142 -G141 -G140 -G14 -G139 -G138 -G137 -G136 -G135 -G134 -G133 -G132 -G131 -G130 -G13 -G129 -G128 -G127 -G126 -G125 -G124 -G123 -G122 -G121 -G120 -G12 -G119 -G118 -G117 -G116 -G115 -G114 -G113 -G112 -G111 -G110 -G11 -G109 -G108 -G107 -G106 -G105 -G104 -G103 -G102 -G101 -G100 -G10 -G1 -} -set_output_delay -clock clk 0 { -G2594 -G2593 -G2592 -G2591 -G2590 -G2589 -G2588 -G2587 -G2586 -G2585 -G2584 -G2583 -G2582 -G2581 -G2580 -G2579 -G2578 -G2577 -G2576 -G2575 -G2574 -G2573 -G2572 -G2571 -G2570 -G2569 -G2568 -G2567 -G2566 -G2565 -G2564 -G2563 -G2562 -G2561 -G2560 -G2559 -G2558 -G2557 -G2556 -G2555 -G2554 -G2553 -G2552 -G2551 -G2550 -G2549 -G2548 -G2547 -G2546 -G2545 -G2544 -G2543 -G2542 -G2541 -G2540 -G2539 -G2538 -G2537 -G2536 -G2535 -G2534 -G2533 -G2532 -G2531 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c3540.sdc b/benchmarks/iscas85/c3540.sdc index 80f99aab4..5993152de 100644 --- a/benchmarks/iscas85/c3540.sdc +++ b/benchmarks/iscas85/c3540.sdc @@ -1,77 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N97 -N87 -N77 -N68 -N58 -N50 -N45 -N41 -N350 -N349 -N343 -N330 -N33 -N329 -N326 -N322 -N317 -N311 -N303 -N294 -N283 -N274 -N270 -N264 -N257 -N250 -N244 -N238 -N232 -N226 -N223 -N222 -N213 -N200 -N20 -N190 -N179 -N169 -N159 -N150 -N143 -N137 -N132 -N13 -N128 -N125 -N124 -N116 -N107 -N1 -} -set_output_delay -clock clk 0 { -N5361 -N5360 -N5231 -N5192 -N5121 -N5120 -N5102 -N5078 -N5047 -N5045 -N5002 -N4944 -N4815 -N4667 -N4589 -N4145 -N4028 -N3987 -N3833 -N3195 -N1947 -N1713 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c3540a.sdc b/benchmarks/iscas85/c3540a.sdc index 5771eb8a2..5993152de 100644 --- a/benchmarks/iscas85/c3540a.sdc +++ b/benchmarks/iscas85/c3540a.sdc @@ -1,77 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -G9 -G8 -G7 -G6 -G50 -G5 -G49 -G48 -G47 -G46 -G45 -G44 -G43 -G42 -G41 -G40 -G4 -G39 -G38 -G37 -G36 -G35 -G34 -G33 -G32 -G31 -G30 -G3 -G29 -G28 -G27 -G26 -G25 -G24 -G23 -G22 -G21 -G20 -G2 -G19 -G18 -G17 -G16 -G15 -G14 -G13 -G12 -G11 -G10 -G1 -} -set_output_delay -clock clk 0 { -G3540 -G3539 -G3538 -G3537 -G3536 -G3535 -G3534 -G3533 -G3532 -G3531 -G3530 -G3529 -G3528 -G3527 -G3526 -G3525 -G3524 -G3523 -G3522 -G3521 -G3520 -G3519 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c432.sdc b/benchmarks/iscas85/c432.sdc index be14da499..5993152de 100644 --- a/benchmarks/iscas85/c432.sdc +++ b/benchmarks/iscas85/c432.sdc @@ -1,48 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N99 -N95 -N92 -N89 -N86 -N82 -N8 -N79 -N76 -N73 -N69 -N66 -N63 -N60 -N56 -N53 -N50 -N47 -N43 -N40 -N4 -N37 -N34 -N30 -N27 -N24 -N21 -N17 -N14 -N115 -N112 -N11 -N108 -N105 -N102 -N1 -} -set_output_delay -clock clk 0 { -N432 -N431 -N430 -N421 -N370 -N329 -N223 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c499.sdc b/benchmarks/iscas85/c499.sdc index 041e9e6ce..5993152de 100644 --- a/benchmarks/iscas85/c499.sdc +++ b/benchmarks/iscas85/c499.sdc @@ -1,78 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N97 -N93 -N9 -N89 -N85 -N81 -N77 -N73 -N69 -N65 -N61 -N57 -N53 -N5 -N49 -N45 -N41 -N37 -N33 -N29 -N25 -N21 -N17 -N137 -N136 -N135 -N134 -N133 -N132 -N131 -N130 -N13 -N129 -N125 -N121 -N117 -N113 -N109 -N105 -N101 -N1 -} -set_output_delay -clock clk 0 { -N755 -N754 -N753 -N752 -N751 -N750 -N749 -N748 -N747 -N746 -N745 -N744 -N743 -N742 -N741 -N740 -N739 -N738 -N737 -N736 -N735 -N734 -N733 -N732 -N731 -N730 -N729 -N728 -N727 -N726 -N725 -N724 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c5288.sdc b/benchmarks/iscas85/c5288.sdc index 74c414473..5993152de 100644 --- a/benchmarks/iscas85/c5288.sdc +++ b/benchmarks/iscas85/c5288.sdc @@ -1,69 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N86 -N69 -N528 -N52 -N511 -N494 -N477 -N460 -N443 -N426 -N409 -N392 -N375 -N358 -N35 -N341 -N324 -N307 -N290 -N273 -N256 -N239 -N222 -N205 -N188 -N18 -N171 -N154 -N137 -N120 -N103 -N1 -} -set_output_delay -clock clk 0 { -N6288 -N6287 -N6280 -N6270 -N6260 -N6250 -N6240 -N6230 -N6220 -N6210 -N6200 -N6190 -N6180 -N6170 -N6160 -N6150 -N6123 -N5971 -N5672 -N545 -N5308 -N4946 -N4591 -N4241 -N3895 -N3552 -N3211 -N2877 -N2548 -N2223 -N1901 -N1581 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c5315.sdc b/benchmarks/iscas85/c5315.sdc index bd1b8765f..5993152de 100644 --- a/benchmarks/iscas85/c5315.sdc +++ b/benchmarks/iscas85/c5315.sdc @@ -1,306 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N97 -N94 -N91 -N88 -N87 -N86 -N83 -N82 -N81 -N80 -N79 -N76 -N73 -N70 -N67 -N64 -N631 -N625 -N619 -N616 -N613 -N610 -N61 -N607 -N603 -N599 -N598 -N597 -N596 -N595 -N592 -N591 -N588 -N583 -N580 -N577 -N574 -N571 -N566 -N562 -N559 -N556 -N552 -N549 -N545 -N54 -N534 -N53 -N523 -N52 -N514 -N503 -N490 -N49 -N479 -N468 -N46 -N457 -N446 -N435 -N43 -N422 -N411 -N400 -N40 -N4 -N389 -N386 -N374 -N373 -N372 -N37 -N369 -N366 -N361 -N358 -N351 -N348 -N341 -N34 -N338 -N335 -N332 -N331 -N324 -N323 -N316 -N315 -N31 -N308 -N307 -N302 -N299 -N293 -N292 -N289 -N288 -N281 -N280 -N273 -N272 -N27 -N265 -N264 -N26 -N257 -N254 -N251 -N25 -N248 -N245 -N242 -N241 -N24 -N234 -N233 -N23 -N226 -N225 -N218 -N217 -N210 -N209 -N206 -N203 -N200 -N20 -N197 -N194 -N191 -N188 -N185 -N182 -N179 -N176 -N173 -N170 -N17 -N167 -N164 -N161 -N158 -N155 -N152 -N149 -N146 -N145 -N141 -N140 -N14 -N137 -N136 -N135 -N132 -N131 -N130 -N129 -N128 -N127 -N126 -N123 -N122 -N121 -N120 -N119 -N118 -N117 -N116 -N115 -N114 -N113 -N112 -N11 -N109 -N106 -N103 -N100 -N1 -} -set_output_delay -clock clk 0 { -N816 -N8128 -N8127 -N8124 -N8123 -N8076 -N8075 -N7761 -N7760 -N7759 -N7758 -N7757 -N7756 -N7755 -N7754 -N7742 -N7741 -N7740 -N7739 -N7738 -N7737 -N7736 -N7735 -N7707 -N7706 -N7705 -N7704 -N7703 -N7702 -N7701 -N7700 -N7699 -N7698 -N7626 -N7607 -N7606 -N7605 -N7604 -N7603 -N7602 -N7601 -N7600 -N7522 -N7521 -N7520 -N7519 -N7518 -N7517 -N7516 -N7515 -N7511 -N7506 -N7504 -N7503 -N7476 -N7474 -N7473 -N7472 -N7471 -N7470 -N7469 -N7467 -N7466 -N7465 -N7449 -N7432 -N7365 -N7363 -N709 -N7015 -N6927 -N6926 -N6925 -N6924 -N6877 -N6716 -N6648 -N6646 -N6643 -N6641 -N5388 -N5240 -N4740 -N4739 -N4738 -N4737 -N4279 -N4278 -N4275 -N4272 -N3613 -N3604 -N3360 -N3359 -N3358 -N3357 -N2623 -N2590 -N2584 -N2527 -N2387 -N2309 -N2142 -N2139 -N2061 -N2060 -N2054 -N1972 -N1155 -N1154 -N1153 -N1152 -N1147 -N1145 -N1144 -N1143 -N1142 -N1141 -N1140 -N1139 -N1138 -N1137 -N1066 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c5315a.sdc b/benchmarks/iscas85/c5315a.sdc index ddc9132d5..5993152de 100644 --- a/benchmarks/iscas85/c5315a.sdc +++ b/benchmarks/iscas85/c5315a.sdc @@ -1,306 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -G99 -G98 -G97 -G96 -G95 -G94 -G93 -G92 -G91 -G90 -G9 -G89 -G88 -G87 -G86 -G85 -G84 -G83 -G82 -G81 -G80 -G8 -G79 -G78 -G77 -G76 -G75 -G74 -G73 -G72 -G71 -G70 -G7 -G69 -G68 -G67 -G66 -G65 -G64 -G63 -G62 -G61 -G60 -G6 -G59 -G58 -G57 -G56 -G55 -G54 -G53 -G52 -G51 -G50 -G5 -G49 -G48 -G47 -G46 -G45 -G44 -G43 -G42 -G41 -G40 -G4 -G39 -G38 -G37 -G36 -G35 -G34 -G33 -G32 -G31 -G30 -G3 -G29 -G28 -G27 -G26 -G25 -G24 -G23 -G22 -G21 -G20 -G2 -G19 -G18 -G178 -G177 -G176 -G175 -G174 -G173 -G172 -G171 -G170 -G17 -G169 -G168 -G167 -G166 -G165 -G164 -G163 -G162 -G161 -G160 -G16 -G159 -G158 -G157 -G156 -G155 -G154 -G153 -G152 -G151 -G150 -G15 -G149 -G148 -G147 -G146 -G145 -G144 -G143 -G142 -G141 -G140 -G14 -G139 -G138 -G137 -G136 -G135 -G134 -G133 -G132 -G131 -G130 -G13 -G129 -G128 -G127 -G126 -G125 -G124 -G123 -G122 -G121 -G120 -G12 -G119 -G118 -G117 -G116 -G115 -G114 -G113 -G112 -G111 -G110 -G11 -G109 -G108 -G107 -G106 -G105 -G104 -G103 -G102 -G101 -G100 -G10 -G1 -} -set_output_delay -clock clk 0 { -G5315 -G5314 -G5313 -G5312 -G5311 -G5310 -G5309 -G5308 -G5307 -G5306 -G5305 -G5304 -G5303 -G5302 -G5301 -G5300 -G5299 -G5298 -G5297 -G5296 -G5295 -G5294 -G5293 -G5292 -G5291 -G5290 -G5289 -G5288 -G5287 -G5286 -G5285 -G5284 -G5283 -G5282 -G5281 -G5280 -G5279 -G5278 -G5277 -G5276 -G5275 -G5274 -G5273 -G5272 -G5271 -G5270 -G5269 -G5268 -G5267 -G5266 -G5265 -G5264 -G5263 -G5262 -G5261 -G5260 -G5259 -G5258 -G5257 -G5256 -G5255 -G5254 -G5253 -G5252 -G5251 -G5250 -G5249 -G5248 -G5247 -G5246 -G5245 -G5244 -G5243 -G5242 -G5241 -G5240 -G5239 -G5238 -G5237 -G5236 -G5235 -G5234 -G5233 -G5232 -G5231 -G5230 -G5229 -G5228 -G5227 -G5226 -G5225 -G5224 -G5223 -G5222 -G5221 -G5220 -G5219 -G5218 -G5217 -G5216 -G5215 -G5214 -G5213 -G5212 -G5211 -G5210 -G5209 -G5208 -G5207 -G5206 -G5205 -G5204 -G5203 -G5202 -G5201 -G5200 -G5199 -G5198 -G5197 -G5196 -G5195 -G5194 -G5193 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c7552.sdc b/benchmarks/iscas85/c7552.sdc index f397020f1..5993152de 100644 --- a/benchmarks/iscas85/c7552.sdc +++ b/benchmarks/iscas85/c7552.sdc @@ -1,320 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N97 -N94 -N9 -N89 -N88 -N87 -N86 -N85 -N84 -N83 -N82 -N81 -N80 -N79 -N78 -N77 -N76 -N75 -N74 -N73 -N70 -N69 -N66 -N65 -N64 -N63 -N62 -N61 -N60 -N59 -N58 -N57 -N56 -N55 -N54 -N53 -N50 -N5 -N47 -N44 -N41 -N382 -N38 -N367 -N364 -N361 -N358 -N355 -N352 -N35 -N349 -N346 -N343 -N340 -N337 -N334 -N331 -N328 -N325 -N322 -N32 -N319 -N316 -N313 -N310 -N307 -N303 -N299 -N296 -N293 -N29 -N289 -N286 -N283 -N280 -N277 -N274 -N271 -N267 -N263 -N260 -N26 -N257 -N254 -N251 -N248 -N245 -N242 -N241_I -N240 -N239 -N238 -N237 -N236 -N235 -N234 -N233 -N232 -N231 -N230 -N23 -N229 -N228 -N227 -N226 -N225 -N224 -N223 -N222 -N221 -N220 -N219 -N218 -N217 -N216 -N215 -N214 -N213 -N212 -N211 -N210 -N209 -N208 -N207 -N206 -N205 -N204 -N203 -N202 -N201 -N200 -N199 -N198 -N197 -N196 -N195 -N194 -N193 -N192 -N191 -N190 -N189 -N188 -N187 -N186 -N185 -N184 -N183 -N182 -N181 -N180 -N18 -N179 -N178 -N177 -N176 -N175 -N174 -N173 -N172 -N171 -N170 -N169 -N168 -N167 -N166 -N165 -N164 -N163 -N162 -N161 -N160 -N159 -N158 -N157 -N156 -N155 -N154 -N153 -N152 -N151 -N150 -N15 -N147 -N144 -N141 -N138 -N135 -N134 -N133 -N130 -N127 -N124 -N121 -N12 -N118 -N115 -N114 -N113 -N112 -N111 -N110 -N109 -N106 -N103 -N100 -N1 -} -set_output_delay -clock clk 0 { -N945 -N889 -N885 -N884 -N883 -N882 -N881 -N813 -N707 -N643 -N582 -N573 -N571 -N569 -N567 -N565 -N563 -N561 -N559 -N556 -N553 -N551 -N549 -N547 -N545 -N543 -N541 -N539 -N537 -N535 -N519 -N517 -N515 -N513 -N511 -N509 -N507 -N505 -N501 -N492 -N489 -N486 -N484 -N482 -N478 -N388 -N387 -N241_O -N1781 -N1490 -N1489 -N11342 -N11340 -N11334 -N11333 -N1114 -N1113 -N1112 -N1111 -N1110 -N10908 -N10907 -N10906 -N10905 -N10871 -N10870 -N10869 -N10868 -N10840 -N10839 -N10838 -N10837 -N10827 -N10763 -N10762 -N10761 -N10760 -N10759 -N10729 -N10718 -N10717 -N10716 -N10715 -N10714 -N10713 -N10712 -N10711 -N10706 -N10704 -N10641 -N10632 -N10628 -N10576 -N10575 -N10574 -N10353 -N10352 -N10351 -N10350 -N10112 -N10111 -N10110 -N10109 -N10104 -N10103 -N10102 -N10101 -N10025 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas85/c880a.sdc b/benchmarks/iscas85/c880a.sdc index 9d582f7da..5993152de 100644 --- a/benchmarks/iscas85/c880a.sdc +++ b/benchmarks/iscas85/c880a.sdc @@ -1,91 +1,3 @@ -create_clock -name clk -period 10 {} -set_input_delay -clock clk 0 { -N96 -N91 -N90 -N89 -N88 -N87 -N86 -N85 -N80 -N8 -N75 -N74 -N73 -N72 -N68 -N59 -N55 -N51 -N42 -N36 -N29 -N268 -N267 -N261 -N260 -N26 -N259 -N255 -N246 -N237 -N228 -N219 -N210 -N207 -N201 -N195 -N189 -N183 -N177 -N171 -N17 -N165 -N159 -N156 -N153 -N152 -N149 -N146 -N143 -N138 -N135 -N130 -N13 -N126 -N121 -N116 -N111 -N106 -N101 -N1 -} -set_output_delay -clock clk 0 { -N880 -N879 -N878 -N874 -N866 -N865 -N864 -N863 -N850 -N768 -N767 -N450 -N449 -N448 -N447 -N446 -N423 -N422 -N421 -N420 -N419 -N418 -N391 -N390 -N389 -N388 -} +create_clock -name clk -period 0 +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s1196.sdc b/benchmarks/iscas89/s1196.sdc index e616c3f8a..17af5eaff 100644 --- a/benchmarks/iscas89/s1196.sdc +++ b/benchmarks/iscas89/s1196.sdc @@ -1,33 +1,3 @@ create_clock -name clk -period 10 {clk} -set_input_delay -clock clk 0 { -G9 -G8 -G7 -G6 -G5 -G4 -G3 -G2 -G13 -G12 -G11 -G10 -G1 -G0 -} -set_output_delay -clock clk 0 { -G552 -G551 -G550 -G549 -G548 -G547 -G546 -G542 -G539 -G537 -G535 -G532 -G530 -G45 -} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s1238.sdc b/benchmarks/iscas89/s1238.sdc index a9750e7f7..17af5eaff 100644 --- a/benchmarks/iscas89/s1238.sdc +++ b/benchmarks/iscas89/s1238.sdc @@ -1,35 +1,3 @@ -create_clock -name clk -period 10 {CK} -set_input_delay -clock clk 0 { -VDD -GND -G9 -G8 -G7 -G6 -G5 -G4 -G3 -G2 -G13 -G12 -G11 -G10 -G1 -G0 -} -set_output_delay -clock clk 0 { -G552 -G551 -G550 -G549 -G548 -G547 -G546 -G542 -G539 -G537 -G535 -G532 -G530 -G45 -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s1238.v b/benchmarks/iscas89/s1238.v index 8bdd67c40..fda46eaf7 100644 --- a/benchmarks/iscas89/s1238.v +++ b/benchmarks/iscas89/s1238.v @@ -5,10 +5,10 @@ //# 428 gates (134 ANDs + 125 NANDs + 112 ORs + 57 NORs) -module s1238(GND,VDD,CK,G0,G1,G10,G11,G12,G13,G2,G3,G4,G45,G5,G530,G532,G535, +module s1238(GND,VDD,clk,G0,G1,G10,G11,G12,G13,G2,G3,G4,G45,G5,G530,G532,G535, G537,G539, G542,G546,G547,G548,G549,G550,G551,G552,G6,G7,G8,G9); -input GND,VDD,CK,G0,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13; +input GND,VDD,clk,G0,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13; output G549,G550,G551,G552,G542,G546,G547,G548,G530,G532,G535,G537,G45,G539; wire G29,G502,G30,G503,G31,G504,G32,G505,G33,G506,G34,G507,G35,G508,G36,G509, @@ -46,24 +46,24 @@ output G549,G550,G551,G552,G542,G546,G547,G548,G530,G532,G535,G537,G45,G539; G264,G69,G233,G256,G84,G262,G96,G266,G217,G113,G268,G130,G263,G258,G259, G252,G253,G185,G230,G243,G246,G523,G254,G255,G278,G247; - dff DFF_0(CK,G29,G502); - dff DFF_1(CK,G30,G503); - dff DFF_2(CK,G31,G504); - dff DFF_3(CK,G32,G505); - dff DFF_4(CK,G33,G506); - dff DFF_5(CK,G34,G507); - dff DFF_6(CK,G35,G508); - dff DFF_7(CK,G36,G509); - dff DFF_8(CK,G37,G510); - dff DFF_9(CK,G38,G511); - dff DFF_10(CK,G39,G512); - dff DFF_11(CK,G40,G513); - dff DFF_12(CK,G41,G514); - dff DFF_13(CK,G42,G515); - dff DFF_14(CK,G43,G516); - dff DFF_15(CK,G44,G517); - dff DFF_16(CK,G45,G518); - dff DFF_17(CK,G46,G519); + dff DFF_0(clk,G29,G502); + dff DFF_1(clk,G30,G503); + dff DFF_2(clk,G31,G504); + dff DFF_3(clk,G32,G505); + dff DFF_4(clk,G33,G506); + dff DFF_5(clk,G34,G507); + dff DFF_6(clk,G35,G508); + dff DFF_7(clk,G36,G509); + dff DFF_8(clk,G37,G510); + dff DFF_9(clk,G38,G511); + dff DFF_10(clk,G39,G512); + dff DFF_11(clk,G40,G513); + dff DFF_12(clk,G41,G514); + dff DFF_13(clk,G42,G515); + dff DFF_14(clk,G43,G516); + dff DFF_15(clk,G44,G517); + dff DFF_16(clk,G45,G518); + dff DFF_17(clk,G46,G519); not NOT_0(G50,G49); not NOT_1(G55,G54); not NOT_2(G59,G58); diff --git a/benchmarks/iscas89/s1488.sdc b/benchmarks/iscas89/s1488.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s1488.sdc +++ b/benchmarks/iscas89/s1488.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s15850.sdc b/benchmarks/iscas89/s15850.sdc index a7ef88fcb..17af5eaff 100644 --- a/benchmarks/iscas89/s15850.sdc +++ b/benchmarks/iscas89/s15850.sdc @@ -1,234 +1,3 @@ -create_clock -name clk -period 10 {CK} -set_input_delay -clock clk 0 { -g99 -g96 -g95 -g94 -g93 -g925 -g922 -g92 -g919 -g916 -g913 -g910 -g91 -g907 -g904 -g901 -g90 -g898 -g895 -g892 -g89 -g889 -g886 -g881 -g88 -g877 -g873 -g872 -g87 -g86 -g85 -g84 -g83 -g82 -g750 -g744 -g743 -g742 -g741 -g48 -g47 -g46 -g45 -g44 -g43 -g42 -g41 -g31 -g30 -g29 -g28 -g27 -g23 -g1961 -g1960 -g18 -g1712 -g1700 -g1696 -g1203 -g1200 -g1197 -g1194 -g1191 -g1188 -g1185 -g1182 -g1179 -g1176 -g1173 -g1170 -g109 -g104 -g103 -g102 -g101 -g100 -VDD -GND -} -set_output_delay -clock clk 0 { -g9961 -g9451 -g8986 -g8985 -g8984 -g8983 -g8982 -g8981 -g8980 -g8979 -g8978 -g8977 -g8976 -g8566 -g8565 -g8564 -g8563 -g8562 -g8561 -g8352 -g8349 -g8347 -g8340 -g8335 -g8331 -g8328 -g8323 -g8318 -g8316 -g8313 -g8271 -g8062 -g8061 -g7744 -g6955 -g6949 -g6942 -g6932 -g6926 -g6920 -g6842 -g6285 -g6284 -g6283 -g6282 -g6281 -g6280 -g6279 -g6278 -g6277 -g6276 -g6275 -g6274 -g6273 -g6272 -g6271 -g6270 -g6269 -g6268 -g6267 -g6266 -g6265 -g6264 -g6263 -g6262 -g6261 -g6260 -g6259 -g6258 -g6257 -g6256 -g6255 -g6254 -g6253 -g5816 -g5659 -g5658 -g5105 -g5101 -g4888 -g4887 -g4216 -g4215 -g4214 -g4213 -g4212 -g4211 -g4210 -g4209 -g4208 -g4207 -g4206 -g4205 -g4204 -g4203 -g4202 -g4201 -g4200 -g4199 -g4198 -g4197 -g4196 -g4195 -g4194 -g4193 -g4192 -g4191 -g4181 -g4180 -g4179 -g4178 -g4177 -g4176 -g4175 -g4174 -g4173 -g4172 -g4171 -g3327 -g3069 -g3007 -g2986 -g2648 -g2612 -g2611 -g2610 -g2609 -g2608 -g2607 -g2606 -g2605 -g2604 -g2603 -g2602 -g2601 -g2355 -g1957 -g11489 -g11206 -g11163 -g10801 -g10628 -g10465 -g10463 -g10461 -g10459 -g10457 -g10455 -g10379 -g10377 -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s15850.v b/benchmarks/iscas89/s15850.v index 9a2eeb8b7..e63fc6f31 100644 --- a/benchmarks/iscas89/s15850.v +++ b/benchmarks/iscas89/s15850.v @@ -5,7 +5,7 @@ //# 3448 gates (1619 ANDs + 968 NANDs + 710 ORs + 151 NORs) -module s15850(GND,VDD,CK,g100,g101,g102,g103,g10377,g10379,g104,g10455,g10457, +module s15850(GND,VDD,clk,g100,g101,g102,g103,g10377,g10379,g104,g10455,g10457, g10459, g10461,g10463,g10465,g10628,g10801,g109,g11163,g11206,g11489,g1170,g1173, g1176,g1179,g1182,g1185,g1188,g1191,g1194,g1197,g1200,g1203,g1696,g1700, @@ -24,7 +24,7 @@ module s15850(GND,VDD,CK,g100,g101,g102,g103,g10377,g10379,g104,g10455,g10457, g877,g88,g881,g886,g889,g89,g892,g895,g8976,g8977,g8978,g8979,g898,g8980, g8981,g8982,g8983,g8984,g8985,g8986,g90,g901,g904,g907,g91,g910,g913,g916, g919,g92,g922,g925,g93,g94,g9451,g95,g96,g99,g9961); -input GND,VDD,CK,g18,g27,g109,g741,g742,g743,g744,g872,g873,g877,g881,g1712, +input GND,VDD,clk,g18,g27,g109,g741,g742,g743,g744,g872,g873,g877,g881,g1712, g1960,g1961, g1696,g750,g85,g42,g1700,g102,g104,g101,g29,g28,g103,g83,g23,g87,g922,g892, g84,g919,g1182,g925,g48,g895,g889,g1185,g41,g43,g99,g1173,g1203,g1188,g1197, @@ -929,540 +929,540 @@ output g2355,g2601,g2602,g2603,g2604,g2605,g2606,g2607,g2608,g2609,g2610,g2611, g5345,g10432,g5938,I12021,I6489,I5528,I13659,I5343,I12039,I9008,I6488, I13888,I17494,I7684,g3221,I6324,I8590,I11243,g10324,g10239,g4974,g10322; - dff DFF_0(CK,g1289,g5660); - dff DFF_1(CK,g1882,g9349); - dff DFF_2(CK,g312,g5644); - dff DFF_3(CK,g452,g11257); - dff DFF_4(CK,g123,g8272); - dff DFF_5(CK,g207,g7315); - dff DFF_6(CK,g713,g9345); - dff DFF_7(CK,g1153,g6304); - dff DFF_8(CK,g1209,g10873); - dff DFF_9(CK,g1744,g5663); - dff DFF_10(CK,g1558,g7349); - dff DFF_11(CK,g695,g9343); - dff DFF_12(CK,g461,g11467); - dff DFF_13(CK,g940,g8572); - dff DFF_14(CK,g976,g11471); - dff DFF_15(CK,g709,g8432); - dff DFF_16(CK,g1092,g6810); - dff DFF_17(CK,g1574,g7354); - dff DFF_18(CK,g1864,g7816); - dff DFF_19(CK,g369,g11439); - dff DFF_20(CK,g1580,g7356); - dff DFF_21(CK,g1736,g6846); - dff DFF_22(CK,g39,g10774); - dff DFF_23(CK,g1651,g11182); - dff DFF_24(CK,g1424,g7330); - dff DFF_25(CK,g1737,g1736); - dff DFF_26(CK,g1672,g11037); - dff DFF_27(CK,g1077,g6805); - dff DFF_28(CK,g1231,g8279); - dff DFF_29(CK,g4,g8079); - dff DFF_30(CK,g774,g7785); - dff DFF_31(CK,g1104,g6815); - dff DFF_32(CK,g1304,g7290); - dff DFF_33(CK,g243,g7325); - dff DFF_34(CK,g1499,g8447); - dff DFF_35(CK,g1044,g7789); - dff DFF_36(CK,g1444,g8987); - dff DFF_37(CK,g757,g11179); - dff DFF_38(CK,g786,g8436); - dff DFF_39(CK,g1543,g7344); - dff DFF_40(CK,g552,g11045); - dff DFF_41(CK,g315,g5645); - dff DFF_42(CK,g1534,g7341); - dff DFF_43(CK,g622,g9338); - dff DFF_44(CK,g1927,g9354); - dff DFF_45(CK,g1660,g11033); - dff DFF_46(CK,g278,g7765); - dff DFF_47(CK,g1436,g8989); - dff DFF_48(CK,g718,g8433); - dff DFF_49(CK,g76,g7775); - dff DFF_50(CK,g554,g11047); - dff DFF_51(CK,g496,g11333); - dff DFF_52(CK,g981,g11472); - dff DFF_53(CK,g878,g4896); - dff DFF_54(CK,g590,g5653); - dff DFF_55(CK,g829,g4182); - dff DFF_56(CK,g1095,g6811); - dff DFF_57(CK,g704,g9344); - dff DFF_58(CK,g1265,g7302); - dff DFF_59(CK,g1786,g7814); - dff DFF_60(CK,g682,g8429); - dff DFF_61(CK,g1296,g7292); - dff DFF_62(CK,g587,g6295); - dff DFF_63(CK,g52,g7777); - dff DFF_64(CK,g646,g8065); - dff DFF_65(CK,g327,g5649); - dff DFF_66(CK,g1389,g6836); - dff DFF_67(CK,g1371,g7311); - dff DFF_68(CK,g1956,g1955); - dff DFF_69(CK,g1675,g11038); - dff DFF_70(CK,g354,g11508); - dff DFF_71(CK,g113,g7285); - dff DFF_72(CK,g639,g8063); - dff DFF_73(CK,g1684,g11041); - dff DFF_74(CK,g1639,g8448); - dff DFF_75(CK,g1791,g8080); - dff DFF_76(CK,g248,g7323); - dff DFF_77(CK,g1707,g4907); - dff DFF_78(CK,g1759,g5668); - dff DFF_79(CK,g351,g11507); - dff DFF_80(CK,g1957,g1956); - dff DFF_81(CK,g1604,g7364); - dff DFF_82(CK,g1098,g6812); - dff DFF_83(CK,g932,g8570); - dff DFF_84(CK,g126,g5642); - dff DFF_85(CK,g1896,g8282); - dff DFF_86(CK,g736,g8435); - dff DFF_87(CK,g1019,g7807); - dff DFF_88(CK,g1362,g7305); - dff DFF_89(CK,g745,g2639); - dff DFF_90(CK,g1419,g7332); - dff DFF_91(CK,g58,g7779); - dff DFF_92(CK,g32,g11397); - dff DFF_93(CK,g876,g878); - dff DFF_94(CK,g1086,g6808); - dff DFF_95(CK,g1486,g8444); - dff DFF_96(CK,g1730,g10881); - dff DFF_97(CK,g1504,g7328); - dff DFF_98(CK,g1470,g8440); - dff DFF_99(CK,g822,g8437); - dff DFF_100(CK,g583,g6291); - dff DFF_101(CK,g1678,g11039); - dff DFF_102(CK,g174,g8423); - dff DFF_103(CK,g1766,g7810); - dff DFF_104(CK,g1801,g8450); - dff DFF_105(CK,g186,g7317); - dff DFF_106(CK,g959,g11403); - dff DFF_107(CK,g1169,g6314); - dff DFF_108(CK,g1007,g7806); - dff DFF_109(CK,g1407,g8993); - dff DFF_110(CK,g1059,g7794); - dff DFF_111(CK,g1868,g7817); - dff DFF_112(CK,g758,g6797); - dff DFF_113(CK,g1718,g6337); - dff DFF_114(CK,g396,g11265); - dff DFF_115(CK,g1015,g7808); - dff DFF_116(CK,g38,g10872); - dff DFF_117(CK,g632,g5655); - dff DFF_118(CK,g1415,g7335); - dff DFF_119(CK,g1227,g8278); - dff DFF_120(CK,g1721,g10878); - dff DFF_121(CK,g882,g883); - dff DFF_122(CK,g16,g4906); - dff DFF_123(CK,g284,g7767); - dff DFF_124(CK,g426,g11256); - dff DFF_125(CK,g219,g7310); - dff DFF_126(CK,g1216,g1360); - dff DFF_127(CK,g806,g7289); - dff DFF_128(CK,g1428,g8992); - dff DFF_129(CK,g579,g6287); - dff DFF_130(CK,g1564,g7351); - dff DFF_131(CK,g1741,g5662); - dff DFF_132(CK,g225,g7309); - dff DFF_133(CK,g281,g7766); - dff DFF_134(CK,g1308,g11627); - dff DFF_135(CK,g611,g9930); - dff DFF_136(CK,g631,g5654); - dff DFF_137(CK,g1217,g9823); - dff DFF_138(CK,g1589,g7359); - dff DFF_139(CK,g1466,g8439); - dff DFF_140(CK,g1571,g7353); - dff DFF_141(CK,g1861,g7815); - dff DFF_142(CK,g1365,g7307); - dff DFF_143(CK,g1448,g11594); - dff DFF_144(CK,g1711,g6335); - dff DFF_145(CK,g1133,g6309); - dff DFF_146(CK,g1333,g11635); - dff DFF_147(CK,g153,g8426); - dff DFF_148(CK,g962,g11404); - dff DFF_149(CK,g766,g6799); - dff DFF_150(CK,g588,g6296); - dff DFF_151(CK,g486,g11331); - dff DFF_152(CK,g471,g11469); - dff DFF_153(CK,g1397,g7322); - dff DFF_154(CK,g580,g6288); - dff DFF_155(CK,g1950,g8288); - dff DFF_156(CK,g756,g755); - dff DFF_157(CK,g635,g5656); - dff DFF_158(CK,g1101,g6814); - dff DFF_159(CK,g549,g11044); - dff DFF_160(CK,g1041,g7788); - dff DFF_161(CK,g105,g11180); - dff DFF_162(CK,g1669,g11036); - dff DFF_163(CK,g1368,g7308); - dff DFF_164(CK,g1531,g7340); - dff DFF_165(CK,g1458,g7327); - dff DFF_166(CK,g572,g10877); - dff DFF_167(CK,g1011,g7805); - dff DFF_168(CK,g33,g10867); - dff DFF_169(CK,g1411,g7331); - dff DFF_170(CK,g1074,g6813); - dff DFF_171(CK,g444,g11259); - dff DFF_172(CK,g1474,g8441); - dff DFF_173(CK,g1080,g6806); - dff DFF_174(CK,g1713,g6336); - dff DFF_175(CK,g333,g5651); - dff DFF_176(CK,g269,g7762); - dff DFF_177(CK,g401,g11266); - dff DFF_178(CK,g1857,g11409); - dff DFF_179(CK,g9,g7336); - dff DFF_180(CK,g664,g8782); - dff DFF_181(CK,g965,g11405); - dff DFF_182(CK,g1400,g7324); - dff DFF_183(CK,g309,g5652); - dff DFF_184(CK,g814,g8077); - dff DFF_185(CK,g231,g7319); - dff DFF_186(CK,g557,g11048); - dff DFF_187(CK,g586,g6294); - dff DFF_188(CK,g869,g875); - dff DFF_189(CK,g1383,g7316); - dff DFF_190(CK,g158,g8425); - dff DFF_191(CK,g627,g5657); - dff DFF_192(CK,g1023,g7799); - dff DFF_193(CK,g259,g7755); - dff DFF_194(CK,g1361,g1206); - dff DFF_195(CK,g1327,g11633); - dff DFF_196(CK,g654,g8067); - dff DFF_197(CK,g293,g7770); - dff DFF_198(CK,g1346,g11656); - dff DFF_199(CK,g1633,g8873); - dff DFF_200(CK,g1753,g5666); - dff DFF_201(CK,g1508,g7329); - dff DFF_202(CK,g1240,g7297); - dff DFF_203(CK,g538,g11326); - dff DFF_204(CK,g416,g11269); - dff DFF_205(CK,g542,g11325); - dff DFF_206(CK,g1681,g11040); - dff DFF_207(CK,g374,g11440); - dff DFF_208(CK,g563,g11050); - dff DFF_209(CK,g1914,g8284); - dff DFF_210(CK,g530,g11328); - dff DFF_211(CK,g575,g11052); - dff DFF_212(CK,g1936,g9355); - dff DFF_213(CK,g55,g7778); - dff DFF_214(CK,g1117,g6299); - dff DFF_215(CK,g1317,g1356); - dff DFF_216(CK,g357,g11509); - dff DFF_217(CK,g386,g11263); - dff DFF_218(CK,g1601,g7363); - dff DFF_219(CK,g553,g11046); - dff DFF_220(CK,g166,g7747); - dff DFF_221(CK,g501,g11334); - dff DFF_222(CK,g262,g7758); - dff DFF_223(CK,g1840,g8694); - dff DFF_224(CK,g70,g7783); - dff DFF_225(CK,g318,g5646); - dff DFF_226(CK,g1356,g6818); - dff DFF_227(CK,g794,g6800); - dff DFF_228(CK,g36,g10870); - dff DFF_229(CK,g302,g7773); - dff DFF_230(CK,g342,g11513); - dff DFF_231(CK,g1250,g7299); - dff DFF_232(CK,g1163,g6301); - dff DFF_233(CK,g1810,g2044); - dff DFF_234(CK,g1032,g7800); - dff DFF_235(CK,g1432,g8990); - dff DFF_236(CK,g1053,g7792); - dff DFF_237(CK,g1453,g7326); - dff DFF_238(CK,g363,g11511); - dff DFF_239(CK,g330,g5650); - dff DFF_240(CK,g1157,g6303); - dff DFF_241(CK,g1357,g6330); - dff DFF_242(CK,g35,g10869); - dff DFF_243(CK,g928,g8569); - dff DFF_244(CK,g261,g7757); - dff DFF_245(CK,g516,g11337); - dff DFF_246(CK,g254,g7759); - dff DFF_247(CK,g778,g8076); - dff DFF_248(CK,g861,g4190); - dff DFF_249(CK,g1627,g8871); - dff DFF_250(CK,g1292,g7293); - dff DFF_251(CK,g290,g7769); - dff DFF_252(CK,g1850,g5671); - dff DFF_253(CK,g770,g7288); - dff DFF_254(CK,g1583,g7357); - dff DFF_255(CK,g466,g11468); - dff DFF_256(CK,g1561,g7350); - dff DFF_257(CK,g1527,g4899); - dff DFF_258(CK,g1546,g7345); - dff DFF_259(CK,g287,g7768); - dff DFF_260(CK,g560,g11049); - dff DFF_261(CK,g617,g8780); - dff DFF_262(CK,g17,g4894); - dff DFF_263(CK,g336,g11653); - dff DFF_264(CK,g456,g11466); - dff DFF_265(CK,g305,g5643); - dff DFF_266(CK,g345,g11642); - dff DFF_267(CK,g8,g2613); - dff DFF_268(CK,g1771,g7811); - dff DFF_269(CK,g865,g8275); - dff DFF_270(CK,g255,g7751); - dff DFF_271(CK,g1945,g9356); - dff DFF_272(CK,g1738,g5661); - dff DFF_273(CK,g1478,g8442); - dff DFF_274(CK,g1035,g7787); - dff DFF_275(CK,g1959,g4217); - dff DFF_276(CK,g1690,g6844); - dff DFF_277(CK,g1482,g8443); - dff DFF_278(CK,g1110,g6817); - dff DFF_279(CK,g296,g7771); - dff DFF_280(CK,g1663,g11034); - dff DFF_281(CK,g700,g8431); - dff DFF_282(CK,g1762,g5669); - dff DFF_283(CK,g360,g11510); - dff DFF_284(CK,g192,g6837); - dff DFF_285(CK,g1657,g10875); - dff DFF_286(CK,g722,g9346); - dff DFF_287(CK,g61,g7780); - dff DFF_288(CK,g566,g11051); - dff DFF_289(CK,g1394,g7809); - dff DFF_290(CK,g1089,g6809); - dff DFF_291(CK,g883,g4897); - dff DFF_292(CK,g1071,g6804); - dff DFF_293(CK,g986,g11473); - dff DFF_294(CK,g971,g11470); - dff DFF_295(CK,g1955,g6338); - dff DFF_296(CK,g143,g7746); - dff DFF_297(CK,g1814,g9825); - dff DFF_298(CK,g1038,g7797); - dff DFF_299(CK,g1212,g1217); - dff DFF_300(CK,g1918,g9353); - dff DFF_301(CK,g782,g8273); - dff DFF_302(CK,g1822,g9826); - dff DFF_303(CK,g237,g7306); - dff DFF_304(CK,g746,g2638); - dff DFF_305(CK,g1062,g7795); - dff DFF_306(CK,g1462,g8438); - dff DFF_307(CK,g178,g7748); - dff DFF_308(CK,g366,g11512); - dff DFF_309(CK,g837,g4184); - dff DFF_310(CK,g599,g9819); - dff DFF_311(CK,g1854,g11408); - dff DFF_312(CK,g944,g11398); - dff DFF_313(CK,g1941,g8287); - dff DFF_314(CK,g170,g8422); - dff DFF_315(CK,g1520,g7334); - dff DFF_316(CK,g686,g9342); - dff DFF_317(CK,g953,g11401); - dff DFF_318(CK,g1958,g6339); - dff DFF_319(CK,g40,g10775); - dff DFF_320(CK,g1765,g3329); - dff DFF_321(CK,g1733,g10882); - dff DFF_322(CK,g1270,g7303); - dff DFF_323(CK,g1610,g6845); - dff DFF_324(CK,g1796,g8280); - dff DFF_325(CK,g1324,g11632); - dff DFF_326(CK,g1540,g7343); - dff DFF_327(CK,g1377,g7312); - dff DFF_328(CK,g1206,g4898); - dff DFF_329(CK,g491,g11332); - dff DFF_330(CK,g1849,g5670); - dff DFF_331(CK,g213,g7313); - dff DFF_332(CK,g1781,g7813); - dff DFF_333(CK,g1900,g9351); - dff DFF_334(CK,g1245,g7298); - dff DFF_335(CK,g108,g11593); - dff DFF_336(CK,g630,g7287); - dff DFF_337(CK,g148,g8427); - dff DFF_338(CK,g833,g4183); - dff DFF_339(CK,g1923,g8285); - dff DFF_340(CK,g936,g8571); - dff DFF_341(CK,g1215,g6315); - dff DFF_342(CK,g1314,g11629); - dff DFF_343(CK,g849,g4187); - dff DFF_344(CK,g1336,g11654); - dff DFF_345(CK,g272,g7763); - dff DFF_346(CK,g1806,g8573); - dff DFF_347(CK,g826,g8568); - dff DFF_348(CK,g1065,g7796); - dff DFF_349(CK,g1887,g8281); - dff DFF_350(CK,g37,g10871); - dff DFF_351(CK,g968,g11406); - dff DFF_352(CK,g1845,g5673); - dff DFF_353(CK,g1137,g6310); - dff DFF_354(CK,g1891,g9350); - dff DFF_355(CK,g1255,g7300); - dff DFF_356(CK,g257,g7753); - dff DFF_357(CK,g874,g9821); - dff DFF_358(CK,g591,g9818); - dff DFF_359(CK,g731,g9347); - dff DFF_360(CK,g636,g8781); - dff DFF_361(CK,g1218,g8276); - dff DFF_362(CK,g605,g9820); - dff DFF_363(CK,g79,g7776); - dff DFF_364(CK,g182,g7749); - dff DFF_365(CK,g950,g11400); - dff DFF_366(CK,g1129,g6308); - dff DFF_367(CK,g857,g4189); - dff DFF_368(CK,g448,g11258); - dff DFF_369(CK,g1828,g9827); - dff DFF_370(CK,g1727,g10880); - dff DFF_371(CK,g1592,g7360); - dff DFF_372(CK,g1703,g6843); - dff DFF_373(CK,g1932,g8286); - dff DFF_374(CK,g1624,g8870); - dff DFF_375(CK,g26,g4885); - dff DFF_376(CK,g1068,g6803); - dff DFF_377(CK,g578,g6286); - dff DFF_378(CK,g440,g11260); - dff DFF_379(CK,g476,g11338); - dff DFF_380(CK,g119,g7745); - dff DFF_381(CK,g668,g9340); - dff DFF_382(CK,g139,g8418); - dff DFF_383(CK,g1149,g6305); - dff DFF_384(CK,g34,g10868); - dff DFF_385(CK,g1848,g7366); - dff DFF_386(CK,g263,g7760); - dff DFF_387(CK,g818,g8274); - dff DFF_388(CK,g1747,g5664); - dff DFF_389(CK,g802,g6802); - dff DFF_390(CK,g275,g7764); - dff DFF_391(CK,g1524,g7338); - dff DFF_392(CK,g1577,g7355); - dff DFF_393(CK,g810,g7786); - dff DFF_394(CK,g391,g11264); - dff DFF_395(CK,g658,g9339); - dff DFF_396(CK,g1386,g7318); - dff DFF_397(CK,g253,g7750); - dff DFF_398(CK,g875,g9822); - dff DFF_399(CK,g1125,g6307); - dff DFF_400(CK,g201,g7304); - dff DFF_401(CK,g1280,g7295); - dff DFF_402(CK,g1083,g6807); - dff DFF_403(CK,g650,g8066); - dff DFF_404(CK,g1636,g8874); - dff DFF_405(CK,g853,g4188); - dff DFF_406(CK,g421,g11270); - dff DFF_407(CK,g762,g6798); - dff DFF_408(CK,g956,g11402); - dff DFF_409(CK,g378,g11441); - dff DFF_410(CK,g1756,g5667); - dff DFF_411(CK,g589,g6297); - dff DFF_412(CK,g841,g4185); - dff DFF_413(CK,g1027,g7798); - dff DFF_414(CK,g1003,g7803); - dff DFF_415(CK,g1403,g8991); - dff DFF_416(CK,g1145,g6312); - dff DFF_417(CK,g1107,g6816); - dff DFF_418(CK,g1223,g8277); - dff DFF_419(CK,g406,g11267); - dff DFF_420(CK,g1811,g11185); - dff DFF_421(CK,g1642,g11183); - dff DFF_422(CK,g1047,g7790); - dff DFF_423(CK,g1654,g10874); - dff DFF_424(CK,g197,g6835); - dff DFF_425(CK,g1595,g7361); - dff DFF_426(CK,g1537,g7342); - dff DFF_427(CK,g727,g8434); - dff DFF_428(CK,g999,g7804); - dff DFF_429(CK,g798,g6801); - dff DFF_430(CK,g481,g11324); - dff DFF_431(CK,g754,g4895); - dff DFF_432(CK,g1330,g11634); - dff DFF_433(CK,g845,g4186); - dff DFF_434(CK,g790,g8567); - dff DFF_435(CK,g1512,g8449); - dff DFF_436(CK,g114,g113); - dff DFF_437(CK,g1490,g8445); - dff DFF_438(CK,g1166,g6300); - dff DFF_439(CK,g1056,g7793); - dff DFF_440(CK,g348,g11506); - dff DFF_441(CK,g868,g874); - dff DFF_442(CK,g1260,g7301); - dff DFF_443(CK,g260,g7756); - dff DFF_444(CK,g131,g8420); - dff DFF_445(CK,g7,g2731); - dff DFF_446(CK,g258,g7754); - dff DFF_447(CK,g521,g11330); - dff DFF_448(CK,g1318,g11630); - dff DFF_449(CK,g1872,g9348); - dff DFF_450(CK,g677,g9341); - dff DFF_451(CK,g582,g6290); - dff DFF_452(CK,g1393,g7320); - dff DFF_453(CK,g1549,g7346); - dff DFF_454(CK,g947,g11399); - dff DFF_455(CK,g1834,g9895); - dff DFF_456(CK,g1598,g7362); - dff DFF_457(CK,g1121,g6306); - dff DFF_458(CK,g1321,g11631); - dff DFF_459(CK,g506,g11335); - dff DFF_460(CK,g546,g11043); - dff DFF_461(CK,g1909,g9352); - dff DFF_462(CK,g755,g6298); - dff DFF_463(CK,g1552,g7347); - dff DFF_464(CK,g584,g6292); - dff DFF_465(CK,g1687,g11042); - dff DFF_466(CK,g1586,g7358); - dff DFF_467(CK,g324,g5648); - dff DFF_468(CK,g1141,g6311); - dff DFF_469(CK,g1570,g4900); - dff DFF_470(CK,g1341,g11655); - dff DFF_471(CK,g1710,g4901); - dff DFF_472(CK,g1645,g11184); - dff DFF_473(CK,g115,g7321); - dff DFF_474(CK,g135,g8419); - dff DFF_475(CK,g525,g11329); - dff DFF_476(CK,g581,g6289); - dff DFF_477(CK,g1607,g7365); - dff DFF_478(CK,g321,g5647); - dff DFF_479(CK,g67,g7782); - dff DFF_480(CK,g1275,g11443); - dff DFF_481(CK,g1311,g11628); - dff DFF_482(CK,g1615,g8868); - dff DFF_483(CK,g382,g11442); - dff DFF_484(CK,g1374,g6825); - dff DFF_485(CK,g266,g7761); - dff DFF_486(CK,g1284,g7294); - dff DFF_487(CK,g1380,g7314); - dff DFF_488(CK,g673,g8428); - dff DFF_489(CK,g1853,g5672); - dff DFF_490(CK,g162,g8424); - dff DFF_491(CK,g411,g11268); - dff DFF_492(CK,g431,g11262); - dff DFF_493(CK,g1905,g8283); - dff DFF_494(CK,g1515,g7333); - dff DFF_495(CK,g1630,g8872); - dff DFF_496(CK,g49,g7774); - dff DFF_497(CK,g991,g7802); - dff DFF_498(CK,g1300,g7291); - dff DFF_499(CK,g339,g11505); - dff DFF_500(CK,g256,g7752); - dff DFF_501(CK,g1750,g5665); - dff DFF_502(CK,g585,g6293); - dff DFF_503(CK,g1440,g8988); - dff DFF_504(CK,g1666,g11035); - dff DFF_505(CK,g1528,g7339); - dff DFF_506(CK,g1351,g11657); - dff DFF_507(CK,g1648,g11181); - dff DFF_508(CK,g127,g8421); - dff DFF_509(CK,g1618,g11611); - dff DFF_510(CK,g1235,g7296); - dff DFF_511(CK,g299,g7772); - dff DFF_512(CK,g435,g11261); - dff DFF_513(CK,g64,g7781); - dff DFF_514(CK,g1555,g7348); - dff DFF_515(CK,g995,g7801); - dff DFF_516(CK,g1621,g8869); - dff DFF_517(CK,g1113,g6313); - dff DFF_518(CK,g643,g8064); - dff DFF_519(CK,g1494,g8446); - dff DFF_520(CK,g1567,g7352); - dff DFF_521(CK,g691,g8430); - dff DFF_522(CK,g534,g11327); - dff DFF_523(CK,g1776,g7812); - dff DFF_524(CK,g569,g10876); - dff DFF_525(CK,g1160,g6302); - dff DFF_526(CK,g1360,g9824); - dff DFF_527(CK,g1050,g7791); - dff DFF_528(CK,g1,g8078); - dff DFF_529(CK,g511,g11336); - dff DFF_530(CK,g1724,g10879); - dff DFF_531(CK,g12,g7337); - dff DFF_532(CK,g1878,g8695); - dff DFF_533(CK,g73,g7784); + dff DFF_0(clk,g1289,g5660); + dff DFF_1(clk,g1882,g9349); + dff DFF_2(clk,g312,g5644); + dff DFF_3(clk,g452,g11257); + dff DFF_4(clk,g123,g8272); + dff DFF_5(clk,g207,g7315); + dff DFF_6(clk,g713,g9345); + dff DFF_7(clk,g1153,g6304); + dff DFF_8(clk,g1209,g10873); + dff DFF_9(clk,g1744,g5663); + dff DFF_10(clk,g1558,g7349); + dff DFF_11(clk,g695,g9343); + dff DFF_12(clk,g461,g11467); + dff DFF_13(clk,g940,g8572); + dff DFF_14(clk,g976,g11471); + dff DFF_15(clk,g709,g8432); + dff DFF_16(clk,g1092,g6810); + dff DFF_17(clk,g1574,g7354); + dff DFF_18(clk,g1864,g7816); + dff DFF_19(clk,g369,g11439); + dff DFF_20(clk,g1580,g7356); + dff DFF_21(clk,g1736,g6846); + dff DFF_22(clk,g39,g10774); + dff DFF_23(clk,g1651,g11182); + dff DFF_24(clk,g1424,g7330); + dff DFF_25(clk,g1737,g1736); + dff DFF_26(clk,g1672,g11037); + dff DFF_27(clk,g1077,g6805); + dff DFF_28(clk,g1231,g8279); + dff DFF_29(clk,g4,g8079); + dff DFF_30(clk,g774,g7785); + dff DFF_31(clk,g1104,g6815); + dff DFF_32(clk,g1304,g7290); + dff DFF_33(clk,g243,g7325); + dff DFF_34(clk,g1499,g8447); + dff DFF_35(clk,g1044,g7789); + dff DFF_36(clk,g1444,g8987); + dff DFF_37(clk,g757,g11179); + dff DFF_38(clk,g786,g8436); + dff DFF_39(clk,g1543,g7344); + dff DFF_40(clk,g552,g11045); + dff DFF_41(clk,g315,g5645); + dff DFF_42(clk,g1534,g7341); + dff DFF_43(clk,g622,g9338); + dff DFF_44(clk,g1927,g9354); + dff DFF_45(clk,g1660,g11033); + dff DFF_46(clk,g278,g7765); + dff DFF_47(clk,g1436,g8989); + dff DFF_48(clk,g718,g8433); + dff DFF_49(clk,g76,g7775); + dff DFF_50(clk,g554,g11047); + dff DFF_51(clk,g496,g11333); + dff DFF_52(clk,g981,g11472); + dff DFF_53(clk,g878,g4896); + dff DFF_54(clk,g590,g5653); + dff DFF_55(clk,g829,g4182); + dff DFF_56(clk,g1095,g6811); + dff DFF_57(clk,g704,g9344); + dff DFF_58(clk,g1265,g7302); + dff DFF_59(clk,g1786,g7814); + dff DFF_60(clk,g682,g8429); + dff DFF_61(clk,g1296,g7292); + dff DFF_62(clk,g587,g6295); + dff DFF_63(clk,g52,g7777); + dff DFF_64(clk,g646,g8065); + dff DFF_65(clk,g327,g5649); + dff DFF_66(clk,g1389,g6836); + dff DFF_67(clk,g1371,g7311); + dff DFF_68(clk,g1956,g1955); + dff DFF_69(clk,g1675,g11038); + dff DFF_70(clk,g354,g11508); + dff DFF_71(clk,g113,g7285); + dff DFF_72(clk,g639,g8063); + dff DFF_73(clk,g1684,g11041); + dff DFF_74(clk,g1639,g8448); + dff DFF_75(clk,g1791,g8080); + dff DFF_76(clk,g248,g7323); + dff DFF_77(clk,g1707,g4907); + dff DFF_78(clk,g1759,g5668); + dff DFF_79(clk,g351,g11507); + dff DFF_80(clk,g1957,g1956); + dff DFF_81(clk,g1604,g7364); + dff DFF_82(clk,g1098,g6812); + dff DFF_83(clk,g932,g8570); + dff DFF_84(clk,g126,g5642); + dff DFF_85(clk,g1896,g8282); + dff DFF_86(clk,g736,g8435); + dff DFF_87(clk,g1019,g7807); + dff DFF_88(clk,g1362,g7305); + dff DFF_89(clk,g745,g2639); + dff DFF_90(clk,g1419,g7332); + dff DFF_91(clk,g58,g7779); + dff DFF_92(clk,g32,g11397); + dff DFF_93(clk,g876,g878); + dff DFF_94(clk,g1086,g6808); + dff DFF_95(clk,g1486,g8444); + dff DFF_96(clk,g1730,g10881); + dff DFF_97(clk,g1504,g7328); + dff DFF_98(clk,g1470,g8440); + dff DFF_99(clk,g822,g8437); + dff DFF_100(clk,g583,g6291); + dff DFF_101(clk,g1678,g11039); + dff DFF_102(clk,g174,g8423); + dff DFF_103(clk,g1766,g7810); + dff DFF_104(clk,g1801,g8450); + dff DFF_105(clk,g186,g7317); + dff DFF_106(clk,g959,g11403); + dff DFF_107(clk,g1169,g6314); + dff DFF_108(clk,g1007,g7806); + dff DFF_109(clk,g1407,g8993); + dff DFF_110(clk,g1059,g7794); + dff DFF_111(clk,g1868,g7817); + dff DFF_112(clk,g758,g6797); + dff DFF_113(clk,g1718,g6337); + dff DFF_114(clk,g396,g11265); + dff DFF_115(clk,g1015,g7808); + dff DFF_116(clk,g38,g10872); + dff DFF_117(clk,g632,g5655); + dff DFF_118(clk,g1415,g7335); + dff DFF_119(clk,g1227,g8278); + dff DFF_120(clk,g1721,g10878); + dff DFF_121(clk,g882,g883); + dff DFF_122(clk,g16,g4906); + dff DFF_123(clk,g284,g7767); + dff DFF_124(clk,g426,g11256); + dff DFF_125(clk,g219,g7310); + dff DFF_126(clk,g1216,g1360); + dff DFF_127(clk,g806,g7289); + dff DFF_128(clk,g1428,g8992); + dff DFF_129(clk,g579,g6287); + dff DFF_130(clk,g1564,g7351); + dff DFF_131(clk,g1741,g5662); + dff DFF_132(clk,g225,g7309); + dff DFF_133(clk,g281,g7766); + dff DFF_134(clk,g1308,g11627); + dff DFF_135(clk,g611,g9930); + dff DFF_136(clk,g631,g5654); + dff DFF_137(clk,g1217,g9823); + dff DFF_138(clk,g1589,g7359); + dff DFF_139(clk,g1466,g8439); + dff DFF_140(clk,g1571,g7353); + dff DFF_141(clk,g1861,g7815); + dff DFF_142(clk,g1365,g7307); + dff DFF_143(clk,g1448,g11594); + dff DFF_144(clk,g1711,g6335); + dff DFF_145(clk,g1133,g6309); + dff DFF_146(clk,g1333,g11635); + dff DFF_147(clk,g153,g8426); + dff DFF_148(clk,g962,g11404); + dff DFF_149(clk,g766,g6799); + dff DFF_150(clk,g588,g6296); + dff DFF_151(clk,g486,g11331); + dff DFF_152(clk,g471,g11469); + dff DFF_153(clk,g1397,g7322); + dff DFF_154(clk,g580,g6288); + dff DFF_155(clk,g1950,g8288); + dff DFF_156(clk,g756,g755); + dff DFF_157(clk,g635,g5656); + dff DFF_158(clk,g1101,g6814); + dff DFF_159(clk,g549,g11044); + dff DFF_160(clk,g1041,g7788); + dff DFF_161(clk,g105,g11180); + dff DFF_162(clk,g1669,g11036); + dff DFF_163(clk,g1368,g7308); + dff DFF_164(clk,g1531,g7340); + dff DFF_165(clk,g1458,g7327); + dff DFF_166(clk,g572,g10877); + dff DFF_167(clk,g1011,g7805); + dff DFF_168(clk,g33,g10867); + dff DFF_169(clk,g1411,g7331); + dff DFF_170(clk,g1074,g6813); + dff DFF_171(clk,g444,g11259); + dff DFF_172(clk,g1474,g8441); + dff DFF_173(clk,g1080,g6806); + dff DFF_174(clk,g1713,g6336); + dff DFF_175(clk,g333,g5651); + dff DFF_176(clk,g269,g7762); + dff DFF_177(clk,g401,g11266); + dff DFF_178(clk,g1857,g11409); + dff DFF_179(clk,g9,g7336); + dff DFF_180(clk,g664,g8782); + dff DFF_181(clk,g965,g11405); + dff DFF_182(clk,g1400,g7324); + dff DFF_183(clk,g309,g5652); + dff DFF_184(clk,g814,g8077); + dff DFF_185(clk,g231,g7319); + dff DFF_186(clk,g557,g11048); + dff DFF_187(clk,g586,g6294); + dff DFF_188(clk,g869,g875); + dff DFF_189(clk,g1383,g7316); + dff DFF_190(clk,g158,g8425); + dff DFF_191(clk,g627,g5657); + dff DFF_192(clk,g1023,g7799); + dff DFF_193(clk,g259,g7755); + dff DFF_194(clk,g1361,g1206); + dff DFF_195(clk,g1327,g11633); + dff DFF_196(clk,g654,g8067); + dff DFF_197(clk,g293,g7770); + dff DFF_198(clk,g1346,g11656); + dff DFF_199(clk,g1633,g8873); + dff DFF_200(clk,g1753,g5666); + dff DFF_201(clk,g1508,g7329); + dff DFF_202(clk,g1240,g7297); + dff DFF_203(clk,g538,g11326); + dff DFF_204(clk,g416,g11269); + dff DFF_205(clk,g542,g11325); + dff DFF_206(clk,g1681,g11040); + dff DFF_207(clk,g374,g11440); + dff DFF_208(clk,g563,g11050); + dff DFF_209(clk,g1914,g8284); + dff DFF_210(clk,g530,g11328); + dff DFF_211(clk,g575,g11052); + dff DFF_212(clk,g1936,g9355); + dff DFF_213(clk,g55,g7778); + dff DFF_214(clk,g1117,g6299); + dff DFF_215(clk,g1317,g1356); + dff DFF_216(clk,g357,g11509); + dff DFF_217(clk,g386,g11263); + dff DFF_218(clk,g1601,g7363); + dff DFF_219(clk,g553,g11046); + dff DFF_220(clk,g166,g7747); + dff DFF_221(clk,g501,g11334); + dff DFF_222(clk,g262,g7758); + dff DFF_223(clk,g1840,g8694); + dff DFF_224(clk,g70,g7783); + dff DFF_225(clk,g318,g5646); + dff DFF_226(clk,g1356,g6818); + dff DFF_227(clk,g794,g6800); + dff DFF_228(clk,g36,g10870); + dff DFF_229(clk,g302,g7773); + dff DFF_230(clk,g342,g11513); + dff DFF_231(clk,g1250,g7299); + dff DFF_232(clk,g1163,g6301); + dff DFF_233(clk,g1810,g2044); + dff DFF_234(clk,g1032,g7800); + dff DFF_235(clk,g1432,g8990); + dff DFF_236(clk,g1053,g7792); + dff DFF_237(clk,g1453,g7326); + dff DFF_238(clk,g363,g11511); + dff DFF_239(clk,g330,g5650); + dff DFF_240(clk,g1157,g6303); + dff DFF_241(clk,g1357,g6330); + dff DFF_242(clk,g35,g10869); + dff DFF_243(clk,g928,g8569); + dff DFF_244(clk,g261,g7757); + dff DFF_245(clk,g516,g11337); + dff DFF_246(clk,g254,g7759); + dff DFF_247(clk,g778,g8076); + dff DFF_248(clk,g861,g4190); + dff DFF_249(clk,g1627,g8871); + dff DFF_250(clk,g1292,g7293); + dff DFF_251(clk,g290,g7769); + dff DFF_252(clk,g1850,g5671); + dff DFF_253(clk,g770,g7288); + dff DFF_254(clk,g1583,g7357); + dff DFF_255(clk,g466,g11468); + dff DFF_256(clk,g1561,g7350); + dff DFF_257(clk,g1527,g4899); + dff DFF_258(clk,g1546,g7345); + dff DFF_259(clk,g287,g7768); + dff DFF_260(clk,g560,g11049); + dff DFF_261(clk,g617,g8780); + dff DFF_262(clk,g17,g4894); + dff DFF_263(clk,g336,g11653); + dff DFF_264(clk,g456,g11466); + dff DFF_265(clk,g305,g5643); + dff DFF_266(clk,g345,g11642); + dff DFF_267(clk,g8,g2613); + dff DFF_268(clk,g1771,g7811); + dff DFF_269(clk,g865,g8275); + dff DFF_270(clk,g255,g7751); + dff DFF_271(clk,g1945,g9356); + dff DFF_272(clk,g1738,g5661); + dff DFF_273(clk,g1478,g8442); + dff DFF_274(clk,g1035,g7787); + dff DFF_275(clk,g1959,g4217); + dff DFF_276(clk,g1690,g6844); + dff DFF_277(clk,g1482,g8443); + dff DFF_278(clk,g1110,g6817); + dff DFF_279(clk,g296,g7771); + dff DFF_280(clk,g1663,g11034); + dff DFF_281(clk,g700,g8431); + dff DFF_282(clk,g1762,g5669); + dff DFF_283(clk,g360,g11510); + dff DFF_284(clk,g192,g6837); + dff DFF_285(clk,g1657,g10875); + dff DFF_286(clk,g722,g9346); + dff DFF_287(clk,g61,g7780); + dff DFF_288(clk,g566,g11051); + dff DFF_289(clk,g1394,g7809); + dff DFF_290(clk,g1089,g6809); + dff DFF_291(clk,g883,g4897); + dff DFF_292(clk,g1071,g6804); + dff DFF_293(clk,g986,g11473); + dff DFF_294(clk,g971,g11470); + dff DFF_295(clk,g1955,g6338); + dff DFF_296(clk,g143,g7746); + dff DFF_297(clk,g1814,g9825); + dff DFF_298(clk,g1038,g7797); + dff DFF_299(clk,g1212,g1217); + dff DFF_300(clk,g1918,g9353); + dff DFF_301(clk,g782,g8273); + dff DFF_302(clk,g1822,g9826); + dff DFF_303(clk,g237,g7306); + dff DFF_304(clk,g746,g2638); + dff DFF_305(clk,g1062,g7795); + dff DFF_306(clk,g1462,g8438); + dff DFF_307(clk,g178,g7748); + dff DFF_308(clk,g366,g11512); + dff DFF_309(clk,g837,g4184); + dff DFF_310(clk,g599,g9819); + dff DFF_311(clk,g1854,g11408); + dff DFF_312(clk,g944,g11398); + dff DFF_313(clk,g1941,g8287); + dff DFF_314(clk,g170,g8422); + dff DFF_315(clk,g1520,g7334); + dff DFF_316(clk,g686,g9342); + dff DFF_317(clk,g953,g11401); + dff DFF_318(clk,g1958,g6339); + dff DFF_319(clk,g40,g10775); + dff DFF_320(clk,g1765,g3329); + dff DFF_321(clk,g1733,g10882); + dff DFF_322(clk,g1270,g7303); + dff DFF_323(clk,g1610,g6845); + dff DFF_324(clk,g1796,g8280); + dff DFF_325(clk,g1324,g11632); + dff DFF_326(clk,g1540,g7343); + dff DFF_327(clk,g1377,g7312); + dff DFF_328(clk,g1206,g4898); + dff DFF_329(clk,g491,g11332); + dff DFF_330(clk,g1849,g5670); + dff DFF_331(clk,g213,g7313); + dff DFF_332(clk,g1781,g7813); + dff DFF_333(clk,g1900,g9351); + dff DFF_334(clk,g1245,g7298); + dff DFF_335(clk,g108,g11593); + dff DFF_336(clk,g630,g7287); + dff DFF_337(clk,g148,g8427); + dff DFF_338(clk,g833,g4183); + dff DFF_339(clk,g1923,g8285); + dff DFF_340(clk,g936,g8571); + dff DFF_341(clk,g1215,g6315); + dff DFF_342(clk,g1314,g11629); + dff DFF_343(clk,g849,g4187); + dff DFF_344(clk,g1336,g11654); + dff DFF_345(clk,g272,g7763); + dff DFF_346(clk,g1806,g8573); + dff DFF_347(clk,g826,g8568); + dff DFF_348(clk,g1065,g7796); + dff DFF_349(clk,g1887,g8281); + dff DFF_350(clk,g37,g10871); + dff DFF_351(clk,g968,g11406); + dff DFF_352(clk,g1845,g5673); + dff DFF_353(clk,g1137,g6310); + dff DFF_354(clk,g1891,g9350); + dff DFF_355(clk,g1255,g7300); + dff DFF_356(clk,g257,g7753); + dff DFF_357(clk,g874,g9821); + dff DFF_358(clk,g591,g9818); + dff DFF_359(clk,g731,g9347); + dff DFF_360(clk,g636,g8781); + dff DFF_361(clk,g1218,g8276); + dff DFF_362(clk,g605,g9820); + dff DFF_363(clk,g79,g7776); + dff DFF_364(clk,g182,g7749); + dff DFF_365(clk,g950,g11400); + dff DFF_366(clk,g1129,g6308); + dff DFF_367(clk,g857,g4189); + dff DFF_368(clk,g448,g11258); + dff DFF_369(clk,g1828,g9827); + dff DFF_370(clk,g1727,g10880); + dff DFF_371(clk,g1592,g7360); + dff DFF_372(clk,g1703,g6843); + dff DFF_373(clk,g1932,g8286); + dff DFF_374(clk,g1624,g8870); + dff DFF_375(clk,g26,g4885); + dff DFF_376(clk,g1068,g6803); + dff DFF_377(clk,g578,g6286); + dff DFF_378(clk,g440,g11260); + dff DFF_379(clk,g476,g11338); + dff DFF_380(clk,g119,g7745); + dff DFF_381(clk,g668,g9340); + dff DFF_382(clk,g139,g8418); + dff DFF_383(clk,g1149,g6305); + dff DFF_384(clk,g34,g10868); + dff DFF_385(clk,g1848,g7366); + dff DFF_386(clk,g263,g7760); + dff DFF_387(clk,g818,g8274); + dff DFF_388(clk,g1747,g5664); + dff DFF_389(clk,g802,g6802); + dff DFF_390(clk,g275,g7764); + dff DFF_391(clk,g1524,g7338); + dff DFF_392(clk,g1577,g7355); + dff DFF_393(clk,g810,g7786); + dff DFF_394(clk,g391,g11264); + dff DFF_395(clk,g658,g9339); + dff DFF_396(clk,g1386,g7318); + dff DFF_397(clk,g253,g7750); + dff DFF_398(clk,g875,g9822); + dff DFF_399(clk,g1125,g6307); + dff DFF_400(clk,g201,g7304); + dff DFF_401(clk,g1280,g7295); + dff DFF_402(clk,g1083,g6807); + dff DFF_403(clk,g650,g8066); + dff DFF_404(clk,g1636,g8874); + dff DFF_405(clk,g853,g4188); + dff DFF_406(clk,g421,g11270); + dff DFF_407(clk,g762,g6798); + dff DFF_408(clk,g956,g11402); + dff DFF_409(clk,g378,g11441); + dff DFF_410(clk,g1756,g5667); + dff DFF_411(clk,g589,g6297); + dff DFF_412(clk,g841,g4185); + dff DFF_413(clk,g1027,g7798); + dff DFF_414(clk,g1003,g7803); + dff DFF_415(clk,g1403,g8991); + dff DFF_416(clk,g1145,g6312); + dff DFF_417(clk,g1107,g6816); + dff DFF_418(clk,g1223,g8277); + dff DFF_419(clk,g406,g11267); + dff DFF_420(clk,g1811,g11185); + dff DFF_421(clk,g1642,g11183); + dff DFF_422(clk,g1047,g7790); + dff DFF_423(clk,g1654,g10874); + dff DFF_424(clk,g197,g6835); + dff DFF_425(clk,g1595,g7361); + dff DFF_426(clk,g1537,g7342); + dff DFF_427(clk,g727,g8434); + dff DFF_428(clk,g999,g7804); + dff DFF_429(clk,g798,g6801); + dff DFF_430(clk,g481,g11324); + dff DFF_431(clk,g754,g4895); + dff DFF_432(clk,g1330,g11634); + dff DFF_433(clk,g845,g4186); + dff DFF_434(clk,g790,g8567); + dff DFF_435(clk,g1512,g8449); + dff DFF_436(clk,g114,g113); + dff DFF_437(clk,g1490,g8445); + dff DFF_438(clk,g1166,g6300); + dff DFF_439(clk,g1056,g7793); + dff DFF_440(clk,g348,g11506); + dff DFF_441(clk,g868,g874); + dff DFF_442(clk,g1260,g7301); + dff DFF_443(clk,g260,g7756); + dff DFF_444(clk,g131,g8420); + dff DFF_445(clk,g7,g2731); + dff DFF_446(clk,g258,g7754); + dff DFF_447(clk,g521,g11330); + dff DFF_448(clk,g1318,g11630); + dff DFF_449(clk,g1872,g9348); + dff DFF_450(clk,g677,g9341); + dff DFF_451(clk,g582,g6290); + dff DFF_452(clk,g1393,g7320); + dff DFF_453(clk,g1549,g7346); + dff DFF_454(clk,g947,g11399); + dff DFF_455(clk,g1834,g9895); + dff DFF_456(clk,g1598,g7362); + dff DFF_457(clk,g1121,g6306); + dff DFF_458(clk,g1321,g11631); + dff DFF_459(clk,g506,g11335); + dff DFF_460(clk,g546,g11043); + dff DFF_461(clk,g1909,g9352); + dff DFF_462(clk,g755,g6298); + dff DFF_463(clk,g1552,g7347); + dff DFF_464(clk,g584,g6292); + dff DFF_465(clk,g1687,g11042); + dff DFF_466(clk,g1586,g7358); + dff DFF_467(clk,g324,g5648); + dff DFF_468(clk,g1141,g6311); + dff DFF_469(clk,g1570,g4900); + dff DFF_470(clk,g1341,g11655); + dff DFF_471(clk,g1710,g4901); + dff DFF_472(clk,g1645,g11184); + dff DFF_473(clk,g115,g7321); + dff DFF_474(clk,g135,g8419); + dff DFF_475(clk,g525,g11329); + dff DFF_476(clk,g581,g6289); + dff DFF_477(clk,g1607,g7365); + dff DFF_478(clk,g321,g5647); + dff DFF_479(clk,g67,g7782); + dff DFF_480(clk,g1275,g11443); + dff DFF_481(clk,g1311,g11628); + dff DFF_482(clk,g1615,g8868); + dff DFF_483(clk,g382,g11442); + dff DFF_484(clk,g1374,g6825); + dff DFF_485(clk,g266,g7761); + dff DFF_486(clk,g1284,g7294); + dff DFF_487(clk,g1380,g7314); + dff DFF_488(clk,g673,g8428); + dff DFF_489(clk,g1853,g5672); + dff DFF_490(clk,g162,g8424); + dff DFF_491(clk,g411,g11268); + dff DFF_492(clk,g431,g11262); + dff DFF_493(clk,g1905,g8283); + dff DFF_494(clk,g1515,g7333); + dff DFF_495(clk,g1630,g8872); + dff DFF_496(clk,g49,g7774); + dff DFF_497(clk,g991,g7802); + dff DFF_498(clk,g1300,g7291); + dff DFF_499(clk,g339,g11505); + dff DFF_500(clk,g256,g7752); + dff DFF_501(clk,g1750,g5665); + dff DFF_502(clk,g585,g6293); + dff DFF_503(clk,g1440,g8988); + dff DFF_504(clk,g1666,g11035); + dff DFF_505(clk,g1528,g7339); + dff DFF_506(clk,g1351,g11657); + dff DFF_507(clk,g1648,g11181); + dff DFF_508(clk,g127,g8421); + dff DFF_509(clk,g1618,g11611); + dff DFF_510(clk,g1235,g7296); + dff DFF_511(clk,g299,g7772); + dff DFF_512(clk,g435,g11261); + dff DFF_513(clk,g64,g7781); + dff DFF_514(clk,g1555,g7348); + dff DFF_515(clk,g995,g7801); + dff DFF_516(clk,g1621,g8869); + dff DFF_517(clk,g1113,g6313); + dff DFF_518(clk,g643,g8064); + dff DFF_519(clk,g1494,g8446); + dff DFF_520(clk,g1567,g7352); + dff DFF_521(clk,g691,g8430); + dff DFF_522(clk,g534,g11327); + dff DFF_523(clk,g1776,g7812); + dff DFF_524(clk,g569,g10876); + dff DFF_525(clk,g1160,g6302); + dff DFF_526(clk,g1360,g9824); + dff DFF_527(clk,g1050,g7791); + dff DFF_528(clk,g1,g8078); + dff DFF_529(clk,g511,g11336); + dff DFF_530(clk,g1724,g10879); + dff DFF_531(clk,g12,g7337); + dff DFF_532(clk,g1878,g8695); + dff DFF_533(clk,g73,g7784); not NOT_0(I8854,g4500); not NOT_1(g5652,I9117); not NOT_2(I12913,g7845); diff --git a/benchmarks/iscas89/s208.sdc b/benchmarks/iscas89/s208.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s208.sdc +++ b/benchmarks/iscas89/s208.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s27.sdc b/benchmarks/iscas89/s27.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s27.sdc +++ b/benchmarks/iscas89/s27.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s298.sdc b/benchmarks/iscas89/s298.sdc index 64b72fde9..17af5eaff 100644 --- a/benchmarks/iscas89/s298.sdc +++ b/benchmarks/iscas89/s298.sdc @@ -1,14 +1,3 @@ -create_clock -name clk -period 10 {CK} -set_input_delay -clock clk 0 { -G2 -G1 -G0 -} -set_output_delay -clock clk 0 { -G67 -G66 -G133 -G132 -G118 -G117 -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s344.sdc b/benchmarks/iscas89/s344.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s344.sdc +++ b/benchmarks/iscas89/s344.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s349.sdc b/benchmarks/iscas89/s349.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s349.sdc +++ b/benchmarks/iscas89/s349.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s35932.sdc b/benchmarks/iscas89/s35932.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s35932.sdc +++ b/benchmarks/iscas89/s35932.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s382.sdc b/benchmarks/iscas89/s382.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s382.sdc +++ b/benchmarks/iscas89/s382.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s38417.sdc b/benchmarks/iscas89/s38417.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s38417.sdc +++ b/benchmarks/iscas89/s38417.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s38584.sdc b/benchmarks/iscas89/s38584.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s38584.sdc +++ b/benchmarks/iscas89/s38584.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s386.sdc b/benchmarks/iscas89/s386.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s386.sdc +++ b/benchmarks/iscas89/s386.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s400.sdc b/benchmarks/iscas89/s400.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s400.sdc +++ b/benchmarks/iscas89/s400.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s420.sdc b/benchmarks/iscas89/s420.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s420.sdc +++ b/benchmarks/iscas89/s420.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s444.sdc b/benchmarks/iscas89/s444.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s444.sdc +++ b/benchmarks/iscas89/s444.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s510.sdc b/benchmarks/iscas89/s510.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s510.sdc +++ b/benchmarks/iscas89/s510.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s526.sdc b/benchmarks/iscas89/s526.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s526.sdc +++ b/benchmarks/iscas89/s526.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s641.sdc b/benchmarks/iscas89/s641.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s641.sdc +++ b/benchmarks/iscas89/s641.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s713.sdc b/benchmarks/iscas89/s713.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s713.sdc +++ b/benchmarks/iscas89/s713.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s820.sdc b/benchmarks/iscas89/s820.sdc index 1938b97ee..17af5eaff 100644 --- a/benchmarks/iscas89/s820.sdc +++ b/benchmarks/iscas89/s820.sdc @@ -1,44 +1,3 @@ -create_clock -name clk -period 10 {CK} -set_input_delay -clock clk 0 { -VDD -GND -G9 -G8 -G7 -G6 -G5 -G4 -G3 -G2 -G18 -G16 -G15 -G14 -G13 -G12 -G11 -G10 -G1 -G0 -} -set_output_delay -clock clk 0 { -G55 -G53 -G49 -G47 -G45 -G43 -G327 -G325 -G322 -G315 -G312 -G310 -G302 -G300 -G298 -G296 -G292 -G290 -G288 -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s838.sdc b/benchmarks/iscas89/s838.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s838.sdc +++ b/benchmarks/iscas89/s838.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/iscas89/s938.sdc b/benchmarks/iscas89/s938.sdc index 07ddfde7d..17af5eaff 100644 --- a/benchmarks/iscas89/s938.sdc +++ b/benchmarks/iscas89/s938.sdc @@ -1,5 +1,3 @@ -create_clock -name clk -period 10 {clk_i} -set_input_delay -clock clk 0 { -} -set_output_delay -clock clk 0 { -} +create_clock -name clk -period 10 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/opdb/chip_bridge.pickle.sdc b/benchmarks/opdb/chip_bridge.pickle.sdc index 9d9b63b4f..2d2ee1ce7 100644 --- a/benchmarks/opdb/chip_bridge.pickle.sdc +++ b/benchmarks/opdb/chip_bridge.pickle.sdc @@ -1,31 +1,3 @@ -create_clock -name clk -period 10 {chip_clk intcnct_clk} -set_input_delay -clock clk 0 { -rst_n -network_out_3 -network_out_2 -network_out_1 -intcnct_data_in -intcnct_credit_back_out -intcnct_channel_in -data_out_val_3 -data_out_val_2 -data_out_val_1 -data_in_rdy_3 -data_in_rdy_2 -data_in_rdy_1 -async_mux -} -set_output_delay -clock clk 0 { -network_in_3 -network_in_2 -network_in_1 -intcnct_data_out -intcnct_credit_back_in -intcnct_channel_out -data_out_rdy_3 -data_out_rdy_2 -data_out_rdy_1 -data_in_val_3 -data_in_val_2 -data_in_val_1 -} +create_clock -name clk -period 1 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/opdb/chip_bridge.pickle.v b/benchmarks/opdb/chip_bridge.pickle.v index 55d56bd99..965a75a37 100644 --- a/benchmarks/opdb/chip_bridge.pickle.v +++ b/benchmarks/opdb/chip_bridge.pickle.v @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /******************************************************************** * Author: Sam Payne - * + * * Module encapsulates an asynchronus FIFO used for bridging signals * across clock domains, parameters allow for different sized modules * compatible with wide range of frequencies. @@ -36,14 +36,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -module async_fifo +module async_fifo #( parameter DSIZE = 64, parameter ASIZE = 5, parameter MEMSIZE = 16 // should be 2 ^ (ASIZE-1) ) ( - rdata, + rdata, rempty, rclk, ren, @@ -101,7 +101,7 @@ assign g_wptr_next[ASIZE-1:0] = {1'b0, b_wptr_next[ASIZE-1:1]} ^ b_wptr_next[ASI assign g_rptr_next[ASIZE-1:0] = {1'b0, b_rptr_next[ASIZE-1:1]} ^ b_rptr_next[ASIZE-1:0]; //full and empty signals -assign wfull = (g_wptr[ASIZE-1] != g_rsync2[ASIZE-1] ) && +assign wfull = (g_wptr[ASIZE-1] != g_rsync2[ASIZE-1] ) && (g_wptr[ASIZE-2] != g_rsync2[ASIZE-2] ) && (g_wptr[ASIZE-3:0] == g_rsync2[ASIZE-3:0]) || (wreset || rreset); @@ -141,13 +141,13 @@ always @(posedge wclk) begin g_rsync1 <= g_rptr; g_rsync2 <= g_rsync1; - + end endmodule // Copyright (c) 2015 Princeton University // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright @@ -158,7 +158,7 @@ endmodule // * Neither the name of Princeton University nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY PRINCETON UNIVERSITY "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -173,7 +173,7 @@ endmodule // Author: Alexey Lavrov, Tri Nguyen // Description: A simple wrapper to infer Xilinx BRAMs for SRAMs, modified to be synthesizable -module bram_1r1w_wrapper +module bram_1r1w_wrapper #(parameter NAME="", DEPTH=1, ADDR_WIDTH=1, BITMASK_WIDTH=1, DATA_WIDTH=1) ( input wire MEMCLK, @@ -258,12 +258,12 @@ always @ * begin bram_data_in = bram_data_in | (bram_data_in_r & ~WRITE_BIT_MASK_REG); else bram_data_in = bram_data_in | (bram_data_write_read_out_reg & ~WRITE_BIT_MASK_REG); - + // note: DOUT retains value if read enable is not asserted // which is why default value is not set for DOUT if (read_enable_in_reg) begin - DOUTA = bram_data_read_out_reg; + DOUTA = bram_data_read_out_reg; if (rw_conflict_r) begin DOUTA = bram_data_in_r; end @@ -341,7 +341,7 @@ end endmodule // Copyright (c) 2015 Princeton University // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright @@ -352,7 +352,7 @@ endmodule // * Neither the name of Princeton University nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY PRINCETON UNIVERSITY "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -367,7 +367,7 @@ endmodule // Author: Alexey Lavrov, Tri Nguyen // Description: A simple wrapper to infer Xilinx BRAMs for SRAMs -module bram_1rw_wrapper +module bram_1rw_wrapper #(parameter NAME="", DEPTH=1, ADDR_WIDTH=1, BITMASK_WIDTH=1, DATA_WIDTH=1) ( input MEMCLK, @@ -654,14 +654,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //================================================================================================== -module sync_fifo +module sync_fifo #( parameter DSIZE = 64, parameter ASIZE = 5, parameter MEMSIZE = 16 // should be 2 ^ (ASIZE-1) ) ( - rdata, + rdata, empty, clk, ren, @@ -730,7 +730,7 @@ end always @ * begin if (reset) - begin + begin sync_rd_ptr_next = 0; end else if (ren && !empty) @@ -751,7 +751,7 @@ end always @ * begin if (reset) - begin + begin sync_wr_ptr_next = 0; end else if (wval && !full) @@ -782,7 +782,7 @@ begin sync_buf_mem_f[sync_wr_ptr_f] <= wdata; end else - begin + begin sync_buf_mem_f[sync_wr_ptr_f] <= sync_buf_mem_f[sync_wr_ptr_f]; end end @@ -819,9 +819,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /******************************************************************** * Author: Sam Payne - * - * Module encapsulates the off chip receive interface for networks - * 1, 2 and 3. packets received are 64 bits wide, received in 2 + * + * Module encapsulates the off chip receive interface for networks + * 1, 2 and 3. packets received are 64 bits wide, received in 2 * 32-bit payloads. * *******************************************************************/ @@ -938,7 +938,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + // endif PITON_CLKS_PASSTHRU // endif PITON_CLKS_CHIPSET @@ -992,7 +992,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. `timescale 1ns/1ps module chip_bridge_in ( - rst, + rst, wr_clk, rd_clk, async_mux, @@ -1008,7 +1008,7 @@ module chip_bridge_in ( data_from_fpga, data_channel, credit_to_fpga -); +); input rst; input wr_clk; @@ -1398,7 +1398,7 @@ async_credit_fifo( .wval(~(rst) & (| credit_gather) & async_mux), .wdata(credit_gather), .rdata(async_credit_fifo_out), - .wfull(async_credit_fifo_full), + .wfull(async_credit_fifo_full), .rempty(async_credit_empty) ); //endif PITON_PROTO @@ -1430,7 +1430,7 @@ sync_credit_fifo( .wval(~(rst) & (| credit_gather) & ~async_mux), .wdata(credit_gather), .rdata(sync_credit_fifo_out), - .full(sync_credit_fifo_full), + .full(sync_credit_fifo_full), .empty(sync_credit_empty) ); // endif PITON_PROTO @@ -1446,7 +1446,7 @@ assign credit_gather[1] = bout_rdy_2 & bout_val_2; assign credit_gather[2] = bout_rdy_3 & bout_val_3; /**************************************************** - channel side sequential logic + channel side sequential logic ****************************************************/ always@(posedge wr_clk) begin @@ -1454,15 +1454,15 @@ always@(posedge wr_clk) begin // ifndef PITON_PROTO if(rst) begin // endif PITON_PROTO - credit_to_fpga_r <= 3'b000; + credit_to_fpga_r <= 3'b000; end else begin - if(~credit_empty) begin + if(~credit_empty) begin credit_to_fpga_r <= credit_fifo_out; end else - credit_to_fpga_r <= 3'b000; - end + credit_to_fpga_r <= 3'b000; + end end endmodule @@ -1496,7 +1496,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /******************************************************************** * Author: Sam Payne - * + * * Module encapsulates the off chip interface for networks 1, 2 and 3 * channel is 32 bits wide, splitting flits into two parts before send * relies on arbitration logic in chip_net_chooser.v @@ -1615,7 +1615,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + // endif PITON_CLKS_PASSTHRU // endif PITON_CLKS_CHIPSET @@ -1669,7 +1669,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. `timescale 1ns/1ps module chip_bridge_out ( - rst, + rst, wr_clk, rd_clk, async_mux, @@ -1685,7 +1685,7 @@ module chip_bridge_out ( data_to_fpga, data_channel, credit_from_fpga -); +); input rst; input wr_clk; @@ -1773,9 +1773,9 @@ reg [1:0] serial_buffer_channel_dup /* synthesis dont_touch = true */; -assign bin_rdy_1 = ~fifo1_full; -assign bin_rdy_2 = ~fifo2_full; -assign bin_rdy_3 = ~fifo3_full; +assign bin_rdy_1 = ~fifo1_full; +assign bin_rdy_2 = ~fifo2_full; +assign bin_rdy_3 = ~fifo3_full; assign data_to_fpga = serial_buffer_data_f; assign data_channel = serial_buffer_channel; @@ -2017,7 +2017,7 @@ always @(posedge rd_clk) begin end else begin if( channel_to_serial_buffer != 0 && serial_buffer_data_counter == 1) begin - + serial_buffer_data_f <= data_to_serial_buffer[31:0]; serial_buffer_data <= data_to_serial_buffer[63:32]; serial_buffer_channel <= channel_to_serial_buffer; @@ -2036,7 +2036,7 @@ always @(posedge rd_clk) begin serial_buffer_channel_dup <= channel_to_serial_buffer; end end -end +end endmodule /* @@ -2068,9 +2068,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /******************************************************************** * Author: Sam Payne - * + * * Module encapsulates logic used to choose between 3 on chip networks - * based upon round robin ordering factoring in which networks are + * based upon round robin ordering factoring in which networks are * empty and which have been given priority previously * *******************************************************************/ @@ -2133,7 +2133,7 @@ assign data_out = rdy_1 ? din_1 : rdy_2 ? din_2 : rdy_3 ? din_3 : 64'd0; -assign data_channel = select; +assign data_channel = select; assign rdy_1 = (select == 2'b01 && select_counter == 1'b0) ? 1'b1 : 1'b0; assign rdy_2 = (select == 2'b10 && select_counter == 1'b0) ? 1'b1 : 1'b0; @@ -2141,7 +2141,7 @@ assign rdy_3 = (select == 2'b11 && select_counter == 1'b0) ? 1'b1 : 1'b0; assign select = ( (select_counter != 1'b0 ) ) ? select_reg : ( (credit_1 == 9'd255 || ~val_1) && //3 networks full - (credit_2 == 9'd255 || ~val_2) && + (credit_2 == 9'd255 || ~val_2) && (credit_3 == 9'd255 || ~val_3) ) ? 2'b00 : ( (credit_2 == 9'd255 || ~val_2) && //2 networks full (credit_3 == 9'd255 || ~val_3) ) ? 2'b01 : @@ -2186,7 +2186,7 @@ always @(posedge clk) begin select_counter <= 0; end else begin - select_counter <= select_counter + 2'b01; + select_counter <= select_counter + 2'b01; end //update incoming credits @@ -2199,7 +2199,7 @@ always @(posedge clk) begin if(credit_from_fpga[2] & ~(rdy_3 & val_3)) begin credit_3 <= credit_3 - 9'd1; end - + if((credit_1 < 9'd255) && (credit_2 < 9'd255) && (credit_3 < 9'd255) && @@ -2216,7 +2216,7 @@ always @(posedge clk) begin if(~credit_from_fpga[0]) begin credit_1 <= credit_1 + 9'd1; end - end + end if(rdy_2 & val_2) begin sel_23 <= 1; sel_12 <= 0; @@ -2270,13 +2270,12 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -//top level module for chip_send tests +//top level module for chip_send tests //`timescale 1ns/1ps module chip_bridge( rst_n, - chip_clk, - intcnct_clk, + clk, async_mux, network_out_1, network_out_2, @@ -2305,10 +2304,13 @@ module chip_bridge( // dbg_interconnect_data, // dbg_interconnect_channel ); + input clk; input rst_n; -input chip_clk; -input intcnct_clk; +wire chip_clk; +wire intcnct_clk; + assign chip_clk = clk; + assign intcnct_clk = clk; input async_mux; input [63:0] network_out_1; @@ -2346,7 +2348,7 @@ output [2:0] intcnct_credit_back_in; //assign dbg_interconnect_channel = intcnct_channel; chip_bridge_out chip_fpga_out( - .rst(~rst_n), + .rst(~rst_n), .wr_clk(chip_clk), .rd_clk(intcnct_clk), .async_mux(async_mux), @@ -2362,10 +2364,10 @@ chip_bridge_out chip_fpga_out( .data_to_fpga(intcnct_data_out), .data_channel(intcnct_channel_out), .credit_from_fpga(intcnct_credit_back_out) - ); + ); chip_bridge_in chip_fpga_in( - .rst(~rst_n), + .rst(~rst_n), .wr_clk(intcnct_clk), .rd_clk(chip_clk), .async_mux(async_mux), diff --git a/benchmarks/opdb/fpu.pickle.sdc b/benchmarks/opdb/fpu.pickle.sdc index 65d5a322e..2d2ee1ce7 100644 --- a/benchmarks/opdb/fpu.pickle.sdc +++ b/benchmarks/opdb/fpu.pickle.sdc @@ -1,14 +1,3 @@ -create_clock -name clk -period 10 {clk} -set_input_delay -clock clk 0 { -rst_n -pcx_fpio_data_px2_79_72 -pcx_fpio_data_px2_67_0 -pcx_fpio_data_px2_123_118 -pcx_fpio_data_px2_116_112 -l15_fp_rdy -} -set_output_delay -clock clk 0 { -fpu_arb_grant -fpu_arb_data_rdy -fpu_arb_data -} +create_clock -name clk -period 1 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/opdb/gng.pickle.sdc b/benchmarks/opdb/gng.pickle.sdc index b9fe1c132..2d2ee1ce7 100644 --- a/benchmarks/opdb/gng.pickle.sdc +++ b/benchmarks/opdb/gng.pickle.sdc @@ -1,9 +1,3 @@ -create_clock -name clk -period 10 {clk} -set_input_delay -clock clk 0 { -rstn -ce -} -set_output_delay -clock clk 0 { -valid_out -data_out -} +create_clock -name clk -period 1 {clk} +set_input_delay -clock clk -max 0 [all_inputs] +set_output_delay -clock clk -max 0 [all_outputs] diff --git a/benchmarks/plot_bars.py b/benchmarks/plot_bars.py index 673f0062e..b21e6e6d9 100644 --- a/benchmarks/plot_bars.py +++ b/benchmarks/plot_bars.py @@ -132,7 +132,11 @@ def extract(run): adp_d = (data['area'] * data['arrival']) / (data['ref_arrival'] * data['ref_area']) fig, ((nodes, depth, ndp), (area, delay, adp)) = plt.subplots(2,3) +all = np.column_stack((nodes_d, depth_d, area_d, delay_d, ndp_d, adp_d, data['ref_nodes'])) +labels = np.column_stack((data['design'], data['optimization'])) +np.savetxt("all.csv", all, delimiter=",") +np.savetxt("labels.csv", labels, delimiter=",", fmt="%s") width = 0.9 for graph, title, ax, db, label in [ ("nodes", "Nodes", nodes, nodes_d, True), diff --git a/benchmarks/techmapping/tigfet/sclib_tigfet10_hpall_tt_0p70v_25c.db b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpall_tt_0p70v_25c.db new file mode 100644 index 000000000..6621aa086 Binary files /dev/null and b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpall_tt_0p70v_25c.db differ diff --git a/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw12_tt_0p70v_25c.db b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw12_tt_0p70v_25c.db new file mode 100644 index 000000000..bf0af9eb5 Binary files /dev/null and b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw12_tt_0p70v_25c.db differ diff --git a/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw1_tt_0p70v_25c.db b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw1_tt_0p70v_25c.db new file mode 100644 index 000000000..59d71f8b6 Binary files /dev/null and b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw1_tt_0p70v_25c.db differ diff --git a/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw4_tt_0p70v_25c.db b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw4_tt_0p70v_25c.db index fa966d143..93b5ab3ba 100644 Binary files a/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw4_tt_0p70v_25c.db and b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw4_tt_0p70v_25c.db differ diff --git a/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw8_tt_0p70v_25c.db b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw8_tt_0p70v_25c.db new file mode 100644 index 000000000..eda1282ce Binary files /dev/null and b/benchmarks/techmapping/tigfet/sclib_tigfet10_hpnw8_tt_0p70v_25c.db differ diff --git a/branch_cleanup.txt b/branch_cleanup.txt new file mode 100644 index 000000000..112301c60 --- /dev/null +++ b/branch_cleanup.txt @@ -0,0 +1,138 @@ +Orphaned + +srt_multithreating 2019-07-03 10:52:34 -0600 +Really old, unlikely to be useful. + +seq_lut_map, seq_partitions +2019-12-17 14:49:04 -0700 + +srt_tech_mapper +2020-02-12 10:29:20 -0700 +abandoned + +dev 2020-03-11 17:50:09 -0600 +demo - intermediate of dev + +gh-pages 2020-10-29 09:56:08 -0600 +intermediates: +yosys-plugin +yosys_lso +abc-integration +srt_abc + +srtBipartUpdate 2021-01-14 00:06:39 -0700 + +opensta 2021-01-26 10:33:41 -0700 + +lnis-snel_lsoracle/openroad-plugin +looks like rebased. + +lnis-snel_lsoracle/opensta_network +abandoned AIG direct sta integration + +lnissrv_research-lsoracle/by-partition-optimization 2021-05-17 15:45:10 -0600 +abandoned changes in alice parsing + +lnissrv_research-lsoracle/cicd-benchmarks 2021-05-26 15:01:50 -0600 +cicd thrashing + +lnis-snel_lsoracle/dan/techmapper 2021-06-07 14:59:10 +0100 +wip + +origin/timing-resynthesis +probably rebased + +lnis-snel_openroad/master, lnis-snel_openroad/kahypar-config +trash + +lnis-snel_lsoracle/interactive-errors +wip + +lnis-snel_lsoracle/scrub-warnings +trash + +lnis-snel_lsoracle/partition_weighted +two merge commits, probbly rebased + +lnis-snel_lsoracle/partition-command-generics +trash + +lnis-snel_lsoracle/galois-submodule, lnis-snel_lsoracle/kahypar_submodule +wip, trash + +lnis-snel_lsoracle/legacy_cicd_update +trash + +lnis-snel_lsoracle/sap-port +lnis-snel_lsoracle/RedundantOptimizationReduction +lnissrv_research-lsoracle/mockturtle_update +lnis-snel_lsoracle/mockturtle_update +lnis-snel_test/RedundantOptimizationReduction + lnis-snel_lsoracle/whitespace-cleanup +lnissrv_lsoracle-old/master +lnis-snel_lsoracle/test +trash + +origin/RedundantOptimizationReduction +check, is an orphaned merge commit, has a bunch of stuff from nichols + +lnis-snel_lsoracle-xmg/xmg_techmap, lnis-snel_lsoracle-xmg/timing_metrics +trash intermediTe + +lnis-snel_lsoracle/buffer_experiment +probably trash + +old/xmg_techmap, lnissrv_lsoracle-old/xmg_techmap, lnis-snel_lsoracle/xmg_techmap +trash + +old/xmg_techmap, lnissrv_lsoracle-old/xmg_techmap, lnis-snel_lsoracle/xmg_techmap +trash + +origin/srt/for_thierry +maybe something useful + +lnis-snel_lsoracle/master +trash + +origin/new_recipes +stuff from walther to check + +origin/techmapper-general-delay-area +check dan's stuff + + +origin/optimizer_reorg, optimizer_reorg +just a refactor, i think i did it again in another branching + +origin/abc_flag_fix, abc_flag_fix +orphaned, check + +trash +lnis-snel_lsoracle/pragma_once +lnis-snel_lsoracle/timing_final + +timing_final +origin/timing_final + + +origin/timing_metrics +lnis-snel_lsoracle/timing_metrics +lnis-snel_lsoracle/tigfet_benchmarks +origin/tigfet_benchmarks +old/tigfet_benchmarks, lnissrv_lsoracle-old/tigfet_benchmarks, lnis-snel_lsoracle/partition_resynth +trash intermediates + + +* origin/partition_resynth 2022-03-21 14:14:49 -0600 +old/partition_resynth, lnissrv_lsoracle-old/partition_resynth +last is the uncommitted WIP contents + +origin/updt_migtune +* updt_migtune 2022-08-30 13:04:53 -0600 +last is the uncommitted WIP contents + +* origin/master 2022-07-07 12:45:44 -0600 + +* timing 2022-09-12 15:43:43 -0600 +* exploder 2022-08-15 11:46:01 -0600 +stuff i was working on diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 993a3d0da..2f3986361 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -25,7 +25,11 @@ add_custom_command( set(LSORACLE_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/kahypar_config.cpp kahypar_temp_config.cpp + algorithms/optimization/optimizer.cpp + algorithms/optimization/optimizers.cpp algorithms/optimization/resynthesis.cpp + algorithms/optimization/abc.cpp + algorithms/optimization/exploder.cpp utility.cpp ) @@ -45,6 +49,7 @@ endif() set(LSORACLE_TESTS algorithms/partitioning/__tests__/sap_test.cpp algorithms/partitioning/__tests__/partition_manager_junior_test.cpp + algorithms/optimization/__tests__/exploder_test.cpp ) add_executable(unit_tests ${LSORACLE_SOURCE} ${LSORACLE_TESTS}) target_link_libraries(unit_tests gtest_main alice mockturtle kahypar) diff --git a/core/algorithms/optimization/__tests__/exploder_test.cpp b/core/algorithms/optimization/__tests__/exploder_test.cpp new file mode 100644 index 000000000..16f7f9f5a --- /dev/null +++ b/core/algorithms/optimization/__tests__/exploder_test.cpp @@ -0,0 +1,249 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include +#include "algorithms/optimization/exploder.hpp" + +using aig_names = mockturtle::names_view; +using aig_window = mockturtle::window_view; +using aig_exploder = oracle::exploderizer; +using xmg_names = mockturtle::names_view; +using xmg_window = mockturtle::window_view; +using xmg_exploder = oracle::exploderizer; +using mig_names = mockturtle::names_view; +using mig_window = mockturtle::window_view; +using mig_exploder = oracle::exploderizer; +using xag_names = mockturtle::names_view; +using xag_window = mockturtle::window_view; +using xag_exploder = oracle::exploderizer; + +TEST(exploderizer_test, disjoint_cones) +{ + aig_names net; + aig_names::signal pi0 = net.create_pi(); + net.set_name(pi0, "pi0"); + aig_names::signal pi1 = net.create_pi(); + net.set_name(pi1, "pi1"); + aig_names::signal pi2 = net.create_pi(); + net.set_name(pi2, "pi2"); + aig_names::signal pi3 = net.create_pi(); + net.set_name(pi3, "pi3"); + aig_names::signal pi4 = net.create_pi(); + net.set_name(pi4, "pi4"); + aig_names::signal pi5 = net.create_pi(); + net.set_name(pi5, "pi5"); + + aig_names::signal w0 = net.create_nand(pi0, pi1); + net.set_name(w0, "w0"); + aig_names::signal w1 = net.create_and(pi1, pi2); + net.set_name(w1, "w1"); + aig_names::signal w2 = net.create_nand(w0, w1); + net.set_name(w2, "w2"); + uint32_t po0 = net.create_po(w2); + net.set_output_name(po0, "po0"); + + aig_names::signal w3 = net.create_nand(pi3, pi4); + net.set_name(w3, "w3"); + aig_names::signal w4 = net.create_nand(pi4, pi5); + net.set_name(w4, "w4"); + aig_names::signal w5 = net.create_nand(w3, w4); + net.set_name(w5, "w5"); + uint32_t po1 = net.create_po(w5); + net.set_output_name(po1, "po1"); + + aig_exploder boom(net, "yosys-abc"); + + ASSERT_EQ(net.num_gates(), 6); + ASSERT_EQ(net.num_pos(), 2); + ASSERT_EQ(net.num_pis(), 6); + + xmg_names result = boom.exploderize(10); + + ASSERT_EQ(result.num_gates(), 6); + ASSERT_EQ(result.num_pos(), 2); + ASSERT_EQ(result.num_pis(), 6); + mockturtle::write_dot(net, "disjoint_net.dot"); + mockturtle::write_dot(result, "disjoint_result.dot"); + + const auto miter = *mockturtle::miter(net, result); + const auto valid = mockturtle::equivalence_checking(miter); + ASSERT_TRUE(valid && *valid); +} + +TEST(exploderizer_test, strashable_cones) +{ + aig_names net; + aig_names::signal pi0 = net.create_pi(); + net.set_name(pi0, "pi0"); + aig_names::signal pi1 = net.create_pi(); + net.set_name(pi1, "pi1"); + aig_names::signal pi2 = net.create_pi(); + net.set_name(pi2, "pi2"); + aig_names::signal pi3 = net.create_pi(); + net.set_name(pi3, "pi3"); + + aig_names::signal w0 = net.create_nand(pi0, pi1); + net.set_name(w0, "w0"); + aig_names::signal w1 = net.create_nand(pi1, pi2); + net.set_name(w1, "w1"); + aig_names::signal w2 = net.create_nand(pi2, pi3); + net.set_name(w2, "w2"); + aig_names::signal w4 = net.create_and(w0, w1); + net.set_name(w4, "w4"); + aig_names::signal w5 = net.create_nand(w1, w2); + net.set_name(w5, "w5"); + aig_names::signal w6 = net.create_nand(w4, w5); + net.set_name(w6, "w6"); + + uint32_t po0 = net.create_po(w5); + net.set_output_name(po0, "po0"); + uint32_t po1 = net.create_po(w6); + net.set_output_name(po1, "po1"); + + aig_exploder boom(net, "yosys-abc"); + + ASSERT_EQ(net.num_gates(), 6); + ASSERT_EQ(net.num_pos(), 2); + ASSERT_EQ(net.num_pis(), 4); + + xmg_names result = boom.exploderize(10); + + ASSERT_EQ(result.num_pos(), 2); + ASSERT_EQ(result.num_pis(), 4); + mockturtle::write_dot(net, "strash_net.dot"); + mockturtle::write_dot(result, "strash_result.dot"); + + const auto miter = *mockturtle::miter(net, result); + const auto valid = mockturtle::equivalence_checking(miter); + ASSERT_TRUE(valid && *valid); +} + +TEST(exploderizer_test, big_network) +{ + aig_names net; + aig_names::signal pi0 = net.create_pi(); + net.set_name(pi0, "pi0"); + aig_names::signal pi1 = net.create_pi(); + net.set_name(pi1, "pi1"); + aig_names::signal pi2 = net.create_pi(); + net.set_name(pi2, "pi2"); + aig_names::signal pi3 = net.create_pi(); + net.set_name(pi3, "pi3"); + aig_names::signal pi4 = net.create_pi(); + net.set_name(pi4, "pi4"); + aig_names::signal pi5 = net.create_pi(); + net.set_name(pi5, "pi5"); + aig_names::signal pi6 = net.create_pi(); + net.set_name(pi6, "pi6"); + aig_names::signal pi7 = net.create_pi(); + net.set_name(pi7, "pi7"); + aig_names::signal pi8 = net.create_pi(); + net.set_name(pi8, "pi8"); + aig_names::signal pi9 = net.create_pi(); + net.set_name(pi9, "pi9"); + aig_names::signal pi10 = net.create_pi(); + net.set_name(pi10, "pi10"); + aig_names::signal pi11 = net.create_pi(); + net.set_name(pi11, "pi11"); + aig_names::signal pi12 = net.create_pi(); + net.set_name(pi12, "pi12"); + aig_names::signal pi13 = net.create_pi(); // isolated subnet + net.set_name(pi13, "pi13"); + aig_names::signal pi14 = net.create_pi(); // isolated subnet + net.set_name(pi14, "pi14"); + aig_names::signal w0 = net.create_nand(pi0, pi1); + net.set_name(w0, "w0"); + aig_names::signal w1 = net.create_nand(pi4, pi5); + net.set_name(w1, "w1"); + aig_names::signal w2 = net.create_nand(pi2, w1); + net.set_name(w2, "w2"); + aig_names::signal w3 = net.create_nand(w0, pi3); + net.set_name(w3, "w3"); + aig_names::signal w4 = net.create_nand(w0, w3); + net.set_name(w4, "w4"); + aig_names::signal w5 = net.create_nand(pi6, pi7); + net.set_name(w5, "w5"); + aig_names::signal w6 = net.create_nand(pi6, w5); + net.set_name(w6, "w6"); + aig_names::signal w7 = net.create_nand(w2, w6); + net.set_name(w7, "w7"); + aig_names::signal w8 = net.create_nand(pi8, pi9); + net.set_name(w8, "w8"); + aig_names::signal w10 = net.create_nand(pi8, pi11); + net.set_name(w10, "w10"); + aig_names::signal w9 = net.create_nand(w10, pi11); + net.set_name(w9, "w9"); + aig_names::signal w11 = net.create_nand(w4, w7); + net.set_name(w11, "w11"); + aig_names::signal w12 = net.create_nand(w7, w6); + net.set_name(w12, "w12"); + aig_names::signal w13 = net.create_nand(w8, w10); + net.set_name(w13, "w13"); + aig_names::signal w14 = net.create_nand(net.create_not(w6), w13); + net.set_name(w14, "w14"); + aig_names::signal w15 = net.create_nand(w0, w4); + net.set_name(w15, "w15"); + aig_names::signal w16 = net.create_nand(w14, w15); + net.set_name(w16, "w16"); + aig_names::signal w17 = net.create_nand(w9, w14); + net.set_name(w17, "w17"); + aig_names::signal w18 = net.create_nand(pi14, pi13); + net.set_name(w18, "w18"); + + uint32_t po0 = net.create_po(pi10); // PI with PO passthrough only + uint32_t po1 = net.create_po(pi11); // PI with PO passthrough and fanout + uint32_t po2 = net.create_po(pi12); // PI with two PO passthrough only + uint32_t po3 = net.create_po(pi12); // PI with two PO passthrough only + uint32_t po4 = net.create_po(w11); // edge PO from edge gate + uint32_t po5 = net.create_po(net.create_not(w12)); // inverted duplicate PO from edge gate + uint32_t po6 = net.create_po(w12); // duplicate PO from edge gate + uint32_t po7 = net.create_po(w13); // PO for gate with external fanout. + uint32_t po8 = net.create_po(w15); // PO for gate with internal fanout. + uint32_t po9 = net.create_po(w14); // PO for gate with internal and external fanout. + uint32_t po10 = net.create_po(w17); // edge PO from edge gate + uint32_t po11 = net.create_po(w18); // edge PO for isolated subnetwork. + + ASSERT_EQ(net.num_cis(), 15); + ASSERT_EQ(net.num_cos(), 12); + ASSERT_EQ(net.num_gates(), 19); + + aig_exploder boom(net, "yosys-abc"); + xmg_names result = boom.exploderize(10); + + ASSERT_EQ(result.num_cos(), 12); + ASSERT_EQ(result.num_cis(), 15); + mockturtle::write_dot(net, "big_net.dot"); + mockturtle::write_dot(result, "big_result.dot"); + + const auto miter = *mockturtle::miter(net, result); + const auto valid = mockturtle::equivalence_checking(miter); + ASSERT_TRUE(valid && *valid); + +} diff --git a/core/algorithms/optimization/abc.cpp b/core/algorithms/optimization/abc.cpp new file mode 100644 index 000000000..654db81e7 --- /dev/null +++ b/core/algorithms/optimization/abc.cpp @@ -0,0 +1,131 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "algorithms/optimization/abc.hpp" +#include "algorithms/partitioning/partition_manager_junior.hpp" + +namespace oracle +{ + +template std::string get_po_name_or_default(const network &ntk, const typename network::signal &signal) +{ + int index = ntk.po_index(signal); + + if (ntk.has_output_name(index)) { + return ntk.get_output_name(index); + } else { + int digits_out = std::to_string(ntk.num_pos()).length(); + // std::cout << "missing output name for index " << index << std::endl; + return fmt::format("po__{0:0{1}}", index, digits_out); + } +} + +template +std::string get_pi_name_or_default(const network &ntk, const typename network::node &node) +{ + typename network::signal signal = ntk.make_signal(node); + + if (ntk.has_name(signal)) { + return ntk.get_name(signal); + } else { + // std::cout << "missing name for PI node " << node << std::endl; + int digits_in = std::to_string(ntk.num_pis()).length(); + return fmt::format("pi__{0:0{1}}", node, digits_in); + } +} + +template +std::string get_node_name_or_default(const network &ntk, const typename network::node &node) +{ + if (ntk.is_pi(node)) { + return get_pi_name_or_default(ntk, node); + } else { + typename network::signal signal = ntk.make_signal(node); + if (ntk.has_name(signal)) { + return ntk.get_name(signal); + } else { + // std::cout << "missing name for non-PI node " << node << std::endl; + int digits_gate = std::to_string(ntk.num_gates()).length(); + return fmt::format("node__{0:0{1}}", node, digits_gate); + } + } +} + +template +std::string get_ri_name_or_default(const network &ntk, const typename network::signal &signal) +{ + if (ntk.has_name(signal)) { + return ntk.get_name(signal); + } else { + typename network::node node = ntk.get_node(signal); + // std::cout << "missing name for RI node " << node << std::endl; + int digits_in = std::to_string(ntk.num_registers()).length(); + return fmt::format("ri__{0:0{1}}", node, digits_in); + } +} + + template +mockturtle::window_view> fix_names2(partition_manager_junior &partman, int index) +{ + mockturtle::window_view> part = partman.partition(index); + mockturtle::names_view ntk = partman.get_network(); + part.foreach_pi([&part, &ntk](typename network::node n) { + std::string name = get_node_name_or_default(ntk, n); + part.set_name(part.make_signal(n), name); + }); + int feedthrough = 0; + part.foreach_po([&part, &ntk, &feedthrough](typename network::signal s, int i) { + typename network::node n = part.get_node(s); + if (ntk.is_pi(n)) { + feedthrough++; + // skip feedthroughs + return; + } + std::string name = get_node_name_or_default(ntk, n); + part.set_output_name(i, name); + }); + if (feedthrough > 0 ) { + std::cout << "Skipped renaming for " << feedthrough << " feedthrough." << std::endl; + } + return part; +} + + void optimize_abc(oracle::partition_manager_junior &partitions, + const std::string &abc_exec) +{ + for (int i = 0; i < partitions.count(); i++) { + auto orig = fix_names2(partitions, i); + abc_optimizer optimizer(i, orig, optimization_strategy::depth, abc_exec); + optimizer.convert(); + optimizer.optimize(); + mockturtle::names_view optimal = optimizer.optimized(); + partitions.integrate(i, optimal); + } + partitions.substitute_nodes(); +} + +} diff --git a/core/algorithms/optimization/abc.hpp b/core/algorithms/optimization/abc.hpp new file mode 100644 index 000000000..19c6b8b02 --- /dev/null +++ b/core/algorithms/optimization/abc.hpp @@ -0,0 +1,37 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include "algorithms/optimization/optimizers.hpp" +#include "algorithms/partitioning/partition_manager_junior.hpp" +#include "algorithms/optimization/optimizers/abc.hpp" + +namespace oracle +{ +void optimize_abc( + oracle::partition_manager_junior &partitions, const std::string &abc_exec); +} diff --git a/core/algorithms/optimization/aig_script2.hpp b/core/algorithms/optimization/aig_script2.hpp index 060c2da5e..504b015bb 100644 --- a/core/algorithms/optimization/aig_script2.hpp +++ b/core/algorithms/optimization/aig_script2.hpp @@ -24,6 +24,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ +#pragma once #include #include #include diff --git a/core/algorithms/optimization/exploder.cpp b/core/algorithms/optimization/exploder.cpp new file mode 100644 index 000000000..6e13b7f3b --- /dev/null +++ b/core/algorithms/optimization/exploder.cpp @@ -0,0 +1,162 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#include "algorithms/optimization/optimizers.hpp" +#include "exploder.hpp" + +namespace oracle +{ +template typename exploderizer::xmg_names exploderizer::exploderize(uint32_t target_depth) +{ + mockturtle::depth_view depth(ntk); + xmg_names output; + ntk.foreach_pi([&](typename exploderizer::network_names::node pi) { + auto n = output.create_pi(); + auto s = ntk.make_signal( pi ); + if ( ntk.has_name( s ) ) + { + output.set_name (n, ntk.get_name( s ) ); + } + }); + optimization_strategy_comparator *strategy = new depth_strategy; + ntk.foreach_po([&](auto po, auto i) { + auto cone = extract_cone(po); + + assert(cone.num_pos() == 1); + assert(cone.num_pis() == output.num_pis()); + + if (depth.level(ntk.get_node(po)) < target_depth) { + mockturtle::xmg_npn_resynthesis resyn; + xmg_names copy; + mockturtle::node_resynthesis::window>(copy, cone, resyn); + + assert(copy.num_pos() == 1); + assert(copy.num_pis() == output.num_pis()); + + integrate(output, copy); + } else { + std::cout << "********************************" + << " pis " << cone.num_pis() + << " pos " << cone.num_pos() + << " gates " << cone.num_gates() << std::endl; + optimizer *optimized = optimize( + *strategy, + optimization_strategy::depth, + cone, + i, + abc_exec); + xmg_names optim = optimized->export_superset(); + + assert(optim.num_pos() == 1); + assert(optim.num_pis() == output.num_pis()); + + integrate(output, optim); + delete optimized; + std::cout << "******************************** updated result with" + << " pis " << output.num_pis() + << " pos " << output.num_pos() + << " gates " << output.num_gates() << std::endl; + + } + }); + delete strategy; + + return mockturtle::cleanup_dangling(output); +} + +template void exploderizer::integrate(xmg_names &output, xmg_names &optim) +{ + mockturtle::node_map map(optim); + auto topo = mockturtle::topo_view(optim); + topo.foreach_pi([&](auto p, auto i) { + map[p] = output.make_signal(output.pi_at(i)); + }); + topo.foreach_gate([&](auto g) { + std::vector fin; + topo.foreach_fanin(g, [&](const typename xmg_names::signal f){ + if (optim.is_constant(optim.get_node(f))) { + auto fanin = output.get_constant(optim.is_complemented(f)); + fin.push_back(fanin); + } else { + auto mapped = map[f]; + auto fanin = optim.is_complemented(f) ? output.create_not(mapped) : mapped; + fin.push_back(fanin); + } + }); + map[g] = output.clone_node(optim, g, fin); + // output.copy_signal_metadata(map[g], optim, optim.make_signal(g)); + }); + topo.foreach_po([&](const typename xmg_names::signal f) { + auto n = map[topo.get_node(f)]; + uint32_t id; + if (optim.is_complemented(f) != output.is_complemented(n)) { + id = output.create_po(output.create_not(n)); + } else { + id = output.create_po(n); + } + if ( ntk.has_output_name( id ) ) { + output.set_output_name(id, ntk.get_output_name( id ) ); + } + }); +} + +/* + * generate a window of a logic cone, starting at the given signal. + */ +template +const typename exploderizer::window +exploderizer::extract_cone(typename exploderizer::network_names::signal s) +{ + std::vector::network_names::node> gates; + std::vector::network_names::node> inputs; + std::vector::network_names::signal> outputs; + outputs.push_back(s); + + ntk.foreach_pi([&](auto pi) { + // relying on mockturtle guarantee of input order. + inputs.push_back(pi); + }); + std::queue::network_names::node> traverse; + traverse.push(ntk.get_node(s)); + ntk.incr_trav_id(); + uint32_t id = ntk.trav_id(); + while (!traverse.empty()) { + auto t = traverse.front(); + if (ntk.visited(t) != id && !ntk.is_pi(t)) { + gates.push_back(t); + ntk.foreach_fanin(t, [&](auto f) { + traverse.push(ntk.get_node(f)); + }); + } + ntk.set_visited(t, id); + traverse.pop(); + } + return window(ntk, inputs, outputs, gates); +} + +using xmg_names = mockturtle::names_view; +template xmg_names exploderizer::exploderize(uint32_t); +} diff --git a/core/algorithms/optimization/exploder.hpp b/core/algorithms/optimization/exploder.hpp new file mode 100644 index 000000000..8fadb91c2 --- /dev/null +++ b/core/algorithms/optimization/exploder.hpp @@ -0,0 +1,56 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include "algorithms/optimization/optimizers.hpp" + +namespace oracle { + +template +class exploderizer +{ +public: + using network_names = mockturtle::names_view; + using window = mockturtle::window_view>; + using xmg_names = mockturtle::names_view; + + exploderizer(mockturtle::names_view ntk, std::string abc_exec): ntk(ntk), abc_exec(abc_exec) { + } + + xmg_names exploderize(uint32_t target_depth); + + void integrate(xmg_names &output, xmg_names &optim); + + /* + * generate a window of a logic cone, starting at the given signal. + */ + const window extract_cone(typename network_names::signal s); +private: + network_names ntk; + const std::string abc_exec; +}; +}; diff --git a/core/algorithms/optimization/mab.hpp b/core/algorithms/optimization/mab.hpp index 971cea3c9..01e60daf9 100644 --- a/core/algorithms/optimization/mab.hpp +++ b/core/algorithms/optimization/mab.hpp @@ -376,7 +376,7 @@ string abc_stats_commmands(int h, int i, int which_opt) else return ";strash;print_stats;\" | grep \"and =\" > " + to_string(h)+"_"+to_string(i)+".result\n"; //default as AIG minimization */ - + throw; } // generate initial random constrained commands (stored in vector of strings) @@ -691,10 +691,10 @@ float get_results_universe(string resultFile, int which_opt) else res = -1; if (res == -1) - assert(0); + assert(0); else if (res == 0) - return 999999999.0; - else + return 999999999.0; + return res; } @@ -1332,4 +1332,4 @@ void bayes_flow_tune(char const* Design, int repeats, int prefix_pos, int target outfile.close(); return ; } -} \ No newline at end of file +} diff --git a/core/algorithms/optimization/optimizer.cpp b/core/algorithms/optimization/optimizer.cpp new file mode 100644 index 000000000..49d5027f0 --- /dev/null +++ b/core/algorithms/optimization/optimizer.cpp @@ -0,0 +1,65 @@ +#include "algorithms/optimization/optimizers.hpp" +// #include "algorithms/optimization/optimizers/strategy.hpp" +#include "algorithms/optimization/optimizers/noop.hpp" +#include "algorithms/optimization/optimizers/aig.hpp" +#include "algorithms/optimization/optimizers/mig.hpp" +#include "algorithms/optimization/optimizers/xag.hpp" +#include "algorithms/optimization/optimizers/xmg.hpp" +#include "algorithms/optimization/optimizers/abc.hpp" + +namespace oracle { +template +optimizer *optimize(optimization_strategy_comparator &comparator, + optimization_strategy strategy, + mockturtle::window_view> &part, + int index, + const std::string &abc_exec) +{ + std::cout << "******************************** optimizing partition " << index << " ********************************" << std::endl; + std::cout << "Optimizing based on strategy " << comparator.name() << std::endl; + // depth_view part_depth(part); + // std::cout << "Original depth " << part_depth.depth() << " gates " << part_depth.num_gates() << " size " << part_depth.size() << std::endl; + // todo this is gonna leak memory. + std::vector*>optimizers { + new noop(index, part, strategy, abc_exec), + new migscript_optimizer(index, part, strategy, abc_exec), + new migscript2_optimizer(index, part, strategy, abc_exec), + new migscript3_optimizer(index, part, strategy, abc_exec), + new aigscript_optimizer(index, part, strategy, abc_exec), + new aigscript2_optimizer(index, part, strategy, abc_exec), + new aigscript3_optimizer(index, part, strategy, abc_exec), + new aigscript4_optimizer(index, part, strategy, abc_exec), + new aigscript5_optimizer(index, part, strategy, abc_exec), + new xmg_optimizer(index, part, strategy, abc_exec), + new xag_optimizer(index, part, strategy, abc_exec), + // new abc_optimizer(index, part, strategy, abc_exec), + }; + optimizer *best = nullptr; + for (auto opt = optimizers.begin(); opt != optimizers.end(); opt++) { + std::cout << "running optimization " << (*opt)->optimizer_name() << std::endl; + // std::cout << "converting network" << std::endl; + (*opt)->convert(); + // std::cout << "trying to optimize" << std::endl; + (*opt)->optimize(); + // std::cout << "checking tech independent metrics." << std::endl; + node_depth result = (*opt)->independent_metric(); + std::cout << "result depth " << result.depth + << " size " << result.nodes << std::endl; + + if (best == nullptr) { + best = *opt; + continue; + } + + if (comparator(**opt, *best)) { + best = *opt; + //std::cout << "found a better result" << std::endl; + continue; + } + } + std::cout << "using " << best->optimizer_name() << " for " << index << std::endl; + + return best; + +} +}; diff --git a/core/algorithms/optimization/optimizers.cpp b/core/algorithms/optimization/optimizers.cpp new file mode 100644 index 000000000..435fdbd68 --- /dev/null +++ b/core/algorithms/optimization/optimizers.cpp @@ -0,0 +1,95 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#include "algorithms/optimization/optimizers.hpp" +#include "algorithms/optimization/optimizers/aig.hpp" +#include "algorithms/optimization/optimizers/mig.hpp" +#include "algorithms/optimization/optimizers/xag.hpp" +#include "algorithms/optimization/optimizers/xmg.hpp" +#include "algorithms/optimization/optimizers/abc.hpp" +#include "algorithms/optimization/optimizers/noop.hpp" +namespace oracle { +template +optimizer *optimize(optimization_strategy_comparator &comparator, + optimization_strategy strategy, + const mockturtle::window_view> &part, + int index, + const std::string &abc_exec) +{ + std::cout << "******************************** optimizing partition " << index << " ********************************" << std::endl; + std::cout << "Optimizing based on strategy " << comparator.name() << std::endl; + // depth_view part_depth(part); + // std::cout << "Original depth " << part_depth.depth() << " gates " << part_depth.num_gates() << " size " << part_depth.size() << std::endl; + // todo this is gonna leak memory. + std::vector*>optimizers { + new noop(index, part, strategy, abc_exec), + new migscript_optimizer(index, part, strategy, abc_exec), + new migscript2_optimizer(index, part, strategy, abc_exec), + new migscript3_optimizer(index, part, strategy, abc_exec), + new aigscript_optimizer(index, part, strategy, abc_exec), + new aigscript2_optimizer(index, part, strategy, abc_exec), + new aigscript3_optimizer(index, part, strategy, abc_exec), + new aigscript4_optimizer(index, part, strategy, abc_exec), + new aigscript5_optimizer(index, part, strategy, abc_exec), + new xmg_optimizer(index, part, strategy, abc_exec), + new xag_optimizer(index, part, strategy, abc_exec), + new abc_optimizer(index, part, strategy, abc_exec), + }; + optimizer *best = nullptr; + for (auto opt = optimizers.begin(); opt != optimizers.end(); opt++) { + std::cout << "running optimization " << (*opt)->optimizer_name() << std::endl; + // std::cout << "converting network" << std::endl; + (*opt)->convert(); + // std::cout << "trying to optimize" << std::endl; + (*opt)->optimize(); + // std::cout << "checking tech independent metrics." << std::endl; + node_depth result = (*opt)->independent_metric(); + std::cout << "result depth " << result.depth + << " size " << result.nodes << std::endl; + + if (best == nullptr) { + best = *opt; + continue; + } + + if (comparator(**opt, *best)) { + best = *opt; + //std::cout << "found a better result" << std::endl; + continue; + } + } + std::cout << "using " << best->optimizer_name() << " for " << index << std::endl; + + return best; + +} +template optimizer *optimize( + optimization_strategy_comparator &, + optimization_strategy, + const mockturtle::window_view> &, + int, + const std::string &); +} diff --git a/core/algorithms/optimization/optimizers.hpp b/core/algorithms/optimization/optimizers.hpp new file mode 100644 index 000000000..bff94d892 --- /dev/null +++ b/core/algorithms/optimization/optimizers.hpp @@ -0,0 +1,297 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// #include "algorithms/optimization/optimizers/strategy.hpp" +// #include "algorithms/optimization/optimizers/aig.hpp" +// #include "algorithms/optimization/optimizers/mig.hpp" +// #include "algorithms/optimization/optimizers/xag.hpp" +// #include "algorithms/optimization/optimizers/xmg.hpp" +// #include "algorithms/optimization/optimizers/abc.hpp" + +namespace oracle { + +enum optimization_strategy { size, balanced, depth }; + +struct node_depth { + int nodes; + int depth; +}; + +struct area_delay { + double area; + double delay; +}; + +template +class optimizer +{ +public: + /** + * human readable name + */ + virtual const std::string optimizer_name() = 0; + /** + * Do any conversion necessary from original network type to the internal network type. + */ + virtual void convert() = 0; + /** + * Perform optimization + */ + virtual void optimize() = 0; + /** + * Calculate tech independent depth and nodes metrics. + */ + virtual node_depth independent_metric() = 0; + /** + * List the type of optimization: area, delay, or balanced. + */ + virtual optimization_strategy target() = 0; + /** + * Techmap, then return a path to a file containing the techmapped verilog. + */ + virtual std::string techmap(const std::string &liberty_file) = 0; + /** + * convert the network to the superset. + */ + virtual mockturtle::names_view export_superset() = 0; + /** + * Reapply this optimization to a different network. + */ + virtual optimizer *reapply(int index, const mockturtle::window_view> &part) = 0; + virtual std::string get_network_name() = 0; + virtual void reoptimize() = 0; +}; + +template +class optimization_strategy_comparator { +public: + // Comparator function + virtual bool operator()(optimizer &a, optimizer &b) = 0; + virtual const std::string name() = 0; +}; + +template +optimizer *optimize(optimization_strategy_comparator &comparator, + optimization_strategy strategy, + const mockturtle::window_view> &part, + int index, + const std::string &abc_exec); + +template +class node_depth_strategy : public optimization_strategy_comparator +{ + bool operator()(optimizer &a, optimizer &b) + { + node_depth x = a.independent_metric(); + node_depth y = b.independent_metric(); + + return x.nodes * x.depth < y.nodes * y.depth; + } + const std::string name() + { + return "node-depth product"; + } +}; + +template +class depth_strategy : public optimization_strategy_comparator +{ + bool operator()(optimizer &a, optimizer &b) + { + node_depth x = a.independent_metric(); + node_depth y = b.independent_metric(); + + return x.depth < y.depth; + } + const std::string name() + { + return "depth"; + } +}; + + template + class node_strategy : public optimization_strategy_comparator + { + bool operator()(optimizer &a, optimizer &b) + { + node_depth x = a.independent_metric(); + node_depth y = b.independent_metric(); + + return x.nodes < y.nodes; + } + const std::string name() + { + return "node"; + } +}; + +template +class tech_strategy : public optimization_strategy_comparator +{ +public: + tech_strategy(const std::string &liberty_file, const std::string &sdc_file): liberty_file(liberty_file), sdc_file(sdc_file) { + } + + bool operator()(optimizer &a, optimizer &b) + { + sta::Corner *corner = new sta::Corner("tt", 0); + sta::MinMaxAll *minmax = sta::MinMaxAll::all(); + sta::LibertyLibrary *lib = sta::Sta::sta()->readLiberty(liberty_file.c_str(), + corner, + minmax, + true); + + const std::string at = a.techmap(liberty_file); + const std::string bt = b.techmap(liberty_file); + std::string model = a.get_network_name(); + area_delay x = run_timing(lib, at, "picorv32/combinational.sdc", model); + area_delay y = run_timing(lib, bt, "picorv32/combinational.sdc", model); + return compare(x,y); + } +private: + area_delay run_timing(sta::LibertyLibrary *lib, + const std::string &verilog_file, + const std::string &sdc_file, + const std::string design) { + std::cout << "Reading " << design << " from " << verilog_file << std::endl; + bool read_ver = sta::readVerilogFile(verilog_file.c_str(), + sta::Sta::sta()->networkReader()); + assert(read_ver); // << "failed to read verilog"; + bool linked = sta::Sta::sta()->linkDesign(design.c_str()); + assert(linked); // << "Failed to link"; + std::cout << "Attempting to read sdc " << sdc_file << std::endl; + std::string read_sdc = "sta::read_sdc " + sdc_file; + int a = Tcl_Eval(sta::Sta::sta()->tclInterp(), read_sdc.c_str()); + assert(a == 0); + int b = Tcl_Eval(sta::Sta::sta()->tclInterp(), "sta::report_checks > /tmp/test.monkey"); + assert(b == 0); + + std::cout << "running timing" << std::endl; + sta::Slack worst_slack; + sta::Vertex *vertex; + sta::Sta::sta()->worstSlack(sta::MinMax::max(), worst_slack, vertex); + sta::PathRef worst_path_arrival; + sta::PathRef worst_path_slack; + + sta::Sta::sta()->vertexWorstArrivalPath(vertex, sta::MinMax::max(), worst_path_arrival); + sta::Sta::sta()->vertexWorstSlackPath(vertex, sta::MinMax::max(), worst_path_slack); + + sta::ConcreteNetwork *net = reinterpret_cast(sta::Sta::sta()->networkReader()); + sta::ConcreteInstance *top = reinterpret_cast + (net->topInstance()); + sta::CellSeq cells; + sta::PatternMatch *pattern = new sta::PatternMatch("**", false, false, nullptr); + net->findCellsMatching(reinterpret_cast(lib), pattern, &cells); + std::cout << "Number of cells " << cells.size() << std::endl; + double area = 0; + for (sta::Cell *cell: cells) { + sta::ConcreteCell *ce = reinterpret_cast(cell); + sta::LibertyCell *c = ce->libertyCell(); + area += c->area(); + } + std::cout << "Area " << area << std::endl; + + sta::Arrival arrival = worst_path_slack.arrival(sta::Sta::sta()); + // net->clear(); + // net->deleteTopInstance(); + std::cout << "Arrival " << arrival << std::endl; + return { + area, arrival + }; + } + + virtual bool compare(const area_delay &a, const area_delay &b) = 0; + std::string liberty_file; + std::string sdc_file; +}; + +template +class area_delay_strategy : public tech_strategy +{ +public: + area_delay_strategy(const std::string &liberty_file, const std::string &sdc_file): tech_strategy(liberty_file, sdc_file) {} + const std::string name() + { + return "area-delay product"; + } +private: + bool compare(const area_delay &a, const area_delay &b) + { + return a.delay * a.area < b.delay * b.area; + } +}; + +template +class delay_strategy : public tech_strategy +{ +public: + delay_strategy(const std::string &liberty_file, const std::string &sdc_file): tech_strategy(liberty_file, sdc_file) {} + const std::string name() + { + return "depth"; + } +private: + bool compare(const area_delay &a, const area_delay &b) + { + return a.delay < b.delay; + } + +}; + +template +class area_strategy : public tech_strategy +{ +public: + area_strategy(const std::string &liberty_file, const std::string &sdc_file): tech_strategy(liberty_file, sdc_file) {} + const std::string name() + { + return "area"; + } +private: + bool compare(const area_delay &a, const area_delay &b) + { + return a.area < b.area; + } +}; + + +}; diff --git a/core/algorithms/optimization/optimizers/abc.hpp b/core/algorithms/optimization/optimizers/abc.hpp new file mode 100644 index 000000000..0acc9a275 --- /dev/null +++ b/core/algorithms/optimization/optimizers/abc.hpp @@ -0,0 +1,100 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include +#include "algorithms/optimization/optimizers/techmapping.hpp" +#include "algorithms/optimization/optimizers/aig.hpp" + +namespace oracle { + +template< typename network> +class abc_optimizer: public aig_optimizer +{ + using partition = mockturtle::window_view>; +public: + abc_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} + + const std::string optimizer_name() + { + return "abc_resyn2"; + } + + optimizer *reapply(int index, const xmg_partition &part) + { + return new abc_optimizer(index, part, this->strategy, this->abc_exec); + } + + void optimize() + { + std::string blif_name; + if (temp_prefix.empty()) { + char *blif_name_char = strdup("/tmp/lsoracle_XXXXXX.blif"); + if (mkstemps(blif_name_char, 5) == -1) { + throw std::exception(); + } + blif_name = std::string(blif_name_char); + } else { + blif_name = fmt::format("{}.abc_input.blif", temp_prefix); + } + std::cout << "writing blif to " << blif_name << std::endl; + + std::string blif_output_name; + if (temp_prefix.empty()) { + char *blif_output_name_char = strdup("/tmp/lsoracle_XXXXXX_optimized.blif"); + if (mkstemps(blif_output_name_char, 15) == -1) { + throw std::exception(); + } + blif_output_name = std::string(blif_output_name_char); + } else { + blif_output_name = fmt::format("{}.abc_output.blif", temp_prefix); + } + std::cout << "writing abc output to " << blif_output_name << std::endl; + + mockturtle::write_blif_params ps; + ps.skip_feedthrough = 1u; + mockturtle::write_blif(this->converted, blif_name, ps); + std::string script = "abc -c \"read_blif " + blif_name + "; resyn2; write_blif " + blif_output_name + " \""; + int code = system((script).c_str()); + assert(code == 0); + std::cout << "optimized with abc" << std::endl; + + mockturtle::names_view klut; + lorina::return_code read_blif_return_code = lorina::read_blif(blif_output_name, mockturtle::blif_reader(klut)); + assert(read_blif_return_code == lorina::return_code::success); + mockturtle::xag_npn_resynthesis resyn; + mockturtle::node_resynthesis(this->optimal, klut, resyn); + this->optimal.set_network_name(this->converted.get_network_name()); + } + void reoptimize(){ + + } + std::string temp_prefix = ""; + +}; + +}; diff --git a/core/algorithms/optimization/optimizers/aig.hpp b/core/algorithms/optimization/optimizers/aig.hpp new file mode 100644 index 000000000..63a3747c5 --- /dev/null +++ b/core/algorithms/optimization/optimizers/aig.hpp @@ -0,0 +1,284 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include +// #include "config.h" +#include "algorithms/optimization/aig_script.hpp" +#include "algorithms/optimization/aig_script2.hpp" +#include "algorithms/optimization/aig_script3.hpp" +#include "algorithms/optimization/aig_script4.hpp" +#include "algorithms/optimization/aig_script5.hpp" + +#include "algorithms/optimization/optimizers/techmapping.hpp" + +namespace oracle { + using xmg_names = mockturtle::names_view; + using aig_names = mockturtle::names_view; + using xmg_partition = mockturtle::window_view>; + +template +class aig_optimizer: public optimizer +{ + using partition = mockturtle::window_view>; + +public: + aig_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) + { + } + + std::string get_network_name() + { + return "partition_" + std::to_string(index); + } + + xmg_names export_superset() + { + mockturtle::direct_resynthesis resyn; + return mockturtle::node_resynthesis(optimal, resyn); + } + + void convert() + { + mockturtle::xag_npn_resynthesis resyn; + converted = mockturtle::node_resynthesis (original, resyn); + converted.set_network_name("partition_" + std::to_string(index)); + } + + aig_names optimized() + { + return optimal; + } + + node_depth independent_metric() + { + mockturtle::depth_view part_aig_opt_depth{optimal}; + int aig_opt_size = optimal.num_gates(); + int aig_opt_depth = part_aig_opt_depth.depth(); + metric = node_depth{aig_opt_size, aig_opt_depth}; + return metric; + } + + std::string techmap(const std::string &liberty_file) + { + if (techmapped.empty()) { + + std::string script = + "read_lib " + liberty_file + + "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; + techmapped = basic_techmap (script, abc_exec, optimal); + } + return techmapped; + } + + optimization_strategy target() + { + return strategy; + } +protected: + int index; + partition original; + aig_names optimal; + aig_names converted; + node_depth metric; + std::string techmapped; + optimization_strategy strategy; + const std::string &abc_exec; +}; +template class aig_optimizer; + + + +template +class aigscript_optimizer: public aig_optimizer +{ + using partition = mockturtle::window_view>; + using xmg_partition = mockturtle::window_view>; +public: + aigscript_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} + + optimizer *reapply(int index, const xmg_partition &part) + { + return new aigscript_optimizer(index, part, this->strategy, this->abc_exec); + } + + const std::string optimizer_name() + { + return "aigscript"; + } + + void optimize() + { + oracle::aig_script opt; + this->optimal = opt.run(this->converted); + } + void reoptimize(){ + oracle::aig_script opt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + } +}; + +template +class aigscript2_optimizer: public aig_optimizer +{ + using partition = mockturtle::window_view>; +public: + aigscript2_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} + + optimizer *reapply(int index, const xmg_partition &part) + { + return new aigscript2_optimizer(index, part, this->strategy, this->abc_exec); + } + + const std::string optimizer_name() + { + return "aigscript2"; + } + + void optimize() + { + oracle::aig_script2 opt; + this->optimal = opt.run(this->converted); + } + void reoptimize(){ + oracle::aig_script opt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + } +}; + +template +class aigscript3_optimizer: public aig_optimizer +{ + using partition = mockturtle::window_view>; +public: + aigscript3_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} + + optimizer *reapply(int index, const xmg_partition &part) + { + return new aigscript3_optimizer(index, part, this->strategy, this->abc_exec); + } + + const std::string optimizer_name() + { + return "aigscript3"; + } + + void optimize() + { + oracle::aig_script3 opt; + this->optimal = opt.run(this->converted); + } + void reoptimize(){ + oracle::aig_script3 opt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + } +}; + +template +class aigscript4_optimizer: public aig_optimizer +{ + using partition = mockturtle::window_view>; +public: + aigscript4_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} + + optimizer *reapply(int index, const xmg_partition &part) + { + return new aigscript4_optimizer(index, part, this->strategy, this->abc_exec); + } + + const std::string optimizer_name() + { + return "aigscript4"; + } + + void optimize() + { + oracle::aig_script4 opt; + this->optimal = opt.run(this->converted); + } + void reoptimize(){ + oracle::aig_script4 opt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + } + +}; + +template +class aigscript5_optimizer: public aig_optimizer +{ + using partition = mockturtle::window_view>; +public: + aigscript5_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} + + optimizer *reapply(int index, const xmg_partition &part) + { + return new aigscript5_optimizer(index, part, this->strategy, this->abc_exec); + } + + const std::string optimizer_name() + { + return "aigscript5"; + } + + void optimize() + { + oracle::aig_script5 opt; + this->optimal = opt.run(this->converted); + } + void reoptimize(){ + oracle::aig_script5 opt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + } + std::string temp_prefix = ""; + +}; +}; diff --git a/core/algorithms/optimization/optimizers/mig.hpp b/core/algorithms/optimization/optimizers/mig.hpp new file mode 100644 index 000000000..e945d10d1 --- /dev/null +++ b/core/algorithms/optimization/optimizers/mig.hpp @@ -0,0 +1,218 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include +// #include "config.h" + +#include "algorithms/optimization/optimizers/techmapping.hpp" +#include "algorithms/optimization/mig_script.hpp" +#include "algorithms/optimization/mig_script2.hpp" +#include "algorithms/optimization/mig_script3.hpp" + +namespace oracle { +template +class mig_optimizer: public optimizer +{ + using names = mockturtle::names_view; + using partition = mockturtle::window_view; + using manager = mockturtle::window_view; + +public: + mig_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) + { + } + + std::string get_network_name() + { + return "partition_" + std::to_string(index); + } + + xmg_names export_superset() + { + mockturtle::direct_resynthesis resyn; + return mockturtle::node_resynthesis + (optimal, resyn); + } + + void convert() + { + // mockturtle::mig_npn_resynthesis resyn; + mockturtle::direct_resynthesis resyn; + converted = + mockturtle::node_resynthesis>> + (original, resyn); + converted.set_network_name("partition_" + std::to_string(index)); + + } + + mig_names optimized() + { + return optimal; + } + + node_depth independent_metric() + { + mockturtle::depth_view part_mig_opt_depth{optimal}; + int mig_opt_size = optimal.num_gates(); + int mig_opt_depth = part_mig_opt_depth.depth(); + metric = node_depth{mig_opt_size, mig_opt_depth}; + return metric; + } + + std::string techmap(const std::string &liberty_file) + { + if (techmapped.empty()) { + std::string script = + "read_lib " + liberty_file + + "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; + techmapped = basic_techmap (script, abc_exec, optimal); + } + return techmapped; + } + + optimization_strategy target() + { + return strategy; + } +protected: + int index; + partition original; + mig_names optimal; + mig_names converted; + node_depth metric; + std::string techmapped; + std::string name; + optimization_strategy strategy; + const std::string &abc_exec; +}; +template class mig_optimizer; + +template +class migscript_optimizer: public mig_optimizer +{ + using partition = mockturtle::window_view>; +public: + migscript_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): mig_optimizer(index, original, target, abc_exec) {} + + const std::string optimizer_name() + { + return "migscript"; + } + + optimizer *reapply(int index, const xmg_partition &part) + { + return new migscript_optimizer(index, part, this->strategy, this->abc_exec); + } + + void optimize() + { + oracle::mig_script migopt; + this->optimal = migopt.run(this->converted); + } + void reoptimize(){ + oracle::mig_script migopt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = migopt.run(this->optimal); + } + } + +}; + +template +class migscript2_optimizer: public mig_optimizer +{ + using partition = mockturtle::window_view>; +public: + migscript2_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): mig_optimizer(index, original, target, abc_exec) {} + + const std::string optimizer_name() + { + return "migscript2"; + } + + optimizer *reapply(int index, const xmg_partition &part) + { + return new migscript2_optimizer(index, part, this->strategy, this->abc_exec); + } + + void optimize() + { + oracle::mig_script2 migopt; + this->optimal = migopt.run(this->converted); + + } + void reoptimize(){ + oracle::mig_script2 migopt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = migopt.run(this->optimal); + } + } +}; + +template +class migscript3_optimizer: public mig_optimizer +{ + using partition = mockturtle::window_view>; +public: + migscript3_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): mig_optimizer(index, original, target, abc_exec) {} + + optimizer *reapply(int index, const xmg_partition &part) + { + return new migscript3_optimizer(index, part, this->strategy, this->abc_exec); + } + + const std::string optimizer_name() + { + return "migscript3"; + } + + void optimize() + { + oracle::mig_script3 migopt; + this->optimal = migopt.run(this->converted); + } + void reoptimize(){ + oracle::mig_script3 migopt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = migopt.run(this->optimal); + } + + } + std::string temp_prefix = ""; + +}; +}; diff --git a/core/algorithms/optimization/optimizers/noop.hpp b/core/algorithms/optimization/optimizers/noop.hpp new file mode 100644 index 000000000..80a12a478 --- /dev/null +++ b/core/algorithms/optimization/optimizers/noop.hpp @@ -0,0 +1,135 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include "algorithms/optimization/optimizers.hpp" +#include "algorithms/optimization/optimizers/techmapping.hpp" + +namespace oracle { + +template +class noop: public optimizer +{ + using names = mockturtle::names_view; + using partition = mockturtle::window_view; + using xmg_names = mockturtle::names_view; + using xmg_partition = mockturtle::window_view; + // using manager = partition_manager_junior; + +public: + noop(int index, const partition &part, optimization_strategy target, const std::string &abc_exec): index(index), original(part), strategy(target), abc_exec(abc_exec) + { + } + + const std::string optimizer_name() + { + return "noop"; + } + + std::string get_network_name() + { + return "partition_" + std::to_string(index); + } + + + optimizer *reapply(int index, const xmg_partition &part) + { + return new noop(index, part, this->strategy, this->abc_exec); + } + + + // mockturtle::window_view> partition() + // { + // return partman.create_part(ntk, index); + // } + + optimization_strategy target() + { + return strategy; + } + + xmg_names export_superset() + { + mockturtle::direct_resynthesis resyn; + return mockturtle::node_resynthesis(copy, resyn); + } + + /* + * Do direct resynthesis to create a copy. + */ + void convert() + { + // partition original = partman.partition(index); + // // original.set_network_name("partition_" + std::to_string(index)); // TODO not working? + mockturtle::direct_resynthesis resyn; + copy = mockturtle::node_resynthesis (original, resyn); + copy.set_network_name("partition_" + std::to_string(index)); + } + + names optimized() + { + return copy; + } + + void optimize() + { + } + void reoptimize(){ + } + + std::string techmap(const std::string &liberty_file) + { + if (techmapped.empty()) { + std::string script = + "read_lib " + liberty_file + + "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c;"; + techmapped = basic_techmap(script, abc_exec, copy); + } + return techmapped; + } + + node_depth independent_metric() + { + mockturtle::depth_view part_depth(copy); + int opt_size = part_depth.num_gates(); + int opt_depth = part_depth.depth(); + metric = node_depth{opt_size, opt_depth}; + return metric; + } +private: + int index; + partition original; + names copy; + node_depth metric; + optimization_strategy strategy; + std::string techmapped; + const std::string &abc_exec; +}; +template class noop; +template class noop; +template class noop; +template class noop; +}; diff --git a/core/algorithms/optimization/optimizers/techmapping.hpp b/core/algorithms/optimization/optimizers/techmapping.hpp new file mode 100644 index 000000000..c5217067b --- /dev/null +++ b/core/algorithms/optimization/optimizers/techmapping.hpp @@ -0,0 +1,92 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include + +namespace oracle { +using xmg_names = mockturtle::names_view; +using aig_names = mockturtle::names_view; +using mig_names = mockturtle::names_view; +using xag_names = mockturtle::names_view; + +template +std::string basic_techmap(const std::string &tech_script, const std::string &abc_exec, const T &optimal) +{ + std::string temp_prefix = ""; + std::cout << "starting basic techmapping" << std::endl; + std::string input_blif, output_verilog, abc_script; + if (temp_prefix.empty()) { + char *blif = strdup("/tmp/lsoracle_XXXXXX.blif"); + if (mkstemps(blif, 5) == -1) { + throw std::exception(); + } + input_blif = std::string(blif); + + char *verilog = strdup("/tmp/lsoracle_XXXXXX.v"); + if (mkstemps(verilog, 2) == -1) { + throw std::exception(); + } + output_verilog = std::string(verilog); + + char *abc = strdup("/tmp/lsoracle_XXXXXX.abc"); + if (mkstemps(abc, 4) == -1) { + throw std::exception(); + } + abc_script = std::string(abc); + } else { + input_blif = fmt::format("{}.tech.blif", temp_prefix); + output_verilog = fmt::format("{}.tech.v", temp_prefix); + abc_script = fmt::format("{}.tech.abc", temp_prefix); + } + + std::cout << "generated blif " << input_blif << std::endl; + std::cout << "writing output to " << output_verilog << std::endl; + std::cout << "generated ABC script " << abc_script << std::endl; + std::cout << "writing module " << optimal.get_network_name() << std::endl; + + std::ofstream script(abc_script); + script << "print_fanio; " << tech_script << "; print_fanio;" << std::endl; + script.close(); + std::cout << "calling ABC" << std::endl; + mockturtle::write_blif_params ps; + ps.skip_feedthrough = 1u; + mockturtle::write_blif(optimal, input_blif, ps); + int code = system((abc_exec + " -F " + abc_script + + " -o " + output_verilog + + " " + input_blif).c_str()); + assert(code == 0); + std::cout << "done techmapping" << std::endl; + // TODO close everything + return output_verilog; +}; +template std::string basic_techmap(const std::string &, const std::string &, const aig_names &); +template std::string basic_techmap(const std::string &, const std::string &, const xag_names &); +template std::string basic_techmap(const std::string &, const std::string &, const mig_names &); +template std::string basic_techmap(const std::string &, const std::string &, const xmg_names &); + +}; diff --git a/core/algorithms/optimization/optimizers/xag.hpp b/core/algorithms/optimization/optimizers/xag.hpp new file mode 100644 index 000000000..2a1dad960 --- /dev/null +++ b/core/algorithms/optimization/optimizers/xag.hpp @@ -0,0 +1,134 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +namespace oracle { +#include +#include +// #include "config.h" +extern std::string temp_prefix; + +#include "algorithms/optimization/optimizers/techmapping.hpp" +#include "algorithms/optimization/xag_script.hpp" + +template +class xag_optimizer: public optimizer +{ + using partition = mockturtle::window_view>; +public: + xag_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) + { + } + + std::string get_network_name() + { + return "partition_" + std::to_string(index); + } + + xmg_names export_superset() + { + mockturtle::direct_resynthesis resyn; + return mockturtle::node_resynthesis(optimal, resyn); + } + + optimizer *reapply(int index, const xmg_partition &part) + { + return new xag_optimizer(index, part, this->strategy, this->abc_exec); + } + + void convert() + { + mockturtle::xag_npn_resynthesis resyn; + converted = mockturtle::node_resynthesis (original, resyn); + converted.set_network_name("partition_" + std::to_string(index)); + } + + xag_names optimized() + { + return optimal; + } + + node_depth independent_metric() + { + mockturtle::depth_view part_xag_opt_depth{optimal}; + int xag_opt_size = optimal.num_gates(); + int xag_opt_depth = part_xag_opt_depth.depth(); + metric = node_depth{xag_opt_size, xag_opt_depth}; + return metric; + } + + std::string techmap(const std::string &liberty_file) + { + if (techmapped.empty()) { + + std::string script = + "read_lib " + liberty_file + + "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; + techmapped = basic_techmap (script, abc_exec, optimal); + } + return techmapped; + } + + const std::string optimizer_name() + { + return "xagscript"; + } + + void optimize() + { + oracle::xag_script opt; + this->optimal = opt.run(this->converted); + this->optimal.set_network_name(this->original.get_network_name()); + } + + void reoptimize(){ + oracle::xag_script opt; + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + + } + optimization_strategy target() + { + return strategy; + } + +protected: + int index; + partition original; + xag_names optimal; + xag_names converted; + node_depth metric; + std::string techmapped; + optimization_strategy strategy; + const std::string &abc_exec; +}; +template class xag_optimizer; + +} diff --git a/core/algorithms/optimization/optimizers/xmg.hpp b/core/algorithms/optimization/optimizers/xmg.hpp new file mode 100644 index 000000000..28f81c300 --- /dev/null +++ b/core/algorithms/optimization/optimizers/xmg.hpp @@ -0,0 +1,132 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#include +#include +// #include "config.h" +extern std::string temp_prefix; +#include "algorithms/optimization/optimizers/techmapping.hpp" +#include "algorithms/optimization/xmg_script.hpp" + +namespace oracle { +template +class xmg_optimizer: public optimizer +{ + using partition = mockturtle::window_view>; +public: + xmg_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) + { + } + + std::string get_network_name() + { + return "partition_" + std::to_string(index); + } + + optimizer *reapply(int index, const xmg_partition &part) + { + return new xmg_optimizer(index, part, this->strategy, this->abc_exec); + } + + xmg_names export_superset() + { + mockturtle::direct_resynthesis resyn; + return mockturtle::node_resynthesis(optimal, resyn); + } + + void convert() + { + mockturtle::xmg_npn_resynthesis resyn; + converted = mockturtle::node_resynthesis(original, resyn); + converted.set_network_name("partition_" + std::to_string(index)); + } + + xmg_names optimized() + { + return optimal; + } + + node_depth independent_metric() + { + mockturtle::depth_view part_xmg_opt_depth{optimal}; + int xmg_opt_size = optimal.num_gates(); + int xmg_opt_depth = part_xmg_opt_depth.depth(); + metric = node_depth{xmg_opt_size, xmg_opt_depth}; + return metric; + } + + std::string techmap(const std::string &liberty_file) + { + if (techmapped.empty()) { + std::string script = + "read_lib " + liberty_file + + "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; + techmapped = basic_techmap (script, abc_exec, optimal); + } + return techmapped; + } + + const std::string optimizer_name() + { + return "xmgscript"; + } + + void optimize() + { + xmg_script opt; + this->optimal = opt.run(this->converted); + + } + + void reoptimize(){ + xmg_script opt; + int a = this->optimal.num_gates(); + if (this->optimal.num_gates() == 0){ + optimize(); + } + else{ + this->optimal = opt.run(this->optimal); + } + } + + optimization_strategy target() + { + return strategy; + } + +protected: + int index; + partition original; + xmg_names optimal; + xmg_names converted; + node_depth metric; + std::string techmapped; + optimization_strategy strategy; + const std::string &abc_exec; +}; +template class xmg_optimizer; +}; diff --git a/core/algorithms/optimization/resynthesis.cpp b/core/algorithms/optimization/resynthesis.cpp index 8cff58db0..a8b3f0547 100644 --- a/core/algorithms/optimization/resynthesis.cpp +++ b/core/algorithms/optimization/resynthesis.cpp @@ -57,18 +57,10 @@ extern int Sta_Init(Tcl_Interp *interp); #include #include #include "algorithms/optimization/resynthesis.hpp" -#include "algorithms/optimization/mig_script.hpp" -#include "algorithms/optimization/mig_script2.hpp" -#include "algorithms/optimization/mig_script3.hpp" -#include "algorithms/optimization/aig_script.hpp" -#include "algorithms/optimization/aig_script2.hpp" -#include "algorithms/optimization/aig_script3.hpp" -#include "algorithms/optimization/aig_script4.hpp" -#include "algorithms/optimization/aig_script5.hpp" -#include "algorithms/optimization/xag_script.hpp" -#include "algorithms/optimization/xmg_script.hpp" #include "algorithms/partitioning/slack_view.hpp" #include "utility.hpp" +#include "algorithms/optimization/optimizers.hpp" + // TODO replace "pi/po" with "ci/co" namespace oracle { @@ -80,8 +72,9 @@ using xmg_manager = partition_manager_junior; using xmg_partition = mockturtle::window_view>; template -std::string basic_techmap(const std::string &tech_script, const std::string &abc_exec, const T &optimal, const std::string &temp_prefix) +std::string basic_techmap(const std::string &tech_script, const std::string &abc_exec, const T &optimal) { + std::string temp_prefix = ""; std::cout << "starting basic techmapping" << std::endl; std::string input_blif, output_verilog, abc_script; if (temp_prefix.empty()) { @@ -127,10 +120,10 @@ std::string basic_techmap(const std::string &tech_script, const std::string &abc // TODO close everything return output_verilog; }; -template std::string basic_techmap(const std::string &, const std::string &, const aig_names &, const std::string &); -template std::string basic_techmap(const std::string &, const std::string &, const xag_names &, const std::string &); -template std::string basic_techmap(const std::string &, const std::string &, const mig_names &, const std::string &); -template std::string basic_techmap(const std::string &, const std::string &, const xmg_names &, const std::string &); +template std::string basic_techmap(const std::string &, const std::string &, const aig_names &); +template std::string basic_techmap(const std::string &, const std::string &, const xag_names &); +template std::string basic_techmap(const std::string &, const std::string &, const mig_names &); +template std::string basic_techmap(const std::string &, const std::string &, const xmg_names &); template std::string get_po_name_or_default(const network &ntk, const typename network::signal &signal) { @@ -237,763 +230,10 @@ mockturtle::window_view> fix_names2(partition_ma if (feedthrough > 0 ) { std::cout << "Skipped renaming for " << feedthrough << " feedthrough." << std::endl; } + part.set_network_name("partition_" + std::to_string(index)); return part; } -template -class noop: public optimizer -{ - using names = mockturtle::names_view; - using partition = mockturtle::window_view; - // using manager = partition_manager_junior; - -public: - noop(int index, const partition &part, optimization_strategy target, const std::string &abc_exec): index(index), original(part), strategy(target), abc_exec(abc_exec) - { - } - - const std::string optimizer_name() - { - return "noop"; - } - - - optimizer *reapply(int index, const xmg_partition &part) - { - return new noop(index, part, this->strategy, this->abc_exec); - } - - - // mockturtle::window_view> partition() - // { - // return partman.create_part(ntk, index); - // } - - optimization_strategy target() - { - return strategy; - } - - xmg_names export_superset() - { - mockturtle::direct_resynthesis resyn; - return mockturtle::node_resynthesis(copy, resyn); - } - - /* - * Do direct resynthesis to create a copy. - */ - void convert() - { - // partition original = partman.partition(index); - // // original.set_network_name("partition_" + std::to_string(index)); // TODO not working? - mockturtle::direct_resynthesis resyn; - copy = mockturtle::node_resynthesis (original, resyn); - copy.set_network_name("partition_" + std::to_string(index)); - } - - names optimized() - { - return copy; - } - - void optimize() - { - } - - std::string techmap(const std::string &liberty_file, const std::string &temp_prefix) - { - if (techmapped.empty()) { - string script = - "read_lib " + liberty_file + - "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c;"; - techmapped = basic_techmap(script, abc_exec, copy, temp_prefix); - } - return techmapped; - } - - node_depth independent_metric() - { - mockturtle::depth_view part_depth(copy); - int opt_size = part_depth.num_gates(); - int opt_depth = part_depth.depth(); - metric = node_depth{opt_size, opt_depth}; - return metric; - } -private: - int index; - partition original; - names copy; - node_depth metric; - optimization_strategy strategy; - std::string techmapped; - const std::string &abc_exec; -}; -template class noop; -template class noop; -template class noop; -template class noop; - -template -class mig_optimizer: public optimizer -{ - using names = mockturtle::names_view; - using partition = mockturtle::window_view; - using manager = mockturtle::window_view; - -public: - mig_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) - { - } - - xmg_names export_superset() - { - mockturtle::direct_resynthesis resyn; - return mockturtle::node_resynthesis - (optimal, resyn); - } - - void convert() - { - // mockturtle::mig_npn_resynthesis resyn; - mockturtle::direct_resynthesis resyn; - converted = - mockturtle::node_resynthesis>> - (original, resyn); - converted.set_network_name("partition_" + std::to_string(index)); - - } - - mig_names optimized() - { - return optimal; - } - - node_depth independent_metric() - { - mockturtle::depth_view part_mig_opt_depth{optimal}; - int mig_opt_size = optimal.num_gates(); - int mig_opt_depth = part_mig_opt_depth.depth(); - metric = node_depth{mig_opt_size, mig_opt_depth}; - return metric; - } - - std::string techmap(const std::string &liberty_file, const std::string &temp_prefix) - { - if (techmapped.empty()) { - string script = - "read_lib " + liberty_file + - "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; - techmapped = basic_techmap (script, abc_exec, optimal, temp_prefix); - } - return techmapped; - } - - optimization_strategy target() - { - return strategy; - } -protected: - int index; - partition original; - mig_names optimal; - mig_names converted; - node_depth metric; - string techmapped; - string name; - optimization_strategy strategy; - const std::string &abc_exec; -}; -template class mig_optimizer; - -template -class aig_optimizer: public optimizer -{ - using partition = mockturtle::window_view>; -public: - aig_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) - { - } - - xmg_names export_superset() - { - mockturtle::direct_resynthesis resyn; - return mockturtle::node_resynthesis(optimal, resyn); - } - - void convert() - { - mockturtle::xag_npn_resynthesis resyn; - converted = mockturtle::node_resynthesis (original, resyn); - converted.set_network_name("partition_" + std::to_string(index)); - } - - aig_names optimized() - { - return optimal; - } - - node_depth independent_metric() - { - mockturtle::depth_view part_aig_opt_depth{optimal}; - int aig_opt_size = optimal.num_gates(); - int aig_opt_depth = part_aig_opt_depth.depth(); - metric = node_depth{aig_opt_size, aig_opt_depth}; - return metric; - } - - std::string techmap(const std::string &liberty_file, const std::string &temp_prefix) - { - if (techmapped.empty()) { - - string script = - "read_lib " + liberty_file + - "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; - techmapped = basic_techmap ( - script, abc_exec, optimal, temp_prefix); - } - return techmapped; - } - - optimization_strategy target() - { - return strategy; - } -protected: - int index; - partition original; - aig_names optimal; - aig_names converted; - node_depth metric; - string techmapped; - optimization_strategy strategy; - const std::string &abc_exec; -}; -template class aig_optimizer; - - -template< typename network> -class abc_optimizer: public aig_optimizer -{ - using partition = mockturtle::window_view>; -public: - abc_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} - - const std::string optimizer_name() - { - return "abc resyn2"; - } - - optimizer *reapply(int index, const xmg_partition &part) - { - return new abc_optimizer(index, part, this->strategy, this->abc_exec); - } - - void optimize() - { - char *blif_name_char = strdup("/tmp/lsoracle_XXXXXX.blif"); - if (mkstemps(blif_name_char, 5) == -1) { - throw std::exception(); - } - std::string blif_name = std::string(blif_name_char); - std::cout << "writing blif to " << blif_name << std::endl; - - char *blif_output_name_char = strdup("/tmp/lsoracle_XXXXXX_optimized.blif"); - if (mkstemps(blif_output_name_char, 15) == -1) { - throw std::exception(); - } - std::string blif_output_name = std::string(blif_output_name_char); - std::cout << "writing abc output to " << blif_output_name << std::endl; - - mockturtle::write_blif_params ps; - ps.skip_feedthrough = 1u; - mockturtle::write_blif(this->converted, blif_name, ps); - std::string script = "abc -c \"read_blif " + blif_name + "; resyn2; write_blif " + blif_output_name + " \""; - int code = system((script).c_str()); - assert(code == 0); - std::cout << "optimized with abc" << std::endl; - - mockturtle::names_view klut; - lorina::return_code read_blif_return_code = lorina::read_blif(blif_output_name, mockturtle::blif_reader(klut)); - assert(read_blif_return_code == lorina::return_code::success); - mockturtle::xag_npn_resynthesis resyn; - mockturtle::node_resynthesis(this->optimal, klut, resyn); - this->optimal.set_network_name(this->converted.get_network_name()); - } -}; - -template -class xag_optimizer: public optimizer -{ - using partition = mockturtle::window_view>; -public: - xag_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) - { - } - - xmg_names export_superset() - { - mockturtle::direct_resynthesis resyn; - return mockturtle::node_resynthesis(optimal, resyn); - } - - optimizer *reapply(int index, const xmg_partition &part) - { - return new xag_optimizer(index, part, this->strategy, this->abc_exec); - } - - void convert() - { - mockturtle::xag_npn_resynthesis resyn; - converted = mockturtle::node_resynthesis (original, resyn); - converted.set_network_name("partition_" + std::to_string(index)); - } - - xag_names optimized() - { - return optimal; - } - - node_depth independent_metric() - { - mockturtle::depth_view part_xag_opt_depth{optimal}; - int xag_opt_size = optimal.num_gates(); - int xag_opt_depth = part_xag_opt_depth.depth(); - metric = node_depth{xag_opt_size, xag_opt_depth}; - return metric; - } - - std::string techmap(const std::string &liberty_file, const std::string &temp_prefix) - { - if (techmapped.empty()) { - - string script = - "read_lib " + liberty_file + - "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; - techmapped = basic_techmap ( - script, abc_exec, optimal, temp_prefix); - } - return techmapped; - } - - const std::string optimizer_name() - { - return "xagscript"; - } - - void optimize() - { - oracle::xag_script opt; - this->optimal = opt.run(this->converted); - } - - optimization_strategy target() - { - return strategy; - } - -protected: - int index; - partition original; - xag_names optimal; - xag_names converted; - node_depth metric; - string techmapped; - optimization_strategy strategy; - const std::string &abc_exec; -}; -template class xag_optimizer; - -template -class xmg_optimizer: public optimizer -{ - using partition = mockturtle::window_view>; -public: - xmg_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): index(index), original(original), strategy(target), abc_exec(abc_exec) - { - } - - optimizer *reapply(int index, const xmg_partition &part) - { - return new xmg_optimizer(index, part, this->strategy, this->abc_exec); - } - - xmg_names export_superset() - { - mockturtle::direct_resynthesis resyn; - return mockturtle::node_resynthesis(optimal, resyn); - } - - void convert() - { - mockturtle::xmg_npn_resynthesis resyn; - converted = mockturtle::node_resynthesis(original, resyn); - converted.set_network_name("partition_" + std::to_string(index)); - } - - xmg_names optimized() - { - return optimal; - } - - node_depth independent_metric() - { - mockturtle::depth_view part_xmg_opt_depth{optimal}; - int xmg_opt_size = optimal.num_gates(); - int xmg_opt_depth = part_xmg_opt_depth.depth(); - metric = node_depth{xmg_opt_size, xmg_opt_depth}; - return metric; - } - - std::string techmap(const std::string &liberty_file, const std::string &temp_prefix) - { - if (techmapped.empty()) { - string script = - "read_lib " + liberty_file + - "; strash; dch; map -B 0.9; topo; stime -c; buffer -c; upsize -c; dnsize -c"; - techmapped = basic_techmap ( - script, abc_exec, optimal, temp_prefix); - } - return techmapped; - } - - const std::string optimizer_name() - { - return "xmgscript"; - } - - void optimize() - { - oracle::xmg_script opt; - this->optimal = opt.run(this->converted); - } - - optimization_strategy target() - { - return strategy; - } - -protected: - int index; - partition original; - xmg_names optimal; - xmg_names converted; - node_depth metric; - string techmapped; - optimization_strategy strategy; - const std::string &abc_exec; -}; -template class xmg_optimizer; - -template -class migscript_optimizer: public mig_optimizer -{ - using partition = mockturtle::window_view>; -public: - migscript_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): mig_optimizer(index, original, target, abc_exec) {} - - const std::string optimizer_name() - { - return "migscript"; - } - - optimizer *reapply(int index, const xmg_partition &part) - { - return new migscript_optimizer(index, part, this->strategy, this->abc_exec); - } - - void optimize() - { - oracle::mig_script migopt; - this->optimal = migopt.run(this->converted); - } -}; - -template -class migscript2_optimizer: public mig_optimizer -{ - using partition = mockturtle::window_view>; -public: - migscript2_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): mig_optimizer(index, original, target, abc_exec) {} - - const std::string optimizer_name() - { - return "migscript2"; - } - - optimizer *reapply(int index, const xmg_partition &part) - { - return new migscript2_optimizer(index, part, this->strategy, this->abc_exec); - } - - void optimize() - { - oracle::mig_script2 migopt; - this->optimal = migopt.run(this->converted); - } -}; - -template -class migscript3_optimizer: public mig_optimizer -{ - using partition = mockturtle::window_view>; -public: - migscript3_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): mig_optimizer(index, original, target, abc_exec) {} - - optimizer *reapply(int index, const xmg_partition &part) - { - return new migscript3_optimizer(index, part, this->strategy, this->abc_exec); - } - - const std::string optimizer_name() - { - return "migscript3"; - } - - void optimize() - { - oracle::mig_script3 migopt; - this->optimal = migopt.run(this->converted); - } -}; - -template -class aigscript_optimizer: public aig_optimizer -{ - using partition = mockturtle::window_view>; -public: - aigscript_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} - - optimizer *reapply(int index, const xmg_partition &part) - { - return new aigscript_optimizer(index, part, this->strategy, this->abc_exec); - } - - const std::string optimizer_name() - { - return "aigscript"; - } - - void optimize() - { - oracle::aig_script opt; - this->optimal = opt.run(this->converted); - } -}; - -template -class aigscript2_optimizer: public aig_optimizer -{ - using partition = mockturtle::window_view>; -public: - aigscript2_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} - - optimizer *reapply(int index, const xmg_partition &part) - { - return new aigscript2_optimizer(index, part, this->strategy, this->abc_exec); - } - - const std::string optimizer_name() - { - return "aigscript2"; - } - - void optimize() - { - oracle::aig_script2 opt; - this->optimal = opt.run(this->converted); - } -}; - -template -class aigscript3_optimizer: public aig_optimizer -{ - using partition = mockturtle::window_view>; -public: - aigscript3_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} - - optimizer *reapply(int index, const xmg_partition &part) - { - return new aigscript3_optimizer(index, part, this->strategy, this->abc_exec); - } - - const std::string optimizer_name() - { - return "aigscript3"; - } - - void optimize() - { - oracle::aig_script3 opt; - this->optimal = opt.run(this->converted); - } -}; - -template -class aigscript4_optimizer: public aig_optimizer -{ - using partition = mockturtle::window_view>; -public: - aigscript4_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} - - optimizer *reapply(int index, const xmg_partition &part) - { - return new aigscript4_optimizer(index, part, this->strategy, this->abc_exec); - } - - const std::string optimizer_name() - { - return "aigscript4"; - } - - void optimize() - { - oracle::aig_script4 opt; - this->optimal = opt.run(this->converted); - } -}; - -template -class aigscript5_optimizer: public aig_optimizer -{ - using partition = mockturtle::window_view>; -public: - aigscript5_optimizer(int index, const partition &original, optimization_strategy target, const std::string &abc_exec): aig_optimizer(index, original, target, abc_exec) {} - - optimizer *reapply(int index, const xmg_partition &part) - { - return new aigscript5_optimizer(index, part, this->strategy, this->abc_exec); - } - - const std::string optimizer_name() - { - return "aigscript5"; - } - - void optimize() - { - oracle::aig_script5 opt; - this->optimal = opt.run(this->converted); - } -}; - -template -class optimization_strategy_comparator { -public: - // Comparator function - virtual bool operator()(optimizer &a, optimizer &b) = 0; - virtual const string name() = 0; -}; - -template -class ndp_strategy : public optimization_strategy_comparator -{ - bool operator()(optimizer &a, optimizer &b) - { - node_depth x = a.independent_metric(); - node_depth y = b.independent_metric(); - - return x.nodes * x.depth < y.nodes * y.depth; - } - const string name() - { - return "node-depth product"; - } -}; - -template -class d_strategy : public optimization_strategy_comparator -{ - bool operator()(optimizer &a, optimizer &b) - { - node_depth x = a.independent_metric(); - node_depth y = b.independent_metric(); - - return x.depth < y.depth; - } - const string name() - { - return "depth"; - } -}; - - template - class n_strategy : public optimization_strategy_comparator - { - bool operator()(optimizer &a, optimizer &b) - { - node_depth x = a.independent_metric(); - node_depth y = b.independent_metric(); - - return x.nodes < y.nodes; - } - const string name() - { - return "node"; - } -}; - -template -optimizer *optimize(optimization_strategy_comparator &comparator, - optimization_strategy strategy, - partition_manager_junior &partman, - int index, - const std::string &abc_exec) - -{ - std::cout << "******************************** optimizing partition " << index << " ********************************" << std::endl; - std::cout << "Optimizing based on strategy " << comparator.name() << std::endl; - // mockturtle::window_view> orig = partman.partition(index); - // mockturtle::depth_view part_depth(orig); - // std::cout << "Original depth " << part_depth.depth() << " gates " << part_depth.num_gates() << " size " << part_depth.size() << std::endl; - // todo this is gonna leak memory. - // const mockturtle::window_view> part = partman.partition(index); - // todo remove double network. - // fix_names(partman, part, partman.get_network(), index); - const mockturtle::window_view> part = fix_names2(partman, index); - std::vector*>optimizers { - new noop(index, part, strategy, abc_exec), - new migscript_optimizer(index, part, strategy, abc_exec), - new migscript2_optimizer(index, part, strategy, abc_exec), - new migscript3_optimizer(index, part, strategy, abc_exec), - new aigscript_optimizer(index, part, strategy, abc_exec), - new aigscript2_optimizer(index, part, strategy, abc_exec), - new aigscript3_optimizer(index, part, strategy, abc_exec), - new aigscript4_optimizer(index, part, strategy, abc_exec), - new aigscript5_optimizer(index, part, strategy, abc_exec), - new xmg_optimizer(index, part, strategy, abc_exec), - new xag_optimizer(index, part, strategy, abc_exec), - // new abc_optimizer(index, part, strategy, abc_exec), - }; - optimizer *best = nullptr; - for (auto opt = optimizers.begin(); opt != optimizers.end(); opt++) { - std::cout << "running optimization " << (*opt)->optimizer_name() << std::endl; - // std::cout << "converting network" << std::endl; - (*opt)->convert(); - // std::cout << "trying to optimize" << std::endl; - (*opt)->optimize(); - // std::cout << "checking tech independent metrics." << std::endl; - node_depth result = (*opt)->independent_metric(); - std::cout << "result depth " << result.depth - << " size " << result.nodes << std::endl; - - if (best == nullptr) { - best = *opt; - continue; - } - - if (comparator(**opt, *best)) { - best = *opt; - //std::cout << "found a better result" << std::endl; - continue; - } - } - std::cout << "using " << best->optimizer_name() << " for " << index << std::endl; - - return best; - -} - string join(std::string delim, std::set input) { std::vector data(input.begin(), input.end()); @@ -1045,8 +285,7 @@ std::set get_wire_names(oracle::partition_manager_junior & template void write_child(int index, partition_manager_junior &partman, - std::ofstream &verilog, - optimizer *optimizer) + std::ofstream &verilog) { std::cout << "writing out instance for partition " << index << std::endl; verilog << "partition_" << index << " partition_" << index << "_inst (\n"; @@ -1074,17 +313,21 @@ string techmap( const string &abc_exec, const string &liberty_file, const string &mappings_file, - const string &clock, - const string &temp_prefix) + const string &clock) { std::cout << "Starting techmap." << std::endl; // Write out verilog - char *output = strdup("/tmp/lsoracle_XXXXXX.combined.v"); - if (mkstemps(output, 11) == -1) { - throw std::exception(); + std::string output_file; + std::string temp_prefix = ""; + if (temp_prefix.empty()) { + char *output = strdup("/tmp/lsoracle_XXXXXX.combined.v"); + if (mkstemps(output, 11) == -1) { + throw std::exception(); + } + output_file = std::string(output); + } else { + output_file = fmt::format("{}.working.v", temp_prefix); } - std::string output_file = std::string(output); - // std::string output_file = fmt::format("{}.work.v", temp_prefix); std::cout << "Writing out to " << output_file << std::endl; std::ofstream verilog(output_file); @@ -1096,7 +339,7 @@ string techmap( std::cout << "******************************** techmapping partition " << i << " ********************************" << std::endl; optimizer *opt = optimized[i]; std::cout << "using optimizer " << opt->optimizer_name() << std::endl; - std::string module_file = opt->techmap(liberty_file, temp_prefix); + std::string module_file = opt->techmap(liberty_file); std::cout << "writing results" << std::endl; verilog << "// Partition " << i << std::endl; std::ifstream module(module_file); @@ -1242,7 +485,7 @@ void write_top(oracle::partition_manager_junior &partitions, // write out module instances for (int i = 0; i < partitions.count(); i++) { - write_child(i, partitions, verilog, optimized[i]); + write_child(i, partitions, verilog); } verilog << "endmodule" << std::endl; } @@ -1256,7 +499,6 @@ size_t run_timing(sta::LibertyLibrary *lib, const std::vector &optimized) { bool read_ver = sta::readVerilogFile(verilog_file.c_str(), - // bool read_ver = sta::readVerilogFile("/home/snelgrov/code/lsoracle/benchmarks/picorv32/picorv32_lsoracle.mapped.v", sta::Sta::sta()->networkReader()); assert(read_ver); // << "failed to read verilog"; bool linked = sta::Sta::sta()->linkDesign(design.c_str()); @@ -1370,15 +612,52 @@ void reset_sta() Tcl_Eval(tcl_interp, "namespace import sta::*"); } +template +std::vector critical_path(mockturtle::topo_view &net) +{ + mockturtle::node_map> crits(net, 0); + + net.foreach_gate([&](auto n) { + uint32_t worst = 0; + net.foreach_fanin(n, [&](auto f) { + if (crits[f] > worst) + worst = crits[f]; + }); + crits[n] = worst + 1; + }); + typename network::node worst_out; + net.foreach_co([&](auto p, auto i) { + auto n = net.get_node(p); + if (i == 0 || crits[n] > crits[worst_out]) + worst_out = n; + }); + + std::vector path; + path.push_back(worst_out); + typename network::node last = worst_out; + + while (!net.is_ci(last)) { + typename network::node worst; + net.foreach_fanin(last, [&](auto f, auto i) { + auto n = net.get_node(f); + if (i == 0 || crits[n] > crits[worst]) + worst = n; + }); + last = worst; + path.push_back(last); + } + return path; +} template const int worst_indep(oracle::partition_manager_junior &partitions, std::vector &optimized) { oracle::slack_view> slack(partitions.get_network()); - auto critical_path = slack.get_critical_path(partitions.get_network()); // TODO why does this pass itself back + mockturtle::topo_view> topo(partitions.get_network()); + std::vector path = critical_path(topo); std::vector budget(partitions.count(), 0); - for (auto i = critical_path.begin(); i != critical_path.end(); i++) { + for (auto i = path.begin(); i != path.end(); i++) { budget[partitions.node_partition(*i)] += 1; } @@ -1394,20 +673,12 @@ const int worst_indep(oracle::partition_manager_junior &partitions, } template -xmg_names setup_output( - oracle::partition_manager_junior &partitions_in, - std::vector*> &optimized) +oracle::partition_manager_junior setup_output( + oracle::partition_manager_junior &partitions_in, + std::vector*> &optimized) { int num_parts = partitions_in.count(); - mockturtle::direct_resynthesis resyn; - mockturtle::names_view &ntk = partitions_in.get_network(); - xmg_names ntk_out = mockturtle::node_resynthesis>(ntk, resyn); - mockturtle::node_map partitions_out_map(ntk_out); - partitions_in.get_network().foreach_node([&](auto n){ - int i = ntk.node_to_index(n); - partitions_out_map[ntk_out.index_to_node(i)] = partitions_in.node_partition(n); - }); - xmg_manager partitions_out(ntk_out, partitions_out_map, partitions_in.count()); + xmg_manager partitions_out = partitions_in.convert(); for (int i = 0; i < num_parts; i++) { std::cout << "Partition " << i << " " << optimized[i]->optimizer_name() << " "; @@ -1422,28 +693,80 @@ xmg_names setup_output( std::cout << std::endl; if (optimized[i]->optimizer_name() != "noop") { // const xmg_partition part = fix_names2(partitions_out, i); - const xmg_partition part = partitions_out.partition(i); + const xmg_partition part = fix_names2(partitions_out, i); optimizer *optim = optimized[i]->reapply(i, part); optim->convert(); optim->optimize(); xmg_names opt = optim->export_superset(); - partitions_out.integrate(i, partitions_out.partition(i), opt); + partitions_out.integrate(i, part, opt); } } partitions_out.substitute_nodes(); std::cout << "Finished connecting outputs" << std::endl; - return partitions_out.get_network(); + return partitions_out; } +template +xmg_names setup_output1( + oracle::partition_manager_junior &partitions_in, + std::vector*>> &optimized + ) +{ + int num_parts = partitions_in.count(); + mockturtle::direct_resynthesis resyn; + mockturtle::names_view &ntk = partitions_in.get_network(); + xmg_names ntk_out = mockturtle::node_resynthesis>(ntk, resyn); + mockturtle::node_map partitions_out_map(ntk_out); + partitions_in.get_network().foreach_node([&](auto n){ + int i = ntk.node_to_index(n); + partitions_out_map[ntk_out.index_to_node(i)] = partitions_in.node_partition(n); + }); + xmg_manager partitions_out(ntk_out, partitions_out_map, partitions_in.count()); + + for (int i = 0; i < num_parts; i++) { + const xmg_partition part = partitions_out.partition(i); + + optimizer *optim = optimized[i].back()->reapply(i, part); + for(int j=0;joptimizer_name() << std::endl; + switch (optimized[i].back()->target()) { + case optimization_strategy::depth: std::cout << "depth\n"; + break; + case optimization_strategy::balanced: std::cout << "balanced\n"; + break; + case optimization_strategy::size: std::cout << "size\n"; + break; + } + if (optimized[i][j]->optimizer_name() != "noop") { + optim->convert(); + optim->reoptimize(); + node_depth result1 = optim->independent_metric(); + std::cout << "Result depth " << result1.depth + << " size " << result1.nodes << std::endl; + if(j==(optimized[i].size()-1)){ + xmg_names opt = optim->export_superset(); + partitions_out.integrate(i, partitions_out.partition(i), opt); + } + + } + } + } + partitions_out.substitute_nodes(); + std::cout << "Finished connecting outputs" << std::endl; + return partitions_out.get_network(); +} /* * Mixed synthesis followed by XMG resynthesis and combination. */ -template xmg_names optimize_timing( +template xmg_names optimize_timing_resynth( oracle::partition_manager_junior &partitions, const string &liberty_file, const std::string &mapping_file, const string &sdc_file, const string &clock, - const string &output_file, const string &abc_exec, const string &temp_prefix) + const string &output_file, const string &abc_exec, + optimization_strategy_comparator &size_strategy, + optimization_strategy_comparator &mixed_strategy, + optimization_strategy_comparator &depth_strategy) { sta::Corner *corner = new sta::Corner("tt", 0); sta::MinMaxAll *minmax = sta::MinMaxAll::all(); @@ -1456,15 +779,15 @@ template xmg_names optimize_timing( int num_parts = partitions.count(); std::vector*> optimized(num_parts); for (int i = 0; i < num_parts; i++) { - n_strategy strategy; - optimized[i] = optimize(strategy, optimization_strategy::size, partitions, i, abc_exec); + const mockturtle::window_view> part = fix_names2(partitions, i); + optimized[i] = optimize(size_strategy, optimization_strategy::size, part, i, abc_exec); } assert(num_parts == optimized.size()); string verilog; while (true) { //reset_sta(); // todo not cleaning up - verilog = techmap(partitions, optimized, abc_exec, liberty_file, mapping_file, clock, temp_prefix); + verilog = techmap(partitions, optimized, abc_exec, liberty_file, mapping_file, clock); std::cout << "Wrote techmapped verilog to " << verilog << std::endl; std::vector strats(optimized.size(), optimization_strategy::size); for (int i = 0; i < optimized.size(); i++) { @@ -1482,11 +805,11 @@ template xmg_names optimize_timing( break; } if (optimized[worst_part]->target() == optimization_strategy::size) { - ndp_strategy strategy; - optimized[worst_part] = optimize(strategy, optimization_strategy::balanced, partitions, worst_part, abc_exec); + const mockturtle::window_view> part = fix_names2(partitions, worst_part); + optimized[worst_part] = optimize(mixed_strategy, optimization_strategy::balanced, part, worst_part, abc_exec); } else if (optimized[worst_part]->target() == optimization_strategy::balanced) { - d_strategy strategy; - optimized[worst_part] = optimize(strategy, optimization_strategy::depth, partitions, worst_part, abc_exec); + const mockturtle::window_view> part = fix_names2(partitions, worst_part); + optimized[worst_part] = optimize(depth_strategy, optimization_strategy::depth, part, worst_part, abc_exec); } else if (optimized[worst_part]->target() == optimization_strategy::depth) { std::cout << "previous result was already the best we can do." << std::endl; break; // met timing, or it's the best we can do. @@ -1498,10 +821,55 @@ template xmg_names optimize_timing( std::filesystem::copy(verilog, output_file, std::filesystem::copy_options::overwrite_existing); // Output network - return setup_output(partitions, optimized); + return setup_output(partitions, optimized).get_network(); } +/* + * Mixed synthesis followed by XMG resynthesis and combination. + */ +template xmg_names optimize_timing_tech( + oracle::partition_manager_junior &partitions, + const string &liberty_file, const std::string &mapping_file, + const string &sdc_file, const string &clock, + const string &output_file, const string &abc_exec) +{ + + std::cout << "******************************** Doin' the thing ********************************" << std::endl; + optimization_strategy_comparator *area = new area_strategy(liberty_file, sdc_file); + optimization_strategy_comparator *mixed = new area_delay_strategy(liberty_file, sdc_file); + optimization_strategy_comparator *delay = new delay_strategy(liberty_file, sdc_file); + return optimize_timing_resynth(partitions, + liberty_file, mapping_file, sdc_file, + clock, output_file, abc_exec, + *area, *mixed, *delay); + delete area; + delete mixed; + delete delay; +} + +/* + * Mixed synthesis followed by XMG resynthesis and combination. + */ +template xmg_names optimize_timing( + oracle::partition_manager_junior &partitions, + const string &liberty_file, const std::string &mapping_file, + const string &sdc_file, const string &clock, + const string &output_file, const string &abc_exec) +{ + + optimization_strategy_comparator *node = new node_depth_strategy(); + optimization_strategy_comparator *ndp = new node_strategy(); + optimization_strategy_comparator *depth = new depth_strategy(); + return optimize_timing_resynth(partitions, + liberty_file, mapping_file, sdc_file, + clock, output_file, abc_exec, + *node, *ndp, *depth); + delete node; + delete ndp; + delete depth; +} + /* Mixed synthesis followed by XMG resynthesis and combiniation */ @@ -1511,8 +879,10 @@ template xmg_names optimize_resynthesis( int num_parts = partitions.count(); std::vector*> optimized(num_parts); for (int i = 0; i < num_parts; i++) { - n_strategy strategy; - optimized[i] = optimize(strategy, optimization_strategy::size, partitions, i, abc_exec); + node_strategy strategy; + const mockturtle::window_view> part = fix_names2(partitions, i); + + optimized[i] = optimize(strategy, optimization_strategy::size, part, i, abc_exec); } assert(num_parts == optimized.size()); @@ -1522,7 +892,8 @@ template xmg_names optimize_resynthesis( strats[i] = optimized[i]->target(); } const std::string design = partitions.get_network().get_network_name() != "" ? partitions.get_network().get_network_name() : "top"; - size_t worst_part = worst_indep(partitions, strats); + auto partitions_out = setup_output(partitions, optimized); + size_t worst_part = worst_indep(partitions_out, strats); // TODO if this is worse than last result, rollback and finish. if (worst_part == -1) { std::cout << "met timing" << std::endl; @@ -1533,11 +904,14 @@ template xmg_names optimize_resynthesis( break; } if (optimized[worst_part]->target() == optimization_strategy::size) { - ndp_strategy strategy; - optimized[worst_part] = optimize(strategy, optimization_strategy::balanced, partitions, worst_part, abc_exec); + node_depth_strategy strategy; + const mockturtle::window_view> part = fix_names2(partitions, worst_part); + + optimized[worst_part] = optimize(strategy, optimization_strategy::balanced, part, worst_part, abc_exec); } else if (optimized[worst_part]->target() == optimization_strategy::balanced) { - d_strategy strategy; - optimized[worst_part] = optimize(strategy, optimization_strategy::depth, partitions, worst_part, abc_exec); + depth_strategy strategy; + const mockturtle::window_view> part = fix_names2(partitions, worst_part); + optimized[worst_part] = optimize(strategy, optimization_strategy::depth, part, worst_part, abc_exec); } else if (optimized[worst_part]->target() == optimization_strategy::depth) { std::cout << "previous result was already the best we can do." << std::endl; break; // met timing, or it's the best we can do. @@ -1547,7 +921,7 @@ template xmg_names optimize_resynthesis( } // Output network - return setup_output(partitions, optimized); + return setup_output(partitions, optimized).get_network(); } /* @@ -1557,30 +931,33 @@ template xmg_names optimize_basic ( oracle::partition_manager_junior &partitions, const string &abc_exec, - optimization_strategy strategy) + optimization_strategy strategy, + bool reoptimize_bool) { int num_parts = partitions.count(); std::vector*> optimized(num_parts); optimization_strategy_comparator *target; switch (strategy) { case optimization_strategy::depth: std::cout << "depth"; - target = new d_strategy(); + target = new depth_strategy(); break; case optimization_strategy::balanced: std::cout << "balanced"; - target = new ndp_strategy(); + target = new node_depth_strategy(); break; case optimization_strategy::size: std::cout << "size"; - target = new n_strategy(); + target = new node_strategy(); break; } std::cout << std::endl; for (int i = 0; i < num_parts; i++) { - optimized[i] = optimize(*target, strategy, partitions, i, abc_exec); + const mockturtle::window_view> part = fix_names2(partitions, i); + + optimized[i] = optimize(*target, strategy, part, i, abc_exec); } delete target; assert(num_parts == optimized.size()); - return setup_output(partitions, optimized); + return setup_output(partitions, optimized).get_network(); } /**************** Template instances ****************/ @@ -1588,14 +965,22 @@ template xmg_names optimize_timing ( oracle::partition_manager_junior &, - const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &); + const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &); + +template xmg_names +optimize_timing_tech +( + oracle::partition_manager_junior &, + const std::string &, const std::string &, const std::string &, const std::string &, const std::string &, const std::string &); template xmg_names optimize_basic ( oracle::partition_manager_junior &, const std::string &, - const optimization_strategy); + const optimization_strategy, + bool); + template xmg_names optimize_resynthesis @@ -1603,6 +988,21 @@ optimize_resynthesis oracle::partition_manager_junior &, const std::string &); -} +template void +write_child( + int, partition_manager_junior &, std::ofstream &); + +template void +write_child( + int, partition_manager_junior &, std::ofstream &); + +template void +write_child( + int, partition_manager_junior &, std::ofstream &); + +template void +write_child( + int, partition_manager_junior &, std::ofstream &); +}; #endif #endif diff --git a/core/algorithms/optimization/resynthesis.hpp b/core/algorithms/optimization/resynthesis.hpp index 290e23194..2fc92e34d 100644 --- a/core/algorithms/optimization/resynthesis.hpp +++ b/core/algorithms/optimization/resynthesis.hpp @@ -29,6 +29,7 @@ #ifdef ENABLE_ABC #include #include "algorithms/partitioning/partition_manager_junior.hpp" +#include "algorithms/optimization/optimizers.hpp" #include "utility.hpp" namespace oracle @@ -40,64 +41,32 @@ mockturtle::names_view optimize_timing( oracle::partition_manager_junior &partitions, const std::string &liberty_file, const std::string &mapping_file, const std::string &sdc_file, const std::string &clock_name, - const std::string &output_file, const std::string &abc_exec, const std::string &temp_prefix); -#endif + const std::string &output_file, const std::string &abc_exec); -enum optimization_strategy { size, balanced, depth }; +template +mockturtle::names_view optimize_timing_tech( + oracle::partition_manager_junior &partitions, + const std::string &liberty_file, const std::string &mapping_file, + const std::string &sdc_file, const std::string &clock_name, + const std::string &output_file, const std::string &abc_exec); +#endif template mockturtle::names_view optimize_basic( oracle::partition_manager_junior &partitions, const std::string &abc_exec, - const optimization_strategy strategy); + const optimization_strategy strategy, + bool reoptimize_bool); template mockturtle::names_view optimize_resynthesis( oracle::partition_manager_junior &partitions, const std::string &abc_exec); -struct node_depth { - int nodes; - int depth; -}; - - -template -class optimizer -{ -public: - /** - * human readable name - */ - virtual const std::string optimizer_name() = 0; - /** - * Do any conversion necessary from original network type to the internal network type. - */ - virtual void convert() = 0; - /** - * Perform optimization - */ - virtual void optimize() = 0; - /** - * Calculate tech independent depth and nodes metrics. - */ - virtual node_depth independent_metric() = 0; - /** - * List the type of optimization: area, delay, or balanced. - */ - virtual optimization_strategy target() = 0; - /** - * Techmap, then return a path to a file containing the techmapped verilog. - */ - virtual std::string techmap(const std::string &liberty_file, const std::string &temp_prefix) = 0; - /** - * convert the network to the superset. - */ - virtual mockturtle::names_view export_superset() = 0; - /** - * Reapply this optimization to a different network. - */ - virtual optimizer *reapply(int index, const mockturtle::window_view> &part) = 0; -}; +template +void write_child( + int index, + partition_manager_junior &partman, + std::ofstream &verilog); } #endif diff --git a/core/algorithms/partitioning/partition_manager.hpp b/core/algorithms/partitioning/partition_manager.hpp index 145a4b35e..c116f03b9 100644 --- a/core/algorithms/partitioning/partition_manager.hpp +++ b/core/algorithms/partitioning/partition_manager.hpp @@ -461,14 +461,11 @@ class partition_manager : public Ntk int orig_ntk_size = ntk.size(); mockturtle::node_map old_to_new(opt); std::vector pis; - part.foreach_pi([&](auto node) { pis.push_back(part.make_signal(node)); }); - mockturtle::topo_view part_top{part}; mockturtle::topo_view opt_top{opt}; - int pi_idx = 0; std::set visited_pis; opt_top.foreach_node([&](auto node) { @@ -481,7 +478,7 @@ class partition_manager : public Ntk opt.foreach_fanin(node, [&](auto child, auto) { auto f = old_to_new[child]; if (opt.is_pi(opt.get_node(child)) || opt.is_ro(opt.get_node(child))) { - f = pis.at(child.index - 1); + f = pis.at(child.index - 1); //what(): vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 53) } if (opt.is_complemented(child)) { children.push_back(ntk.create_not(f)); @@ -489,7 +486,6 @@ class partition_manager : public Ntk children.push_back(f); } }); - old_to_new[node] = ntk.clone_node(opt, node, children); }); @@ -499,9 +495,7 @@ class partition_manager : public Ntk auto part_out = part._roots.at(i); if (opt.is_complemented(opt._storage->outputs[i])) { opt_out.data += 1; - } - if (!opt.is_constant(opt_node) && !opt.is_pi(opt_node) && !opt.is_ro(opt_node)) { output_substitutions[ntk.get_node(part_out)] = opt_out; diff --git a/core/algorithms/partitioning/partition_manager_junior.hpp b/core/algorithms/partitioning/partition_manager_junior.hpp index 0fa96cc7f..700fb3d23 100644 --- a/core/algorithms/partitioning/partition_manager_junior.hpp +++ b/core/algorithms/partitioning/partition_manager_junior.hpp @@ -39,6 +39,7 @@ class partition_manager_junior { public: using network = typename mockturtle::names_view; + using xmg_names = typename mockturtle::names_view; using partition_map = typename mockturtle::node_map; using storage = typename network::storage; using node = typename network::node; @@ -217,7 +218,7 @@ class partition_manager_junior } std::cout << "Substituted nodes." << std::endl; - ntk = mockturtle::cleanup_dangling_with_registers(ntk); + ntk = mockturtle::cleanup_dangling(ntk); std::cout << "Cleaned up dangling." << std::endl; substitutions.clear(); } @@ -231,6 +232,55 @@ class partition_manager_junior return partition_count; } + partition_manager_junior convert() + { + mockturtle::direct_resynthesis resyn; + xmg_names ntk_out = mockturtle::node_resynthesis>(ntk, resyn); + mockturtle::node_map partitions_out_map(ntk_out); + ntk.foreach_node([&](auto n){ + int i = ntk.node_to_index(n); + partitions_out_map[ntk_out.index_to_node(i)] = node_partition(n); + }); + partition_manager_junior partitions_out(ntk_out, partitions_out_map, count()); + return partitions_out; + } + + window_view extract_cone(typename network::signal s) + { + std::vector gates; + std::vector inputs; + std::vector outputs; + outputs.push_back(s); + + ntk.foreach_pi([&](auto pi) { + // relying on mockturtle guarantee of input order. + inputs.push_back(pi); + }); + std::queue traverse; + traverse.push(ntk.get_node(s)); + ntk.incr_trav_id(); + uint32_t id = ntk.trav_id(); + while (!traverse.empty()) { + auto t = traverse.front(); + if (ntk.visited(t) != id && !ntk.is_pi(t)) { + gates.push_back(t); + ntk.foreach_fanin(t, [&](auto f) { + traverse.push(ntk.get_node(f)); + }); + } + ntk.set_visited(t, id); + traverse.pop(); + } + return window_view(ntk, inputs, outputs, gates); + } + + template + void integrate_cone(window_view &cone, mockturtle::names_view &opt) + { + partition_count += 1; + integrate(partition_count, cone, opt); + } + private: network ntk; partition_map partitions; diff --git a/core/commands/optimization/abc.hpp b/core/commands/optimization/abc.hpp new file mode 100644 index 000000000..7b317e0b7 --- /dev/null +++ b/core/commands/optimization/abc.hpp @@ -0,0 +1,82 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include +#include +#include +#include "algorithms/optimization/abc.hpp" + +namespace alice +{ +class abc_part_command : public alice::command +{ + +public: + explicit abc_part_command(const environment::ptr &env) + : command(env, "Perform timing driven mixed synthesis.") + { + opts.add_option("--abc_exec", abc_exec, + "ABC executable, defaults to using path."); + } +protected: + void execute() + { + synth("AIG"); + } + + template + void synth(string name) + { + if (store>>().empty()) { + env->err() << "No " << name << " stored\n"; + return; + } + if (store>>().empty()) { + env->err() << name << " not partitioned yet\n"; + return; + } + + oracle::partition_manager_junior partitions_jr = + *store>>().current(); + + mockturtle::depth_view orig_depth(partitions_jr.get_network()); + + auto start = std::chrono::high_resolution_clock::now(); + oracle::optimize_abc(partitions_jr, abc_exec); + + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast + (stop - start); + env->out() << "Full Optimization: " << duration.count() << "ms\n"; + env->out() << "Finished optimization\n"; + } + + string abc_exec{"abc"}; +}; +ALICE_ADD_COMMAND(abc_part, "Optimization"); +} diff --git a/core/commands/optimization/exploderize.hpp b/core/commands/optimization/exploderize.hpp new file mode 100644 index 000000000..ba2333ab9 --- /dev/null +++ b/core/commands/optimization/exploderize.hpp @@ -0,0 +1,97 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include +#include +#include +#include "algorithms/optimization/exploder.hpp" + +namespace alice +{ +class exploderize_command : public alice::command +{ + +public: + explicit exploderize_command(const environment::ptr &env) + : command(env, "Perform exploded logic cone optimization.") + { + opts.add_option("--abc_exec", abc_exec, + "ABC executable, defaults to using path."); + opts.add_option("--depth", target, + "Target depth to apply optimization."); + } +protected: + void execute() + { + synth("AIG"); + } + + template + void synth(string name) + { + if (store>>().empty()) { + env->err() << "No " << name << " stored\n"; + return; + } + mockturtle::names_view ntk = + *store>>().current(); + + mockturtle::depth_view orig_depth(ntk); + std::cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; + auto start = std::chrono::high_resolution_clock::now(); + oracle::exploderizer boom(ntk, abc_exec); + mockturtle::names_view ntk_result = boom.exploderize(target); + std::cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << std::endl; + auto stop = std::chrono::high_resolution_clock::now(); + + mockturtle::depth_view new_depth(ntk_result); + env->out() << "Original ntk size = " << ntk.size() << " depth = " << orig_depth.depth() << std::endl; + if (ntk_result.size() == ntk.size() + && orig_depth.depth() == new_depth.depth()) { + env->err() << "No change made to network" << std::endl; + } + + env->out() << "Final ntk size = " << ntk_result.num_gates() << " and depth = " + << new_depth.depth() << "\n"; + env->out() << "Final number of latches = " << ntk_result.num_latches() << "\n"; + env->out() << "Node Depth Product = " + << ntk_result.num_gates() * new_depth.depth() + << "\n"; + auto duration = std::chrono::duration_cast + (stop - start); + env->out() << "Full Optimization: " << duration.count() << "ms\n"; + env->out() << "Finished optimization\n"; + store>>().extend() = + std::make_shared>(ntk_result); + } + + string abc_exec{"abc"}; + uint32_t target = 0; +}; +ALICE_ADD_COMMAND(exploderize, "Optimization"); +} diff --git a/core/commands/optimization/optimization_command.hpp b/core/commands/optimization/optimization_command.hpp deleted file mode 100644 index 5c4afe9bf..000000000 --- a/core/commands/optimization/optimization_command.hpp +++ /dev/null @@ -1,218 +0,0 @@ -/* LSOracle: A learning based Oracle for Logic Synthesis - - * MIT License - * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ -#pragma once -#include - -#include - -#include -#include - -#include -#include - - -namespace alice -{ -class optimization_command : public alice::command -{ - -public: - explicit optimization_command(const environment::ptr &env) - : command(env, "Perform Mixed Synthesis on Network after Partitioning") - { - - opts.add_option("--nn_model,-n", nn_model, - "Trained neural network model for classification"); - opts.add_option("--out,-o", out_file, "Verilog output"); - opts.add_option("--strategy,-s", strategy, - "classification strategy [area delay product=0, area=1, delay=2, delay_threshold=3]"); - opts.add_option("--threshold", threshold, - "maximum delay threshold for strategy 3"); - opts.add_flag("--fixed_initial", "Depth optimize initial partitions."); - opts.add_option("--aig_partitions", aig_parts, - "space separated list of partitions to always be AIG optimized"); - opts.add_option("--mig_partitions", mig_parts, - "space separated list of partitions to always be MIG optimized"); - opts.add_option("--depth_partitions", depth_parts, - "space separated list of partitions to always be depth optimized"); - opts.add_option("--skip_partitions", skip_parts, - "space separated list of partitions that will not be optimized"); - opts.add_option("--area_partitions", area_parts, - "space separated list of partitions to always be area optimized"); - add_flag("--aig,-a", "Perform only AIG optimization on all partitions"); - add_flag("--mig,-m", "Perform only MIG optimization on all partitions"); - add_flag("--combine,-c", - "Combine adjacent partitions that have been classified for the same optimization"); - //add_flag("--skip-feedthrough", "Do not include feedthrough nets when writing out the file"); - } - -protected: - void execute() - { - - if (!store().empty()) { - auto ntk_aig = *store().current(); - mockturtle::depth_view orig_depth{ntk_aig}; - if (!store().empty()) { - auto partitions_aig = *store().current(); - if (!nn_model.empty()) - high = false; - else - high = true; - if (is_set("aig")) - aig = true; - if (is_set("mig")) - mig = true; - if (is_set("combine")) - combine = true; - - if (is_set("fixed_initial")) { - std::set fixed_partitions = - partitions_aig.fixed_partitions(); - std::copy(fixed_partitions.begin(), fixed_partitions.end(), - std::inserter(depth_parts, depth_parts.end())); - } - - if (threshold == 0 && strategy == 3) { - threshold = calculate_depth_percentile(ntk_aig); - } - if (strategy == 3) { - env->out() << "Using threshold " << threshold << " max depth for optimization." - << std::endl; - } - - std::copy(aig_parts.begin(), aig_parts.end(), - std::inserter(aig_always_partitions, aig_always_partitions.end())); - std::copy(mig_parts.begin(), mig_parts.end(), - std::inserter(mig_always_partitions, mig_always_partitions.end())); - std::copy(area_parts.begin(), area_parts.end(), - std::inserter(area_always_partitions, area_always_partitions.end())); - std::copy(depth_parts.begin(), depth_parts.end(), - std::inserter(depth_always_partitions, depth_always_partitions.end())); - std::copy(skip_parts.begin(), skip_parts.end(), std::inserter(skip_partitions, - skip_partitions.end())); - - auto start = std::chrono::high_resolution_clock::now(); - auto ntk_mig = oracle::optimization(ntk_aig, partitions_aig, strategy, - threshold, nn_model, - high, aig, mig, combine, - aig_always_partitions, mig_always_partitions, - depth_always_partitions, area_always_partitions, - skip_partitions); - auto stop = std::chrono::high_resolution_clock::now(); - - - mockturtle::depth_view new_depth{ntk_mig}; - store().extend() = std::make_shared(ntk_mig); - if (ntk_mig.size() != ntk_aig.size() - || orig_depth.depth() != new_depth.depth()) { - env->out() << "Final ntk size = " << ntk_mig.num_gates() << " and depth = " << - new_depth.depth() << "\n"; - env->out() << "Final number of latches = " << ntk_mig.num_latches() << "\n"; - env->out() << "Area Delay Product = " << ntk_mig.num_gates() * new_depth.depth() - << "\n"; - auto duration = std::chrono::duration_cast - (stop - start); - env->out() << "Full Optimization: " << duration.count() << "ms\n"; - env->out() << "Finished optimization\n"; - - if (out_file != "") { - if (oracle::checkExt(out_file, "v")) { - mockturtle::write_verilog_params ps; - - //removing to use stock mockturtle I/O. May be nice to have in the future - //if(is_set("skip-feedthrough")) - // ps.skip_feedthrough = 1u; - - mockturtle::write_verilog(ntk_mig, out_file, ps); - env->out() << "Resulting network written to " << out_file << "\n"; - } else if (oracle::checkExt(out_file, "blif")) { - mockturtle::write_blif_params ps; - //if(is_set("skip-feedthrough")) - // ps.skip_feedthrough = 1u; - - mockturtle::write_blif(ntk_mig, out_file, ps); - env->out() << "Resulting network written to " << out_file << "\n"; - } else { - env->err() << out_file << " is not an accepted output file {.v, .blif}\n"; - } - } - } else { - env->out() << "No change made to network\n"; - } - - } else { - env->err() << "AIG not partitioned yet\n"; - } - } else { - env->err() << "No AIG stored\n"; - } - } -private: - uint32_t calculate_depth_percentile( - mockturtle::names_view net) - { - std::vector depths; - mockturtle::depth_view view(net); - net.foreach_po([this, &depths, &view](auto po) { - depths.push_back(view.level(view.get_node(po))); - }); - std::sort(depths.begin(), depths.end()); - if (depths.size() == 1) { - return depths[0]; - } else if (depths.size() == 0) { - return 0; - } else { - // 95 percentile element or the second to last value, whichever is earlier. - size_t index = (size_t) min(ceil(0.95 * depths.size()), - (double)(depths.size() - 1)) - 1; - return depths[index]; - } - } - std::string nn_model{}; - std::string out_file{}; - std::vector aig_parts{}; - std::vector mig_parts{}; - std::vector area_parts{}; - std::vector depth_parts{}; - std::vector skip_parts{}; - unsigned strategy{0u}; - unsigned threshold{0u}; - bool high = false; - bool aig = false; - bool mig = false; - bool combine = false; - std::set aig_always_partitions = {}; - std::set mig_always_partitions = {}; - std::set depth_always_partitions = {}; - std::set area_always_partitions = {}; - std::set skip_partitions = {}; -}; - -ALICE_ADD_COMMAND(optimization, "Optimization"); -} diff --git a/core/commands/optimization/optimize.hpp b/core/commands/optimization/optimize.hpp index d877afdbe..b73a47f70 100644 --- a/core/commands/optimization/optimize.hpp +++ b/core/commands/optimization/optimize.hpp @@ -45,7 +45,8 @@ class optimize_command : public alice::command opts.add_flag("--ndp", "Node Depth Product target"); opts.add_flag("--nodes", "Node Count target"); opts.add_flag("--depth", "Depth target"); - opts.add_flag("--resynth", "Resynthesis for depth"); + opts.add_flag("--resynth", "Resynthesis for depth"); + opts.add_option("--convergence",strategyconvergence, "Reoptimization until convergence with the strategy wanted (balanced, nodes, depth)"); } protected: void execute() @@ -56,6 +57,7 @@ class optimize_command : public alice::command template void synth(string name) { + auto ntk = *store>>().current(); if (store>>().empty()) { env->err() << "No " << name << " stored\n"; return; @@ -72,9 +74,26 @@ class optimize_command : public alice::command auto start = std::chrono::high_resolution_clock::now(); mockturtle::names_view ntk_result; + mockturtle::names_view ntk2_result; + if (is_set("resynth")) { ntk_result = oracle::optimize_resynthesis(partitions_jr, abc_exec); - } else { + } + + if (is_set("convergence")){ + oracle::optimization_strategy strategy; + if (strategyconvergence=="depth") { + strategy = oracle::optimization_strategy::depth; + } else if (strategyconvergence=="nodes") { + strategy = oracle::optimization_strategy::size; + } else { + strategy = oracle::optimization_strategy::balanced; + } + bool reoptimize_bool = true; + ntk_result = oracle::optimize_basic(partitions_jr, abc_exec, strategy, true); + } + + else { oracle::optimization_strategy strategy; if (is_set("depth")) { strategy = oracle::optimization_strategy::depth; @@ -84,8 +103,8 @@ class optimize_command : public alice::command strategy = oracle::optimization_strategy::balanced; } - ntk_result = oracle::optimize_basic(partitions_jr, abc_exec, strategy); - } + ntk_result = oracle::optimize_basic(partitions_jr, abc_exec, strategy,false); + } auto stop = std::chrono::high_resolution_clock::now(); mockturtle::depth_view new_depth(ntk_result); @@ -95,20 +114,23 @@ class optimize_command : public alice::command } env->out() << "Final ntk size = " << ntk_result.num_gates() << " and depth = " - << new_depth.depth() << "\n"; + << new_depth.depth() << "\n"; env->out() << "Final number of latches = " << ntk_result.num_latches() << "\n"; env->out() << "Node Depth Product = " - << ntk_result.num_gates() * new_depth.depth() - << "\n"; + << ntk_result.num_gates() * new_depth.depth() + << "\n"; auto duration = std::chrono::duration_cast (stop - start); env->out() << "Full Optimization: " << duration.count() << "ms\n"; env->out() << "Finished optimization\n"; store>>().extend() = - std::make_shared>(ntk_result); + std::make_shared>(ntk_result); } string abc_exec{"abc"}; +private: + std:: string strategyconvergence={""}; + }; ALICE_ADD_COMMAND(optimize, "Optimization"); } diff --git a/core/commands/optimization/optimize_tech.hpp b/core/commands/optimization/optimize_tech.hpp new file mode 100644 index 000000000..61463b52e --- /dev/null +++ b/core/commands/optimization/optimize_tech.hpp @@ -0,0 +1,114 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once + +#include +#include +#include +#include "algorithms/optimization/resynthesis.hpp" + +namespace alice +{ +class optimize_tech_command : public alice::command +{ + +public: + explicit optimize_tech_command(const environment::ptr &env) + : command(env, "Perform timing driven mixed synthesis.") + { + opts.add_option("--abc_exec", abc_exec, + "ABC executable, defaults to using path."); + opts.add_flag("--ndp", "Node Depth Product target"); + opts.add_flag("--nodes", "Node Count target"); + opts.add_flag("--depth", "Depth target"); + opts.add_flag("--resynth", "Resynthesis for depth"); + } +protected: + void execute() + { + synth("AIG"); + } + + template + void synth(string name) + { + if (store>>().empty()) { + env->err() << "No " << name << " stored\n"; + return; + } + if (store>>().empty()) { + env->err() << name << " not partitioned yet\n"; + return; + } + + oracle::partition_manager_junior partitions_jr = + *store>>().current(); + + mockturtle::depth_view orig_depth(partitions_jr.get_network()); + + auto start = std::chrono::high_resolution_clock::now(); + mockturtle::names_view ntk_result; + if (is_set("resynth")) { + ntk_result = oracle::optimize_resynthesis(partitions_jr, abc_exec); + } else { + oracle::optimization_strategy strategy; + if (is_set("depth")) { + strategy = oracle::optimization_strategy::depth; + } else if (is_set("nodes")) { + strategy = oracle::optimization_strategy::size; + } else { + strategy = oracle::optimization_strategy::balanced; + } + + ntk_result = oracle::optimize_basic(partitions_jr, abc_exec, strategy, false); + } + auto stop = std::chrono::high_resolution_clock::now(); + + mockturtle::depth_view new_depth(ntk_result); + if (ntk_result.size() == partitions_jr.get_network().size() + && orig_depth.depth() == new_depth.depth()) { + env->err() << "No change made to network" << std::endl; + } + + env->out() << "Final ntk size = " << ntk_result.num_gates() << " and depth = " + << new_depth.depth() << "\n"; + env->out() << "Final number of latches = " << ntk_result.num_latches() << "\n"; + env->out() << "Node Depth Product = " + << ntk_result.num_gates() * new_depth.depth() + << "\n"; + auto duration = std::chrono::duration_cast + (stop - start); + env->out() << "Full Optimization: " << duration.count() << "ms\n"; + env->out() << "Finished optimization\n"; + store>>().extend() = + std::make_shared>(ntk_result); + } + + string abc_exec{"abc"}; +}; +ALICE_ADD_COMMAND(optimize, "Optimization"); +} diff --git a/core/commands/optimization/optimize_timing.hpp b/core/commands/optimization/optimize_timing.hpp index cc30d63cc..cbda1474e 100644 --- a/core/commands/optimization/optimize_timing.hpp +++ b/core/commands/optimization/optimize_timing.hpp @@ -49,7 +49,6 @@ class optimize_timing_command : public alice::command opts.add_option("--sdc,-s", sdc_file, "SDC file."); opts.add_option("--clock,-c", clock_name, "Clock net."); opts.add_option("--abc_exec", abc_exec, "ABC executable, defaults to using path."); - opts.add_option("--temp-prefix", temp_prefix, "Filename prefix for temporary files. If not set, temporary files will be created by OS."); } protected: void execute() @@ -71,18 +70,18 @@ class optimize_timing_command : public alice::command auto ntk = *store>>().current(); mockturtle::depth_view orig_depth{ntk}; - oracle::partition_manager_junior partitions_jr = *store>>().current(); auto start = std::chrono::high_resolution_clock::now(); mockturtle::names_view ntk_result = - oracle::optimize_timing( + oracle::optimize_timing_tech( partitions_jr, liberty_file, mapping_file, sdc_file, clock_name, - output_file, abc_exec, temp_prefix); + output_file, abc_exec); auto stop = std::chrono::high_resolution_clock::now(); + mockturtle::depth_view new_depth{ntk_result}; if (ntk_result.size() == ntk.size() && orig_depth.depth() == new_depth.depth()) { @@ -107,7 +106,6 @@ class optimize_timing_command : public alice::command string sdc_file; string mapping_file; string clock_name; - string temp_prefix; string abc_exec{"abc"}; }; ALICE_ADD_COMMAND(optimize_timing, "Optimization"); diff --git a/core/commands/optimization/optimize_timing2.hpp b/core/commands/optimization/optimize_timing2.hpp new file mode 100644 index 000000000..8d7036eb7 --- /dev/null +++ b/core/commands/optimization/optimize_timing2.hpp @@ -0,0 +1,115 @@ +/* LSOracle: A learning based Oracle for Logic Synthesis + + * MIT License + * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#pragma once +#ifdef ENABLE_OPENSTA +#ifdef ENABLE_ABC + +#include +#include +#include +#include "algorithms/optimization/resynthesis.hpp" +#include "algorithms/partitioning/partition_manager_junior.hpp" + +namespace alice +{ +class optimize_timing2_command : public alice::command +{ + +public: + explicit optimize_timing2_command(const environment::ptr &env) + : command(env, "Perform timing driven mixed synthesis.") + { + opts.add_option("--output,-o", output_file, "Verilog output file.")->required(); + opts.add_option("--liberty,-l", liberty_file, "Liberty file."); + opts.add_option("--mapping", mapping_file, "Mapping verilog for registers and inverters."); + opts.add_option("--sdc,-s", sdc_file, "SDC file."); + opts.add_option("--clock,-c", clock_name, "Clock net."); + opts.add_option("--abc_exec", abc_exec, "ABC executable, defaults to using path."); +} +protected: + void execute() + { + resynth("AIG"); + } + + template + void resynth(string name) + { + if (store>>().empty()) { + env->err() << "No " << name << " stored\n"; + return; + } + if (store>>().empty()) { + env->err() << name << " not partitioned yet\n"; + return; + } + + auto ntk = *store>>().current(); + mockturtle::depth_view orig_depth{ntk}; + + oracle::partition_manager_junior partitions_jr = + *store>>().current(); + + auto start = std::chrono::high_resolution_clock::now(); + mockturtle::names_view ntk_result = + oracle::optimize_timing( + partitions_jr, + liberty_file, mapping_file, sdc_file, clock_name, + output_file, abc_exec); + auto stop = std::chrono::high_resolution_clock::now(); + + mockturtle::depth_view new_depth{ntk_result}; + if (ntk_result.size() == ntk.size() + && orig_depth.depth() == new_depth.depth()) { + env->err() << "No change made to network" << std::endl; + } + + env->out() << "Final ntk size = " << ntk_result.num_gates() << " and depth = " + << new_depth.depth() << "\n"; + env->out() << "Final number of latches = " << ntk_result.num_latches() << "\n"; + env->out() << "Node Depth Product = " + << ntk_result.num_gates() * new_depth.depth() + << "\n"; + auto duration = std::chrono::duration_cast + (stop - start); + env->out() << "Full Optimization: " << duration.count() << "ms\n"; + env->out() << "Finished optimization\n"; + store>>().extend() = + std::make_shared>(ntk_result); + } + string liberty_file; + string output_file; + string sdc_file; + string mapping_file; + string clock_name; + string abc_exec{"abc"}; +}; +ALICE_ADD_COMMAND(optimize_timing2, "Optimization"); +} + +#endif +#endif diff --git a/core/commands/optimization/oracle.hpp b/core/commands/optimization/oracle.hpp index 84ee10a76..aff0a6be9 100644 --- a/core/commands/optimization/oracle.hpp +++ b/core/commands/optimization/oracle.hpp @@ -32,11 +32,11 @@ #include #include - -#include #include #include -#include "algorithms/optimization/optimization_test.hpp" +#include +#include "algorithms/optimization/resynthesis.hpp" + namespace alice { @@ -44,141 +44,194 @@ class oracle_command : public alice::command { public: - explicit oracle_command(const environment::ptr &env) - : command(env, - "Partitions Stored AIG network, and Performs Mixed Synthesis on Network") - { - - opts.add_option("--partition,partition", num_partitions, - "Number of partitions (Network Size / 300 set as partitition number if not specified)"); - opts.add_option("--nn_model,-n", nn_model, - "Trained neural network model for classification"); - opts.add_option("--out,-o", out_file, + using aig_names = mockturtle::names_view; + using aig_ntk = std::shared_ptr; + using part_man_aig = oracle::partition_manager; + using part_man_aig_ntk = std::shared_ptr; + + using mig_names = mockturtle::names_view; + using mig_ntk = std::shared_ptr; + using part_man_mig = oracle::partition_manager; + using part_man_mig_ntk = std::shared_ptr; + + explicit oracle_command(const environment::ptr &env) + : command(env, + "Partitions current network using KaHyPar k-means hypergraph partitioner") + { + add_flag("--aig,-a", "Partition stored AIG (Default)"); + add_flag("--mig,-m", "Partition stored MIG"); + add_flag("--xag,-x", "Partition stored XAG"); + add_flag("--xmg,-g", "Partition stored XMG"); + + auto num_opt = opts.add_option("--num,num", num_partitions, + "Number of desired partitions"); + opts.add_option("--abc_exec", abc_exec, + "ABC executable, defaults to using path."); + opts.add_option("--size", size_partitions, + "Number of desired average nodes per partition.")->excludes(num_opt); + opts.add_option("--config_direc,-c", config_direc, + "Path to the configuration file for KaHyPar."); + opts.add_option("--initial,-i", initial_file, + "External file to write the initial partitions to."); + opts.add_option("--node_weights,-n", node_weight_file, + "External file containing node weights"); + opts.add_option("--edge_weights,-e", edge_weight_file, + "External file containing edge weights"); + add_flag("--sap,-s", "Apply Structure Aware Partitioning"); + opts.add_option("--epsilon", imbalance, + "Hypergraph partitioning epsilon imbalance parameter."); + opts.add_option("--strategy",strategych, "Strategy for optimization"); + opts.add_option("--out,-o", out_file, "output file to write resulting network to [.v, .blif]"); - opts.add_option("--strategy,-s", strategy, - "classification strategy [area delay product{DEFAULT}=0, area=1, delay=2]"); - opts.add_option("--config,-f", config_file, "Config file", true); - // add_flag("--bipart,-g", "Use BiPart from the Galois system for partitioning"); - add_flag("--aig,-a", "Perform only AIG optimization on all partitions"); - add_flag("--mig,-m", "Perform only MIG optimization on all partitions"); - add_flag("--combine,-c", - "Combine adjacent partitions that have been classified for the same optimization"); - //add_flag("--skip-feedthrough", "Do not include feedthrough nets when writing out the file"); -#ifdef ENABLE_GALOIS - // TODO replace this flag with a different letter, g is going to be xmg - add_flag("--bipart,-g", "Use BiPart from the Galois system for partitioning"); -#endif - } - -protected: - void execute() - { - - if (!store().empty()) { - env->out() << "\n\n\n1\n"; - auto ntk = *store().current(); - env->out() << "\n\n\n2\n"; - - //If number of partitions is not specified - if (num_partitions == 0) { - env->out() << "\n\n\nif1\n"; + + } + + protected: - double size = ((double) ntk.size()) / 300.0; - num_partitions = ceil(size); + template + void partition_network(string name) + { + if (store>>().empty()) { + env->err() << name << " network not stored\n"; + return; } - env->out() << "\n\n\n3\n"; + mockturtle::names_view ntk = + *store>>().current(); - mockturtle::depth_view orig_depth{ntk}; - if (config_file == "") { - config_file = make_temp_config(); + + if (num_partitions == 0) { + num_partitions = std::max(ntk.size() / size_partitions, 1u); } - env->out() << "\n\n\n4\n"; - env->out() << "constructing partition manager with " << num_partitions << - " partitionis and config_file: " << config_file << "\n"; - - oracle::partition_manager partitions(ntk, num_partitions, - config_file); - env->out() << "\n\n\n5\n"; - - store().extend() = std::make_shared(partitions); - - env->out() << ntk.get_network_name() << " partitioned " << num_partitions << - " times\n"; - if (!nn_model.empty()) - high = false; - else - high = true; - if (is_set("aig")) - aig = true; - if (is_set("mig")) - mig = true; - if (is_set("combine")) - combine = true; - - auto start = std::chrono::high_resolution_clock::now(); - - auto ntk_mig = oracle::optimization_test(ntk, partitions, strategy, nn_model, - high, aig, mig, combine); - - auto stop = std::chrono::high_resolution_clock::now(); - - mockturtle::depth_view new_depth{ntk_mig}; - if (ntk_mig.size() != ntk.size() || orig_depth.depth() != new_depth.depth()) { - env->out() << "Final ntk size = " << ntk_mig.num_gates() << " and depth = " << - new_depth.depth() << "\n"; - env->out() << "Final number of latches = " << ntk_mig.num_latches() << "\n"; - // env->out() << "Area Delay Product = " << ntk_mig.num_gates() * new_depth.depth() << "\n"; - auto duration = std::chrono::duration_cast - (stop - start); - env->out() << "Full Optimization: " << duration.count() << "ms\n"; - // env->out() << "Finished optimization\n"; - store().extend() = std::make_shared(ntk_mig); - env->out() << "MIG network stored\n"; - - if (out_file != "") { + env->out() << "Using " << num_partitions << " partitions" << std::endl; + + int *node_weights = nullptr; + int *edge_weights = nullptr; + if (edge_weight_file != "") { + env->out() << "Reading edge weights from " << edge_weight_file << std::endl; + std::vector data = read_integer_file(edge_weight_file); + edge_weights = &data[0]; + } + if (node_weight_file != "") { + env->out() << "Reading node weights from " << node_weight_file << std::endl; + std::vector data = read_integer_file(node_weight_file); + if (data.size() != ntk.size()) { + env->out() << "Node weight file contains the incorrect number of nodes: got " << + data.size() << " expected " << ntk.size() << std::endl; + exit(1); + } else { + node_weights = &data[0]; + } + } + + if (config_direc == "") { + config_direc = make_temp_config(); + } + env->out() << "Using KaHyPar configuration " << config_direc << std::endl; + + oracle::kahypar_partitioner partitioner(ntk, + num_partitions, + config_direc, + node_weights, + edge_weights, + imbalance); + + store>>().extend() = + std::make_shared>(partitioner.partition_manager()); + + } + + void execute() + { + synth("AIG"); + } + + template + void synth(string name){ + + if (is_set("mig")) { + partition_network("MIG"); + } else if (is_set("xag")) { + partition_network("XAG"); + } else if (is_set("xmg")) { + partition_network("XMG"); + } else { + partition_network("AIG"); + } + + auto ntk = *store>>().current(); + oracle::partition_manager_junior partitions_jr = + *store>>().current(); + + mockturtle::depth_view orig_depth(partitions_jr.get_network()); + auto start = std::chrono::high_resolution_clock::now(); + mockturtle::names_view ntk_result; + + oracle::optimization_strategy strategy; + if (strategych=="depth") { + strategy = oracle::optimization_strategy::depth; + } else if (strategych=="nodes") { + strategy = oracle::optimization_strategy::size; + } else { + strategy = oracle::optimization_strategy::balanced; + } + ntk_result = oracle::optimize_basic(partitions_jr, abc_exec, strategy,false); + + auto stop = std::chrono::high_resolution_clock::now(); + mockturtle::depth_view new_depth(ntk_result); + + + if (ntk_result.size() == partitions_jr.get_network().size() + && orig_depth.depth() == new_depth.depth()) { + env->err() << "No change made to network" << std::endl; + } + + env->out() << "Final ntk size = " << ntk_result.num_gates() << " and depth = " + << new_depth.depth() << "\n"; + env->out() << "Final number of latches = " << ntk_result.num_latches() << "\n"; + env->out() << "Node Depth Product = " + << ntk_result.num_gates() * new_depth.depth() + << "\n"; + auto duration = std::chrono::duration_cast + (stop - start); + env->out() << "Full Optimization: " << duration.count() << "ms\n"; + env->out() << "Finished optimization\n"; + store>>().extend() = + std::make_shared>(ntk_result); + if (out_file != "") { if (oracle::checkExt(out_file, "v")) { mockturtle::write_verilog_params ps; //might be nice to have again, but for now commenting this out to allow us to use stock mockturtle I/O //if(is_set("skip-feedthrough")) //ps.skip_feedthrough = 1u; - mockturtle::write_verilog(ntk_mig, out_file, ps); + mockturtle::write_verilog(ntk_result, out_file, ps); env->out() << "Resulting network written to " << out_file << "\n"; } else if (oracle::checkExt(out_file, "blif")) { mockturtle::write_blif_params ps; //if(is_set("skip-feedthrough")) //ps.skip_feedthrough = 1u; - mockturtle::write_blif(ntk_mig, out_file, ps); + mockturtle::write_blif(ntk_result, out_file, ps); env->out() << "Resulting network written to " << out_file << "\n"; } else { env->err() << out_file << " is not an accepted output file {.v, .blif}\n"; } } - } else { - env->out() << "No change made to network\n"; - store().extend() = std::make_shared(ntk_mig); - env->out() << "MIG network stored\n"; - } - } else { - env->err() << "AIG network not stored\n"; } - } -private: - std::string filename{}; - int num_partitions{0u}; - std::string nn_model{}; - std::string out_file{}; - std::string config_file{}; - unsigned strategy{0u}; - bool high = false; - bool aig = false; - bool mig = false; - bool combine = false; -#ifdef ENABLE_GALOIS - bool bipart = false; -#endif -}; + private: + uint32_t num_partitions = 0; + uint32_t size_partitions = 2048; + std::string config_direc = ""; + // std::string output_file = ""; + std::string initial_file = ""; + std::string edge_weight_file = ""; + std::string node_weight_file = ""; + double imbalance = 0.9; + std::string out_file{}; + std:: string strategych={""}; + string abc_exec{"abc"}; + + }; ALICE_ADD_COMMAND(oracle, "Optimization"); } diff --git a/core/commands/output/write_partition.hpp b/core/commands/output/write_partition.hpp index 32dadb5f8..63bc68e2f 100644 --- a/core/commands/output/write_partition.hpp +++ b/core/commands/output/write_partition.hpp @@ -1,5 +1,4 @@ /* LSOracle: A learning based Oracle for Logic Synthesis - * MIT License * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) * @@ -34,21 +33,15 @@ #include #include +#include +#include "algorithms/optimization/resynthesis.hpp" + namespace alice { class write_partition_command : public alice::command { - using aig_names = mockturtle::names_view; - using aig_ntk = std::shared_ptr; - using part_man_aig = oracle::partition_manager; - using part_man_aig_ntk = std::shared_ptr; - - using mig_names = mockturtle::names_view; - using mig_ntk = std::shared_ptr; - using part_man_mig = oracle::partition_manager; - using part_man_mig_ntk = std::shared_ptr; public: explicit write_partition_command(const environment::ptr &env) @@ -58,30 +51,39 @@ class write_partition_command : public alice::command opts.add_option("--filename,filename", filename, "BLIF file to write out to")->required(); opts.add_option("--num,-n", partnum, "Part to write."); + add_flag("--aig,-a", "Partition stored AIG (Default)"); + add_flag("--mig,-m", "Partition stored MIG"); + add_flag("--xag,-x", "Partition stored XAG"); + add_flag("--xmg,-g", "Partition stored XMG"); } -protected: - void execute() - { - auto ntk_aig = *store().current(); - auto partitions_aig = *store().current(); - - auto ntk_mig = *oracle::aig_to_mig(ntk_aig, 1); - - part_man_mig partitions(ntk_mig, - partitions_aig.get_all_part_connections(), - partitions_aig.get_all_partition_inputs(), - partitions_aig.get_all_partition_outputs(), - partitions_aig.get_all_partition_regs(), - partitions_aig.get_all_partition_regin(), partitions_aig.get_part_num()); - - - mockturtle::write_blif_params ps; - auto part = partitions.create_part(ntk_mig, partnum); - auto mig = oracle::part_to_mig(part, 0); +public: - mockturtle::write_blif(*mig, filename, ps); + template + void write_part(string name){ + oracle::partition_manager_junior partitions =*store>>().current(); + mockturtle::names_view &ntk = partitions.get_network(); + std::string output_file = std::string(filename); + std::cout << "Writing out to " << output_file << std::endl; + std::ofstream verilog(output_file); + verilog << "// Generated by LSOracle" << std::endl; + std::vector optimized(partitions.count()); + for (int i = 0; i < partitions.count(); i++) { + oracle::write_child(i, partitions, verilog); + } + } + void execute() + { + if (is_set("mig")) { + write_part("MIG"); + } else if (is_set("xag")) { + write_part("XAG"); + } else if (is_set("xmg")) { + write_part("XMG"); + } else { + write_part("AIG"); + } } private: std::string filename{}; diff --git a/core/commands/partitioning/partition_detail.hpp b/core/commands/partitioning/partition_detail.hpp index b68e8ca0b..23a622845 100644 --- a/core/commands/partitioning/partition_detail.hpp +++ b/core/commands/partitioning/partition_detail.hpp @@ -1,5 +1,4 @@ /* LSOracle: A learning based Oracle for Logic Synthesis - * MIT License * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) * @@ -35,6 +34,10 @@ #include #include +#include +#include "algorithms/optimization/resynthesis.hpp" + + namespace alice { @@ -45,112 +48,74 @@ class partition_detail_command : public alice::command explicit partition_detail_command(const environment::ptr &env) : command(env, "Display all nodes in each Partition") { - - add_flag("--mig,-m", "Use stored MIG network (Default is AIG)"); - add_flag("--names,-n", "Use stored named networks (Default is Named AIG)"); + add_flag("--aig,-a", "Partition stored AIG (Default)"); + add_flag("--mig,-m", "Partition stored MIG"); + add_flag("--xag,-x", "Partition stored XAG"); + add_flag("--xmg,-g", "Partition stored XMG"); } protected: - void execute() - { - - if (is_set("mig")) { - if (!store().empty()) { - auto ntk = store().current(); - if (!store().empty()) { - auto partitions = store().current(); - int num_part = partitions->get_part_num(); + template + void partition_det(string name){ + if (!store>>().empty()) { + if (!store>>().empty()) { + mockturtle::names_view ntk = *store>>().current(); + if (!store>>().empty()) { + oracle::partition_manager_junior partitions_jr =*store>>().current(); + mockturtle::depth_view orig_depth(partitions_jr.get_network()); + int num_parts = partitions_jr.count(); double node_num = 0.0; - for (int i = 0; i < num_part; i++) { - oracle::partition_view part = partitions->create_part(*ntk, i); - env->out() << "\n\nPartition " << i << "\n"; - env->out() << "Number of PI = " << part.num_pis() << "\n"; - env->out() << "Number of PO = " << part.num_pos() << "\n"; - env->out() << "Number of latches = " << part.num_latches() << "\n"; - env->out() << "Number of internal nodes = " << part.num_gates() << "\n"; - env->out() << "Partition volume = " << double(part.num_gates()) / double( - part.num_pis()) << "\n"; - node_num += double(part.num_gates()) / double(part.num_pis()); - // env->out() << "Inputs = {"; - // part.foreach_pi([&](auto pi){ - // env->out() << pi << " "; - // }); - // env->out() << "}\n"; - // env->out() << "Outputs = {"; - // part.foreach_po([&](auto conn, auto i){ - // env->out() << conn.index << " "; - // }); - // env->out() << "}\n"; - // env->out() << "Nodes = {"; - // part.foreach_gate([&](auto node){ - // env->out() << node << " "; - // }); - // env->out() << "}\n"; - std::set connected_parts = partitions->get_connected_parts(*ntk, i); - std::set::iterator it; - env->out() << "connected partitions = {"; - for (it = connected_parts.begin(); it != connected_parts.end(); ++it) { - env->out() << *it << " "; - } - env->out() << "}\n"; - } - node_num = node_num / (double)num_part; - env->out() << "Average nodes per partition: " << node_num << "\n"; - } else { - env->err() << "MIG not partitioned yet\n"; - } - } else { - env->err() << "There is no MIG network stored\n"; - } - } else { - if (!store().empty()) { - auto ntk = store().current(); - if (!store().empty()) { - auto partitions = store().current(); - int num_part = partitions->get_part_num(); - double node_num = 0.0; - for (int i = 0; i < num_part; i++) { - oracle::partition_view part = partitions->create_part(*ntk, i); - env->out() << "\n\nPartition " << i << "\n"; - env->out() << "Number of PI = " << part.num_pis() << "\n"; - env->out() << "Number of PO = " << part.num_pos() << "\n"; - env->out() << "Number of latches = " << part.num_latches() << "\n"; - env->out() << "Number of internal nodes = " << part.num_gates() << "\n"; - - env->out() << "Partition volume = " << double(part.num_gates()) / double( - part.num_pis()) << "\n"; - node_num += double(part.num_gates()) / double(part.num_pis()); + for (int i =0; ierr() << "partitions_jr.get_network().size() \n" <out() << "\n\nPartition " << "\n"; + env->out() << "Number of PI = " << partitions_jr.get_network().num_pis() << "\n"; + env->out() << "Number of PO = " << partitions_jr.get_network().num_pos() << "\n"; + env->out() << "Number of latches = " << partitions_jr.get_network().num_latches() << "\n"; + env->out() << "Number of internal nodes = " << partitions_jr.get_network().num_gates() << "\n"; + env->out() << "Partition volume = " << double(partitions_jr.get_network().num_gates()) / double( + partitions_jr.get_network().num_pis()) << "\n"; + node_num += double(partitions_jr.get_network().num_gates()) / double(partitions_jr.get_network().num_pis()); env->out() << "Inputs = {"; - part.foreach_pi([&](auto pi) { + partitions_jr.get_network().foreach_pi([&](auto pi) { env->out() << pi << " "; }); env->out() << "}\n"; env->out() << "Outputs = {"; - part.foreach_po([&](auto conn, auto i) { + + partitions_jr.get_network().foreach_po([&](auto conn, auto i) { env->out() << conn.index << " "; }); env->out() << "}\n"; env->out() << "Nodes = {"; - part.foreach_gate([&](auto node) { + partitions_jr.get_network().foreach_gate([&](auto node) { env->out() << node << " "; }); env->out() << "}\n"; - std::set connected_parts = partitions->get_connected_parts(*ntk, i); - std::set::iterator it; - env->out() << "connected partitions = {"; - for (it = connected_parts.begin(); it != connected_parts.end(); ++it) { - env->out() << *it << " "; - } - env->out() << "}\n"; } - node_num = node_num / (double)num_part; - env->out() << "Average partition volume: " << node_num << "\n"; + node_num = node_num / (double)num_parts; + env->out() << "Average nodes per partition: " << node_num << "\n"; + } else { - env->err() << "AIG not partitioned yet\n"; + env->err() << name <<" not partitioned yet\n"; } - } else { - env->err() << "There is no AIG network stored\n"; } + } else { + env->err() << "There is no "<("MIG"); + } else if (is_set("xag")) { + partition_det("XAG"); + } else if (is_set("xmg")) { + partition_det("XMG"); + } else { + partition_det("AIG"); } } private: diff --git a/core/commands/partitioning/partitioning.hpp b/core/commands/partitioning/partitioning.hpp deleted file mode 100644 index a3f9730c7..000000000 --- a/core/commands/partitioning/partitioning.hpp +++ /dev/null @@ -1,248 +0,0 @@ -/* LSOracle: A learning based Oracle for Logic Synthesis - - * MIT License - * Copyright 2019 Laboratory for Nano Integrated Systems (LNIS) - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ -#pragma once -#include -#include -#include "algorithms/partitioning/partition_manager.hpp" - -#include -#include - -#include -#include -// #include -#include "kahypar_config.hpp" -#ifdef ENABLE_GALOIS -#include -#endif - -namespace alice -{ -class partitioning_command : public alice::command -{ - -public: - using aig_names = mockturtle::names_view; - using aig_ntk = std::shared_ptr; - using part_man_aig = oracle::partition_manager; - using part_man_aig_ntk = std::shared_ptr; - - using mig_names = mockturtle::names_view; - using mig_ntk = std::shared_ptr; - using part_man_mig = oracle::partition_manager; - using part_man_mig_ntk = std::shared_ptr; - - explicit partitioning_command(const environment::ptr &env) - : command(env, - "Partitions current network using k-means hypergraph partitioner") - { - - auto num_opt = opts.add_option("--num,num", num_partitions, - "Number of desired partitions"); - opts.add_option("--size", size_partitions, - "Number of desired average nodes per partition.")->excludes(num_opt); - opts.add_option("--config_direc,-c", config_direc, - "Path to the configuration file for KaHyPar."); - opts.add_option("--file,-f", part_file, - "External file containing partition information"); - opts.add_option("--output,-o", output_file, - "External file to write the generated partitions to."); - opts.add_option("--initial,-i", initial_file, - "External file to write the initial partitions to."); - opts.add_option("--node_weights,-n", node_weight_file, - "External file containing node weights"); - opts.add_option("--edge_weights,-e", edge_weight_file, - "External file containing edge weights"); - add_flag("--mig,-m", "Partitions stored MIG network (AIG network is default)"); - add_flag("--sap,-s", "Apply Structure Aware Partitioning"); - opts.add_option("--epsilon", imbalance, - "Hypergraph partitioning epsilon imbalance parameter."); -#ifdef ENABLE_GALOIS - add_flag("--bipart,-g", - "Run hypergraph partitionining using BiPart from the Galois system"); -#endif - } - -protected: - std::vector read_file(string filename) - { - std::vector output; - std::ifstream ifs; - - ifs.open(filename); - if (ifs.is_open()) { - while (ifs.good()) { - std::string part; - getline(ifs, part); - output.push_back(std::stoi(part)); - } - ifs.close(); - return output; - } else { - env->err() << "Unable to open partition data file\n"; - throw exception(); - } - } - - template - void process_network(string type_name) - { - auto ntk = *store().current(); - if (part_file != "") { - env->out() << "Partitioning stored " << type_name << - " network using external file\n"; - std::map part_data; - std::vector parts = read_file(part_file); - if (parts.size() != ntk.size()) { - env->out() << "Partition file contains the incorrect number of nodes\n"; - exit(1); - } - for (int i = 0; i < parts.size(); i++) { - part_data[ntk.index_to_node(i)] = parts[i]; - } - oracle::partition_manager partitions(ntk, part_data, num_partitions); - store().extend() = std::make_shared(partitions); - } else { -#ifdef ENABLE_GALOIS - if (is_set("bipart")) { - env->out() << "Partitioning stored " << type_name << - " network using Galois BiPart\n"; - oracle::hypergraph t(ntk); - uint32_t num_vertices = 0; - - t.get_hypergraph(ntk); - std::vector> hedges = t.get_hyperedges(); - num_vertices = t.get_num_vertices(); - - int num_threads = 14; - scheduleMode mode = PP; - std::map bipart = biparting(hedges, num_vertices, num_partitions, - num_threads, mode); - std::map part_data; - ntk.foreach_node([&](auto node) { - part_data[node] = bipart[node]; - }); - - oracle::partition_manager partitions(ntk, part_data, num_partitions); - store().extend() = std::make_shared(partitions); - } else -#endif - { - env->out() << "Partitioning stored " << type_name << " network using KaHyPar\n"; - - int *node_weights = nullptr; - int *edge_weights = nullptr; - if (edge_weight_file != "") { - env->out() << "Reading edge weights from " << edge_weight_file << std::endl; - std::vector data = read_file(edge_weight_file); - edge_weights = &data[0]; - } - if (node_weight_file != "") { - env->out() << "Reading node weights from " << node_weight_file << std::endl; - std::vector data = read_file(node_weight_file); - if (data.size() != ntk.size()) { - env->out() << "Node weight file contains the incorrect number of nodes: got " << - data.size() << " expected " << ntk.size() << std::endl; - exit(1); - } else { - node_weights = &data[0]; - } - } - - if (num_partitions == 0) { - num_partitions = std::max(ntk.size() / size_partitions, 1u); - } - env->out() << "Using " << num_partitions << " partitions" << std::endl; - - if (config_direc == "") { - config_direc = make_temp_config(); - } - env->out() << "Using KaHyPar configuration " << config_direc << std::endl; - - if (is_set("sap")) { - env->out() << "Using structure aware partitioning" << std::endl; - } - - oracle::partition_manager partitions(ntk, num_partitions, - config_direc, node_weights, edge_weights, is_set("sap"), imbalance); - store().extend() = std::make_shared(partitions); - - if (output_file != "") { - std::ofstream out; - out.open(output_file); - auto parts = partitions.get_partitions(); - for (auto i = parts.begin(); i != parts.end(); i++) { - out << *i << std::endl; - } - out.close(); - } - - if (initial_file != "") { - std::ofstream out; - out.open(initial_file); - auto init = partitions.get_initial_partitions(); - for (auto i = init.begin(); i != init.end(); i++) { - out << *i << std::endl; - } - out.close(); - } - } - } - } - void execute() - { - mockturtle::mig_npn_resynthesis resyn_mig; - mockturtle::xag_npn_resynthesis resyn_aig; - - if (is_set("mig")) { - if (!store().empty()) { - process_network("MIG"); - } else { - env->err() << "MIG network not stored\n"; - } - } else { - if (!store().empty()) { - process_network("AIG"); - } else { - env->err() << "AIG network not stored\n"; - } - } - } -private: - uint32_t num_partitions = 0; - uint32_t size_partitions = 2048; - std::string config_direc = ""; - std::string part_file = ""; - std::string output_file = ""; - std::string initial_file = ""; - std::string edge_weight_file = ""; - std::string node_weight_file = ""; - double imbalance = 0.9; -}; - -ALICE_ADD_COMMAND(partitioning, "Partitioning"); -} diff --git a/core/config.h.in b/core/config.h.in index 89df51ada..90cf6a11a 100644 --- a/core/config.h.in +++ b/core/config.h.in @@ -2,3 +2,5 @@ #cmakedefine LSORACLE_GIT_REVISION "@LSORACLE_GIT_REVISION@" #cmakedefine LSORACLE_VERSION "@LSORACLE_VERSION@" + +std::string temp_prefix = ""; diff --git a/core/lsoracle.cpp b/core/lsoracle.cpp index 366549402..d858a82e7 100644 --- a/core/lsoracle.cpp +++ b/core/lsoracle.cpp @@ -58,12 +58,12 @@ #include "algorithms/optimization/mig_script3.hpp" #include "algorithms/optimization/test_script.hpp" #include "algorithms/optimization/optimization.hpp" +#include "algorithms/optimization/optimization_test.hpp" #include "algorithms/optimization/xmg_script.hpp" #include "algorithms/optimization/xag_script.hpp" #include "algorithms/optimization/mab.hpp" #include "algorithms/optimization/deep.hpp" #include "algorithms/optimization/parser.hpp" -#include "algorithms/optimization/optimization_test.hpp" //#include "algorithms/optimization/four_way_optimization.hpp" //#include "algorithms/output/part_verilog.hpp" #include "algorithms/output/rtlil.hpp" @@ -122,7 +122,6 @@ #include "commands/stats/write_stats.hpp" //Partitioning -#include "commands/partitioning/partitioning.hpp" #include "commands/partitioning/partition_detail.hpp" #include "commands/partitioning/kahypar.hpp" #include "commands/partitioning/external_partition.hpp" @@ -137,12 +136,14 @@ #include "commands/optimization/migtune.hpp" #include "commands/optimization/migscript.hpp" #include "commands/optimization/testscript.hpp" -#include "commands/optimization/optimization_command.hpp" #include "commands/optimization/depthr.hpp" +#include "commands/optimization/exploderize.hpp" #include "commands/optimization/cut_e.hpp" #include "commands/optimization/cut_rewriting.hpp" #include "commands/optimization/optimize_timing.hpp" +#include "commands/optimization/optimize_timing2.hpp" #include "commands/optimization/optimize.hpp" +#include "commands/optimization/abc.hpp" #include "commands/optimization/interleaving.hpp" //#include "commands/optimization/balance.hpp" //seem to be having some shared pointer issues. Shouldn't be hard, but we never use this alone, so come back to it #include "commands/optimization/refactor.hpp" @@ -180,6 +181,7 @@ #include #include #include + namespace sta { extern const char *tcl_inits[]; } @@ -190,6 +192,7 @@ extern int Sta_Init(Tcl_Interp *interp); int main(int argc, char ** argv) { + #ifdef ENABLE_OPENSTA sta::Sta *test = new sta::Sta; diff --git a/core/utility.cpp b/core/utility.cpp index f4874b50d..7ec92cd0d 100644 --- a/core/utility.cpp +++ b/core/utility.cpp @@ -704,9 +704,14 @@ template function_counts node_functions(const xmg_names&); template function_counts node_functions(const aig_names&); template function_counts node_functions(const xag_names&); } +bool is_digits(const std::string &str) +{ + return std::all_of(str.begin(), str.end(), ::isdigit); // C++11 +} std::vector read_integer_file(string filename) { + std::vector output; std::ifstream ifs; @@ -715,7 +720,8 @@ std::vector read_integer_file(string filename) while (ifs.good()) { std::string part; getline(ifs, part); - if (part != "") + std::cout<<"part:"< read_integer_file(string filename); diff --git a/lib/mockturtle b/lib/mockturtle index fb8f87982..20247bee2 160000 --- a/lib/mockturtle +++ b/lib/mockturtle @@ -1 +1 @@ -Subproject commit fb8f879829f269692f211bb6026bc34a6ca508b6 +Subproject commit 20247bee2ff64c27f28b99e6d347b743a18698d4 diff --git a/yosys-plugin/oracle.cc b/yosys-plugin/oracle.cc index 0341f7a59..8693a0435 100755 --- a/yosys-plugin/oracle.cc +++ b/yosys-plugin/oracle.cc @@ -1128,7 +1128,7 @@ void abc_module(RTLIL::Design *design, RTLIL::Module *current_module, std::strin printf("Finished LSO\n"); - std::string cec_script = stringf("cec %s %s", aiger_temp_file.c_str(), blif_output_file.c_str()); + std::string cec_script = stringf("cec -n %s %s", aiger_temp_file.c_str(), blif_output_file.c_str()); cec_script = add_echos_to_abc_cmd(cec_script); for (size_t i = 0; i+1 < cec_script.size(); i++)