isomatch
|
C API header file for the Isomatch library. More...
#include <stdint.h>
#include <stdlib.h>
Go to the source code of this file.
Classes | |
struct | circuit_list |
Linked list of circuit_handle More... | |
struct | wire_list |
Linked list of wire_handle More... | |
struct | single_match |
Result for a single subcircuit-find match. More... | |
struct | match_results |
Subcircuit-find match results. More... | |
Typedefs | |
typedef uint64_t | sign_t |
Type of a circuit signature. More... | |
typedef void * | circuit_handle |
Value representing a circuit. More... | |
typedef void * | expr_handle |
Value representing an expression. More... | |
typedef const char * | wire_handle |
A wire name. More... | |
typedef struct circuit_list | circuit_list |
Linked list of circuit_handle More... | |
typedef struct wire_list | wire_list |
Linked list of wire_handle More... | |
typedef struct match_results | match_results |
Subcircuit-find match results. More... | |
typedef enum isom_rc | isom_rc |
Return codes of the int -returning functions in this API. More... | |
Enumerations | |
enum | isom_rc { ISOM_RC_OK = 0, ISOM_RC_NULLPTR = 1, ISOM_RC_DOMAIN = 2, ISOM_RC_NO_PARENT = 3, ISOM_RC_BADHEX = 4, ISOM_RC_BAD_FREE = 5, ISOM_RC_OUT_OF_RANGE = 6, ISOM_RC_NOT_CONNECTED = 7, ISOM_RC_ERROR = 255 } |
Return codes of the int -returning functions in this API. More... | |
enum | isom_expr_binop { BAnd, BOr, BXor, BAdd, BSub, BMul, BDiv, BMod, BLsr, BLsl, BAsr } |
enum | isom_expr_unop { UNot } |
enum | isom_expr_unop_cst { UCLsr, UCLsl, UCAsr } |
Functions | |
isom_rc | isom_last_error () |
Return the error code of the last error that occurred. More... | |
const char * | isom_strerror (isom_rc err_code) |
int | free_circuit (circuit_handle circuit) |
int | isom_unplug_circuit (circuit_handle circuit) |
circuit_handle | build_assert (circuit_handle parent, const char *name, expr_handle expr) |
Build an assert gate. More... | |
int | build_assert_add_input (circuit_handle self, wire_handle wire) |
circuit_handle | build_comb (circuit_handle parent) |
Build a comb gate, which will need to be edited with the functions below. More... | |
int | build_comb_add_input (circuit_handle self, wire_handle wire) |
int | build_comb_add_output (circuit_handle self, wire_handle wire, expr_handle expr) |
circuit_handle | build_delay (circuit_handle parent, wire_handle input, wire_handle output) |
Build a delay gate. More... | |
circuit_handle | build_group (const char *name) |
int | build_group_add_child (circuit_handle self, circuit_handle child) |
int | build_group_add_input (circuit_handle self, wire_handle actual, wire_handle formal) |
int | build_group_add_output (circuit_handle self, wire_handle actual, wire_handle formal) |
circuit_handle | build_tristate (circuit_handle parent, wire_handle from, wire_handle to, wire_handle enable) |
Build a tristate gate. More... | |
expr_handle | build_expr_const (unsigned val) |
Build a constant expression node. More... | |
expr_handle | build_expr_longconst (const char *value) |
expr_handle | build_expr_var (int input_pin) |
Build a variable expression node referring to the n th input of the gate. More... | |
expr_handle | build_expr_binop (enum isom_expr_binop op, expr_handle left, expr_handle right) |
Build a binary operator expression node. More... | |
expr_handle | build_expr_unop (enum isom_expr_unop op, expr_handle expr) |
Build a unary operator expression node. More... | |
expr_handle | build_expr_unop_cst (enum isom_expr_unop_cst op, int param, expr_handle expr) |
Build a unary operator with constant parameter expression node. More... | |
expr_handle | build_expr_slice (expr_handle expr, unsigned beg, unsigned end) |
Build a slice expression node (beginning inclusive, end exclusive) More... | |
expr_handle | build_expr_merge (expr_handle left, expr_handle right) |
Build a merge expression node. More... | |
int | free_expression (expr_handle expr) |
Free the given previously created expression. More... | |
int | isom_input_count (circuit_handle circuit) |
Returns the number of inputs of a given circuit. Returns -1 on error. More... | |
int | isom_output_count (circuit_handle circuit) |
Returns the number of outputs of a given circuit. Returns -1 on error. More... | |
wire_handle | isom_nth_input (circuit_handle circuit, size_t wireId) |
Returns the handle of the nth input wire (starting with 0) of circuit More... | |
wire_handle | isom_nth_output (circuit_handle circuit, size_t wireId) |
Returns the handle of the nth output wire (starting with 0) of circuit More... | |
sign_t | sign (circuit_handle circuit) |
sign_t | sign_with_precision (circuit_handle circuit, unsigned precision_level) |
match_results * | subcircuit_find (circuit_handle needle, circuit_handle haystack) |
void | free_match_results (match_results *res) |
void | isom_clear_marks () |
void | isom_mark_circuit (circuit_handle handle) |
void | isom_sweep () |
C API header file for the Isomatch library.
General purpose notes on this API:
free
-like specific function is recursive, where possible; eg. freeing a hierarchy group will free the underlying circuits, freeing a comb gate will free its expressions, ...NULL
if an error occurred. typedef void* circuit_handle |
Value representing a circuit.
typedef struct circuit_list circuit_list |
Linked list of circuit_handle
typedef void* expr_handle |
Value representing an expression.
typedef struct match_results match_results |
Subcircuit-find match results.
typedef uint64_t sign_t |
Type of a circuit signature.
typedef const char* wire_handle |
A wire name.
enum isom_expr_binop |
enum isom_expr_unop |
enum isom_expr_unop_cst |
enum isom_rc |
Return codes of the int
-returning functions in this API.
circuit_handle build_assert | ( | circuit_handle | parent, |
const char * | name, | ||
expr_handle | expr | ||
) |
Build an assert gate.
int build_assert_add_input | ( | circuit_handle | self, |
wire_handle | wire | ||
) |
Add an input wire to a given gate (order matters!)
circuit_handle build_comb | ( | circuit_handle | parent | ) |
Build a comb gate, which will need to be edited with the functions below.
int build_comb_add_input | ( | circuit_handle | self, |
wire_handle | wire | ||
) |
Add an input wire to a given combinator gate
int build_comb_add_output | ( | circuit_handle | self, |
wire_handle | wire, | ||
expr_handle | expr | ||
) |
Add an output wire, alongside with an expression, to a given comb gate
circuit_handle build_delay | ( | circuit_handle | parent, |
wire_handle | input, | ||
wire_handle | output | ||
) |
Build a delay gate.
expr_handle build_expr_binop | ( | enum isom_expr_binop | op, |
expr_handle | left, | ||
expr_handle | right | ||
) |
Build a binary operator expression node.
expr_handle build_expr_const | ( | unsigned | val | ) |
Build a constant expression node.
expr_handle build_expr_longconst | ( | const char * | value | ) |
Build a long constant expression node
value | Hexadecimal string [0-9a-fA-F]+ |
expr_handle build_expr_merge | ( | expr_handle | left, |
expr_handle | right | ||
) |
Build a merge expression node.
expr_handle build_expr_slice | ( | expr_handle | expr, |
unsigned | beg, | ||
unsigned | end | ||
) |
Build a slice expression node (beginning inclusive, end exclusive)
expr_handle build_expr_unop | ( | enum isom_expr_unop | op, |
expr_handle | expr | ||
) |
Build a unary operator expression node.
expr_handle build_expr_unop_cst | ( | enum isom_expr_unop_cst | op, |
int | param, | ||
expr_handle | expr | ||
) |
Build a unary operator with constant parameter expression node.
expr_handle build_expr_var | ( | int | input_pin | ) |
Build a variable expression node referring to the n
th input of the gate.
circuit_handle build_group | ( | const char * | name | ) |
Build a hierarchy group gate, which will need to be edited with the functions below. A group does not necessarily belong to another group, thus there is no parent
argument, and you must call build_group_add_child
yourself.
int build_group_add_child | ( | circuit_handle | self, |
circuit_handle | child | ||
) |
Add the given circuit as a child of the given group.
int build_group_add_input | ( | circuit_handle | self, |
wire_handle | actual, | ||
wire_handle | formal | ||
) |
Add an input pin to the given circuit group.
self | The group to work on |
actual | The name of the pin when accessed from inside the group |
formal | The name of the pin when accessed from outside the group |
int build_group_add_output | ( | circuit_handle | self, |
wire_handle | actual, | ||
wire_handle | formal | ||
) |
Add an output pin to the given circuit group.
self | The group to work on |
actual | The name of the pin when accessed from inside the group |
formal | The name of the pin when accessed from outside the group |
circuit_handle build_tristate | ( | circuit_handle | parent, |
wire_handle | from, | ||
wire_handle | to, | ||
wire_handle | enable | ||
) |
Build a tristate gate.
int free_circuit | ( | circuit_handle | circuit | ) |
Free the given previously created circuit's component (that is, including its ancestors and descendants).
int free_expression | ( | expr_handle | expr | ) |
Free the given previously created expression.
void free_match_results | ( | match_results * | res | ) |
Free a match_results
. This DOES NOT free the needle
and haystack
circuits used during the match!
void isom_clear_marks | ( | ) |
This mark and sweep algorithm works on whole components only. This means that if you mark a circuit, every descendant and ancestor of this circuit will be marked as well. Clears all the mark and sweep's marks. This is automatically done by isom_sweep
after a pass, but can also be done manually.
int isom_input_count | ( | circuit_handle | circuit | ) |
Returns the number of inputs of a given circuit. Returns -1 on error.
isom_rc isom_last_error | ( | ) |
Return the error code of the last error that occurred.
void isom_mark_circuit | ( | circuit_handle | handle | ) |
Marks the given circuit handle, all its ancestors and its descendants (circuits and expressions)as "in use" for the next isom_sweep
pass
wire_handle isom_nth_input | ( | circuit_handle | circuit, |
size_t | wireId | ||
) |
Returns the handle of the nth input wire (starting with 0) of circuit
wire_handle isom_nth_output | ( | circuit_handle | circuit, |
size_t | wireId | ||
) |
Returns the handle of the nth output wire (starting with 0) of circuit
int isom_output_count | ( | circuit_handle | circuit | ) |
Returns the number of outputs of a given circuit. Returns -1 on error.
const char* isom_strerror | ( | isom_rc | err_code | ) |
Return a human-friendly string describing the given error. Note that you don't have to free
the returned string.
void isom_sweep | ( | ) |
Sweeps (frees every value that is not marked, directly or recursively) the previously allocated values.
int isom_unplug_circuit | ( | circuit_handle | circuit | ) |
Disconnect the given circuit from its ancestor and wires, and calls free_circuit
on it.
sign_t sign | ( | circuit_handle | circuit | ) |
Computes a signature for the given circuit handle
sign_t sign_with_precision | ( | circuit_handle | circuit, |
unsigned | precision_level | ||
) |
Computes a signature for the given circuit handle with a precision level of precision_level
match_results* subcircuit_find | ( | circuit_handle | needle, |
circuit_handle | haystack | ||
) |
Finds every disjoint occurrence of needle
in haystack
. If two possible occurrences of needle
are overlapping in haystack
, the match that will be returned is undefined (yet deterministic). The list structures, etc. are malloc
'd and must be free'd on the caller's side whenever they're not needed anymore using free_match_result
.