aigverse.abc¶
Bridge to the external ABC logic synthesis system.
aigverse does not ship ABC. This module drives an ABC executable that is
already installed on the machine, transferring networks as binary AIGER files.
Point it at an executable with the AIGVERSE_ABC environment variable or
set_abc_binary(), or put abc on PATH.
Importing this module always succeeds, whether or not ABC is installed. Use
is_available() to check, and expect AbcNotFoundError from any call
that needs the executable.
The ABC9 (&-space) commands live in the gia namespace,
mirroring ABC’s own prefix: abc.dc2 runs ABC’s dc2 while abc.gia.dc2
runs its &dc2.
Example
>>> from aigverse import abc
>>> from aigverse.generators import ripple_carry_adder
>>> aig = ripple_carry_adder(4)
>>> if abc.is_available():
... optimized = abc.resyn2(aig)
... alternative = abc.gia.dc2(aig)
Submodules¶
Package Contents¶
- run_many(networks: Iterable[aigverse.abc._runner.AigT], commands: str | aigverse.abc._runner.Command | Sequence[str | aigverse.abc._runner.Command], *, jobs: int | None = ..., timeout: float | None = ..., use_init_file: bool = ..., gia: bool = ..., binary: str | PathLike[str] | None = ..., return_exceptions: Literal[False] = False) list[aigverse.abc._runner.AigT][source]¶
- run_many(networks: Iterable[aigverse.abc._runner.AigT], commands: str | aigverse.abc._runner.Command | Sequence[str | aigverse.abc._runner.Command], *, jobs: int | None = ..., timeout: float | None = ..., use_init_file: bool = ..., gia: bool = ..., binary: str | PathLike[str] | None = ..., return_exceptions: Literal[True]) list[aigverse.abc._runner.AigT | aigverse.abc._errors.AbcError]
- run_many(networks: Iterable[aigverse.abc._runner.AigT], commands: str | aigverse.abc._runner.Command | Sequence[str | aigverse.abc._runner.Command], *, jobs: int | None = ..., timeout: float | None = ..., use_init_file: bool = ..., gia: bool = ..., binary: str | PathLike[str] | None = ..., return_exceptions: bool) list[aigverse.abc._runner.AigT] | list[aigverse.abc._runner.AigT | aigverse.abc._errors.AbcError]
Runs one ABC script over many networks, in parallel.
The same script is applied to every network, each in its own ABC process. The bridge already isolates a call completely – its own temporary directory, its own working directory, its own
abc.history– so the runs simply overlap. A cross product of scripts and networks is one call per script:for name, script in recipes.items(): rows[name] = abc.run_many(designs, script)
Results come back in input order, never completion order, so
zip(networks, results)is always valid. Every result is held at once regardless ofjobs, which is the memory a whole corpus costs.Expect a speedup below the number of cores: a batch is as slow as its slowest network.
- Parameters:
networks – The networks to optimize. Consumed in full before any work starts.
commands – A single
;-separated ABC command string, aCommand, or a sequence of individual commands. The same script runs on every network. The canonical scripts are reachable throughexpand_script(), and a parameterized one through each wrapper’scmd().jobs – How many ABC processes to keep running at once.
None(default) uses the number of CPUs available to this process, capped at the number of networks;1runs inline without a thread pool. On large designs memory rather than CPU is what limits this, since each worker holds a whole ABC in flight. A CPU quota –docker --cpus=2– is not visible here, so setjobsexplicitly under one.timeout – Seconds to wait for ABC to terminate, per network rather than for the batch as a whole, or
Nonefor no limit.use_init_file – If
False(default), ABC is invoked with-sso that noabc.rcis read and results do not depend on the local install.gia – If
True, transfer each network through&read/&writeso it lands in ABC9’s GIA store, asrun_script()does.binary – Overrides the resolved ABC executable for this call only. It is resolved once for the whole batch.
return_exceptions – If
False(default), the first failure aborts the batch and is raised, asrun_script()would. IfTrue, each failing network yields itsAbcErrorin place of a result, so one bad design does not lose a whole sweep. Only anAbcErroris captured: aTypeErrorfrom an unsupported network type, aValueErrorfrom an invalid script, and anything else that goes wrong are raised either way, because those are faults in the call rather than per-item ABC failures.
- Returns:
The optimized networks, in input order, each of the same type as its input – with
AbcErrorinstances in place of the failures whenreturn_exceptionsis set.- Raises:
TypeError – If any element of
networksis not anAig.ValueError – If
jobsis below 1, if no command was given, or ifgiais set and a network has a register whose reset value is undefined.AbcNotFoundError – If no ABC executable could be located. Resolution happens once before any network is run, so this is raised whatever
return_exceptionssays.AbcTimeoutError – If ABC did not terminate within
timeoutseconds for some network andreturn_exceptionsis not set.AbcExecutionError – If ABC reported an error for some network and
return_exceptionsis not set.
Note
Which failure is reported when several networks fail is unspecified; use
return_exceptions=Trueto see all of them. There is noverbose: nothing inside an ABC transcript says which network produced it, so a failure’soutput– reachable throughreturn_exceptions– is what carries that.Note
Interrupting a batch drops the networks that have not started yet. Ctrl-C in a terminal reaches the running ABC processes too, because they share the foreground process group, but an interrupt delivered to the interpreter alone does not –
run_commandskeeps no handle on what it spawned, sotimeoutis what bounds those.
- ABC_ENV_VAR = 'AIGVERSE_ABC'¶
- ABC_RC_ENV_VAR = 'AIGVERSE_ABC_RC'¶
- abc_binary() Path[source]¶
Resolves the ABC executable.
- Returns:
The resolved absolute path to the ABC executable.
- Raises:
AbcNotFoundError – If no ABC executable could be located.
- abc_rc() Path | None[source]¶
Resolves the ABC resource file loaded before every command.
Resolution order: an explicit path set via
set_abc_rc(), then theAIGVERSE_ABC_RCenvironment variable.- Returns:
The resolved absolute path, or
Noneif no resource file is configured.
- abc_version(*, timeout: float | None = 10.0) str[source]¶
Queries the version banner of the resolved ABC executable.
Useful to confirm that whatever was discovered really is Berkeley ABC, since discovery itself deliberately does not start a process.
- Parameters:
timeout – Seconds to wait for ABC to respond, or
Noneto wait forever.- Returns:
The trimmed output of ABC’s
versioncommand.- Raises:
AbcNotFoundError – If no ABC executable could be located.
AbcTimeoutError – If ABC did not terminate within
timeoutseconds.AbcExecutionError – If the executable did not accept the
versioncommand, which means whatever was discovered is not ABC.
- find_abc_binary() Path | None[source]¶
Resolves the ABC executable without raising.
Resolution order: an explicit override set via
set_abc_binary(), then theAIGVERSE_ABCenvironment variable, then aPATHlookup forabcandberkeley-abc.- Returns:
The resolved absolute path, or
Noneif no candidate was found.
- is_available() bool[source]¶
Reports whether an ABC executable can be located.
This never raises and never starts a process, so it is safe to call in a module guard or a test skip condition.
- Returns:
Trueif an ABC executable was found,Falseotherwise.
- set_abc_binary(path: str | PathLike[str] | None) Path | None[source]¶
Sets or clears an explicit path to the ABC executable.
The explicit override takes precedence over the
AIGVERSE_ABCenvironment variable and over aPATHlookup. It applies process-wide and is intended to be called once during setup; it is not thread-safe.- Parameters:
path – Path to the ABC executable, or
Noneto clear a previously set override and fall back to environment andPATHdiscovery.- Returns:
The resolved absolute path, or
Noneif the override was cleared.- Raises:
AbcNotFoundError – If
pathdoes not exist or is not executable.
- set_abc_rc(path: str | PathLike[str] | None) Path | None[source]¶
Sets or clears an ABC resource file to load before every command.
The bridge normally runs ABC with
-sso that noabc.rcis read and results do not depend on the local installation. Registering a resource file here keeps that isolation – the file given is the only one loaded – while making its aliases available torun_script()andrun_commands().It applies process-wide and is intended to be called once during setup; it is not thread-safe.
- Parameters:
path – Path to an ABC resource file, or
Noneto clear a previously set one and go back to running without any.- Returns:
The resolved absolute path, or
Noneif the resource file was cleared.- Raises:
AbcNotFoundError – If
pathdoes not exist or is not a file.
- class Balance[source]¶
Bases:
aigverse.abc._runner.CommandWrapperRuns ABC’s
balancecommand on a network, or builds it as a command.- static cmd(*, minimize_levels: bool = True, exor: bool = False, duplicate: bool = False, duplicate_critical: bool = False) aigverse.abc._runner.Command[source]¶
Builds ABC’s
balancecommand without running it.- Parameters:
minimize_levels – If
True(ABC’s default), balance for minimal depth.exor – If
True, balance multi-input EXOR structures as well.duplicate – If
True, allow logic to be duplicated.duplicate_critical – If
True, duplicate logic on the critical paths only, which buys depth for less area thanduplicatedoes.
- Returns:
The command, ready for
run_script()orrun_many().
- __call__(ntk: aigverse.abc._runner.AigT, *, minimize_levels: bool = True, exor: bool = False, duplicate: bool = False, duplicate_critical: bool = False, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
balancecommand on a network.Restructures the AND trees of the network to reduce its depth.
- Parameters:
ntk – The network to optimize.
minimize_levels – If
True(ABC’s default), balance for minimal depth.exor – If
True, balance multi-input EXOR structures as well.duplicate – If
True, allow logic to be duplicated.duplicate_critical – If
True, duplicate logic on the critical paths only, which buys depth for less area thanduplicatedoes.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- class Orchestrate[source]¶
Bases:
aigverse.abc._runner.CommandWrapperRuns ABC’s
orchestratecommand on a network, or builds it as a command.- static cmd(*, max_cut_size: int | None = None, max_inserts: int | None = None, odc_levels: int | None = None, preserve_levels: bool = True, zero_cost_rewrite: bool = True, zero_cost_refactor: bool = True) aigverse.abc._runner.Command[source]¶
Builds ABC’s
orchestratecommand without running it.- Parameters:
max_cut_size – Resubstitution cut size (ABC’s
-K, 4 to 16), orNonefor ABC’s default of 8.max_inserts – Nodes resubstitution may add (ABC’s
-N, 0 to 3), orNonefor ABC’s default of 1.odc_levels – Fanout levels used for don’t-care computation (ABC’s
-F), orNonefor ABC’s default of 0.preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost_rewrite – If
True(ABC’s default here), let the rewriting part apply replacements that do not reduce the size.zero_cost_refactor – If
True(ABC’s default here), the same for the refactoring part.
- Returns:
The command, ready for
run_script()orrun_many().- Raises:
ValueError – If an option is outside the range ABC accepts.
- __call__(ntk: aigverse.abc._runner.AigT, *, max_cut_size: int | None = None, max_inserts: int | None = None, odc_levels: int | None = None, preserve_levels: bool = True, zero_cost_rewrite: bool = True, zero_cost_refactor: bool = True, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
orchestratecommand on a network.Interleaves rewriting, refactoring and resubstitution rather than running them one after another, choosing per node which of the three to apply. It is a single command doing the job of a whole schedule.
Note that ABC enables zero-cost replacements here by default, unlike in the standalone
rewriteandrefactorcommands.- Parameters:
ntk – The network to optimize.
max_cut_size – Resubstitution cut size (ABC’s
-K, 4 to 16), orNonefor ABC’s default of 8.max_inserts – Nodes resubstitution may add (ABC’s
-N, 0 to 3), orNonefor ABC’s default of 1.odc_levels – Fanout levels used for don’t-care computation (ABC’s
-F), orNonefor ABC’s default of 0.preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost_rewrite – If
True(ABC’s default here), let the rewriting part apply replacements that do not reduce the size.zero_cost_refactor – If
True(ABC’s default here), the same for the refactoring part.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.- Raises:
ValueError – If an option is outside the range ABC accepts.
- class Refactor[source]¶
Bases:
aigverse.abc._runner.CommandWrapperRuns ABC’s
refactorcommand on a network, or builds it as a command.- static cmd(*, max_support: int | None = None, min_saved: int | None = None, preserve_levels: bool = True, zero_cost: bool = False) aigverse.abc._runner.Command[source]¶
Builds ABC’s
refactorcommand without running it.- Parameters:
max_support – Maximum support of a collapsed node (ABC’s
-N, 1 to 15), orNonefor ABC’s default of 10. Larger values are slower. ABC documents no range but rejects anything above 15.min_saved – Minimum number of nodes a single step must save to be applied (ABC’s
-M, at least 0), orNonefor ABC’s default of 1. Setting it to 0 accepts steps that save nothing.preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost – If
True, also apply replacements that do not reduce the size, which perturbs the structure and can unlock later gains.
- Returns:
The command, ready for
run_script()orrun_many().- Raises:
ValueError – If
max_supportis outside the range ABC accepts.
- __call__(ntk: aigverse.abc._runner.AigT, *, max_support: int | None = None, min_saved: int | None = None, preserve_levels: bool = True, zero_cost: bool = False, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
refactorcommand on a network.Collapses a cone into a single node and resynthesizes it from its truth table, which reaches larger cuts than
rewritedoes.- Parameters:
ntk – The network to optimize.
max_support – Maximum support of a collapsed node (ABC’s
-N, 1 to 15), orNonefor ABC’s default of 10. Larger values are slower. ABC documents no range but rejects anything above 15.min_saved – Minimum number of nodes a single step must save to be applied (ABC’s
-M, at least 0), orNonefor ABC’s default of 1. Setting it to 0 accepts steps that save nothing.preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost – If
True, also apply replacements that do not reduce the size, which perturbs the structure and can unlock later gains.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.- Raises:
ValueError – If
max_supportis outside the range ABC accepts.
- class Resub[source]¶
Bases:
aigverse.abc._runner.CommandWrapperRuns ABC’s
resubcommand on a network, or builds it as a command.- static cmd(*, max_cut_size: int | None = None, max_inserts: int | None = None, min_saved: int | None = None, odc_levels: int | None = None, preserve_levels: bool = True, zero_cost: bool = False) aigverse.abc._runner.Command[source]¶
Builds ABC’s
resubcommand without running it.- Parameters:
max_cut_size – Maximum cut size (ABC’s
-K, 4 to 16), orNonefor ABC’s default of 8. The canonical scripts sweep this from 6 to 12.max_inserts – Maximum number of nodes to add (ABC’s
-N, 0 to 3), orNonefor ABC’s default of 1.min_saved – Minimum number of nodes a single step must save to be applied (ABC’s
-M, at least 0), orNonefor ABC’s default of 1.odc_levels – Fanout levels used for observability-don’t-care computation (ABC’s
-F, at least 0), orNonefor ABC’s default of 0, which disables it. Don’t-cares find substitutions that are only valid in context, at the cost of a more expensive analysis.preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost – If
True, also apply replacements that do not reduce the size, which perturbs the structure and can unlock later gains.
- Returns:
The command, ready for
run_script()orrun_many().- Raises:
ValueError – If
max_cut_sizeormax_insertsis outside the range ABC accepts.
- __call__(ntk: aigverse.abc._runner.AigT, *, max_cut_size: int | None = None, max_inserts: int | None = None, min_saved: int | None = None, odc_levels: int | None = None, preserve_levels: bool = True, zero_cost: bool = False, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
resubcommand on a network.Re-expresses a node in terms of other nodes already present, which removes logic that rewriting and refactoring cannot reach because it is not local.
- Parameters:
ntk – The network to optimize.
max_cut_size – Maximum cut size (ABC’s
-K, 4 to 16), orNonefor ABC’s default of 8. The canonical scripts sweep this from 6 to 12.max_inserts – Maximum number of nodes to add (ABC’s
-N, 0 to 3), orNonefor ABC’s default of 1.min_saved – Minimum number of nodes a single step must save to be applied (ABC’s
-M, at least 0), orNonefor ABC’s default of 1.odc_levels – Fanout levels used for observability-don’t-care computation (ABC’s
-F, at least 0), orNonefor ABC’s default of 0, which disables it. Don’t-cares find substitutions that are only valid in context, at the cost of a more expensive analysis.preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost – If
True, also apply replacements that do not reduce the size, which perturbs the structure and can unlock later gains.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.- Raises:
ValueError – If
max_cut_sizeormax_insertsis outside the range ABC accepts.
- class Rewrite[source]¶
Bases:
aigverse.abc._runner.CommandWrapperRuns ABC’s
rewritecommand on a network, or builds it as a command.- static cmd(*, preserve_levels: bool = True, zero_cost: bool = False) aigverse.abc._runner.Command[source]¶
Builds ABC’s
rewritecommand without running it.- Parameters:
preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost – If
True, also apply replacements that do not reduce the size, which perturbs the structure and can unlock later gains.
- Returns:
The command, ready for
run_script()orrun_many().
- __call__(ntk: aigverse.abc._runner.AigT, *, preserve_levels: bool = True, zero_cost: bool = False, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
rewritecommand on a network.Replaces 4-input subgraphs with smaller pre-computed equivalents.
- Parameters:
ntk – The network to optimize.
preserve_levels – If
True(ABC’s default), never increase the depth.zero_cost – If
True, also apply replacements that do not reduce the size, which perturbs the structure and can unlock later gains.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- balance: Final[Balance]¶
Runs ABC’s
balancecommand on a network, or builds it as a command; seeBalance.
- orchestrate: Final[Orchestrate]¶
Runs ABC’s
orchestratecommand on a network, or builds it as a command; seeOrchestrate.
- refactor: Final[Refactor]¶
Runs ABC’s
refactorcommand on a network, or builds it as a command; seeRefactor.
- rewrite: Final[Rewrite]¶
Runs ABC’s
rewritecommand on a network, or builds it as a command; seeRewrite.
- exception AbcError[source]¶
Bases:
RuntimeErrorBase class for every failure raised by the ABC bridge.
- exception AbcExecutionError(message: str, *, binary: str, command: str, output: str)[source]¶
Bases:
AbcErrorRaised when ABC ran but did not produce a usable result.
ABC exits with status 0 even for unknown commands and unreadable files, and writes everything to standard output, so the captured output is the only diagnostic available. It is attached to the exception as
output, next to thebinarythat was invoked and thecommandit was given.- binary¶
- command¶
- output¶
- exception AbcNotFoundError[source]¶
Bases:
AbcErrorRaised when no usable ABC executable could be located.
- exception AbcTimeoutError(message: str, *, binary: str, command: str, output: str)[source]¶
Bases:
AbcExecutionErrorRaised when ABC did not terminate within the requested timeout.
- class Command[source]¶
One ABC command with its switches, built without being run.
Every wrapper’s
cmd()returns one of these, e.g.abc.rewrite.cmd(zero_cost=True). It renders as the command ABC takes, andrun_script(),run_commands()andrun_many()accept it wherever they accept a command string – a whole script is a sequence of them.
- class CommandWrapper[source]¶
What every wrapper is: callable on a network, with a
cmd()that only builds.abc.rewriteand its siblings are module-level instances of one subclass each, so a subclass’s lowercased name is the instance’s public name, which is whatrepr()shows in place of an object address.
- run_commands(commands: str | Command | Sequence[str | Command], *, timeout: float | None = None, use_init_file: bool = False, cwd: str | PathLike[str] | None = None, binary: str | PathLike[str] | None = None) str[source]¶
Runs raw ABC commands and returns their combined output.
No network is transferred; this is the escape hatch for commands such as
versionorprint_statson files the caller manages themselves.- Parameters:
commands – A single
;-separated command string, aCommand, or a sequence of individual commands.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.use_init_file – If
False(default), ABC is invoked with-sso that noabc.rcis read and behaviour does not depend on the local install. Set toTrueto let ABC pick up anabc.rcfrom the working directory. Preferset_abc_rc(), which loads one specific file and keeps the isolation.cwd – Working directory for the ABC process. Defaults to a fresh temporary directory, because ABC writes an
abc.historyfile into wherever it runs. Pass a directory explicitly if the commands refer to files by relative path.binary – Overrides the resolved ABC executable for this call only.
- Returns:
Everything ABC wrote to its output.
- Raises:
ValueError – If no command was given.
AbcNotFoundError – If no ABC executable could be located.
AbcTimeoutError – If ABC did not terminate within
timeoutseconds.AbcExecutionError – If ABC reported an error.
- run_script(ntk: AigT, commands: str | Command | Sequence[str | Command], *, timeout: float | None = None, use_init_file: bool = False, gia: bool = False, verbose: bool = False, binary: str | PathLike[str] | None = None) AigT[source]¶
Optimizes a network by piping it through an external ABC process.
The network is written to a temporary binary AIGER file, ABC is invoked with a read command, the given commands, and a write command, and the result is read back. The returned network has the same type as
ntk: anAigyields anAig, aNamedAigyields aNamedAigwith its input and output names preserved, and aSequentialAigyields aSequentialAigwith its registers and their reset values intact.ABC keeps two independent network stores, and a command only ever sees the one it belongs to. By default the network is loaded with
read_aigerinto the classic store, where the commands without a&prefix operate (balance,rewrite,refactor,resub, and hence every script inSCRIPTS). The&-prefixed commands of ABC9 operate on a separate store, the GIA, which stays empty in that mode – a script such as"&syn2"fails with there is no AIG unless it starts with&get. Setgia=Trueto load the network straight into the GIA with&readinstead, which is the cheaper and lossless way to run a&script.commandsmust not contain the read and write steps; they are added automatically. Only commands the resolved ABC binary knows are valid –resyn2and friends areabc.rcaliases rather than builtins, so use the wrappers in this module orSCRIPTS.- Parameters:
ntk – The network to optimize.
commands – A single
;-separated ABC command string, aCommand, or a sequence of individual commands.timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.use_init_file – If
False(default), ABC is invoked with-sso that noabc.rcis read and results do not depend on the local install. A resource file registered withset_abc_rc()is loaded regardless, making its aliases available.gia – If
True, transfer the network through&read/&writeso it lands in ABC9’s GIA store and&-prefixed commands can be used directly. The classic commands then see nothing instead. Mixing the two within one script is possible with&get/&put, but those do not carry I/O names across, whereas&read/&writedo.verbose – If
True, print everything ABC wrote. This is the captured output, not ABC’s own-vreporting – that differs per command and is left to the caller to add tocommands.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.- Raises:
TypeError – If
ntkis not anAig.ValueError – If no command was given, or if
giais set andntkhas a register whose reset value is undefined.AbcNotFoundError – If no ABC executable could be located.
AbcTimeoutError – If ABC did not terminate within
timeoutseconds.AbcExecutionError – If ABC reported an error or produced no usable output.
- expand_script(name: str) tuple[str, ...][source]¶
Expands a canonical ABC script name into builtin commands.
- class AbcStats[source]¶
What ABC reports about a network.
ABC’s own network name is deliberately absent: the bridge transfers through a temporary file, so it is always that file’s stem and never says anything about the network. It survives verbatim in
raw.
- stats(ntk: Aig, *, timeout: float | None = None, binary: str | PathLike[str] | None = None) AbcStats[source]¶
Reports ABC’s
print_statsfor a network.Warning
These are ABC’s counts, not
aigverse’s, and the two can differ for the very same network. ABC structurally hashes as it reads, so any structural redundancy the network carried is gone beforeprint_statssees it: a 16-bit carry-lookahead adder thataigversereports as 186 gates comes back from here as 182. Usenum_gatesto describe the network you hold, and this to describe what ABC worked on.- Parameters:
ntk – The network to measure.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.binary – Overrides the resolved ABC executable for this call only.
- Returns:
What ABC reports about the network.
- Raises:
TypeError – If
ntkis not anAig.AbcNotFoundError – If no ABC executable could be located.
AbcTimeoutError – If ABC did not terminate within
timeoutseconds.AbcExecutionError – If ABC reported an error or printed nothing usable.
- compress(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
compressscript on a network.Like
resyn, but every command is given-l, which turns ABC’s default level preservation off and lets it trade depth for size.The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- compress2(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
compress2script on a network.Like
resyn2, but every command is given-l, which turns ABC’s default level preservation off and lets it trade depth for size.The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- compress2rs(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
compress2rsscript on a network.resyn2rswith level preservation turned off; the strongest of these scripts, and the slowest.The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- dc2(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
dc2script on a network.ABC’s builtin combinational don’t-care-based optimization.
The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- resyn(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
resynscript on a network.A short balance/rewrite loop; the lightest of the standard scripts.
The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- resyn2(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
resyn2script on a network.The most widely used ABC size-reduction script.
The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- resyn2rs(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
resyn2rsscript on a network.resyn2extended with resubstitution passes; slower and usually smaller.The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- resyn3(ntk: aigverse.abc._runner.AigT, *, timeout: float | None = None, verbose: bool = False, binary: str | PathLike[str] | None = None) aigverse.abc._runner.AigT[source]¶
Runs ABC’s
resyn3script on a network.A resubstitution-driven variant of
resyn.The script is expanded into builtin ABC commands, so it does not depend on an
abc.rcbeing present. SeeSCRIPTSfor the exact expansion. Errors are reported the same way as byrun_script().- Parameters:
ntk – The network to optimize.
timeout – Seconds to wait for ABC to terminate, or
Nonefor no limit.verbose – If
True, print everything ABC wrote.binary – Overrides the resolved ABC executable for this call only.
- Returns:
The optimized network, of the same type as
ntk.
- class CecStatus(*args, **kwds)[source]¶
Bases:
enum.EnumThe outcome of an equivalence check.
Deliberately not usable as a boolean:
if cec(a, b):would read as “equivalent” while quietly also firing forUNDECIDEDandTIMEOUT, which are not the same claim at all. Compare explicitly:if abc.gia.cec(a, b) is abc.gia.CecStatus.EQUIVALENT: ...
- EQUIVALENT = 'equivalent'¶
- NOT_EQUIVALENT = 'not equivalent'¶
- UNDECIDED = 'undecided'¶
- TIMEOUT = 'timeout'¶