Module Hardcaml.Circuit_database

A database which holds a collection of circuits, indexed by a unique circuit name.

The database is used to map occurrences of instantiations within a Hardcaml circuit to an implementation. This can then be used to generate an RTL module hierarchy. Structurally identical circuits may be indentified and the implementation shared.

type t
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val create : unit -> t

Create an empty database.

val insert : ?⁠share:bool -> t -> Circuit.t -> string

Insert a circuit into the database and return a potentially modified circuit name, which should used when creating a Hardcaml instantiation. If share is true and the database contains a structurally equal circuit then a reference to the existing circuit is returned. Otherwise, a new entry is created.

val find : t -> mangled_name:string -> Circuit.t option

Find a circuit in the database, given its name.

val get_circuits : t -> Circuit.t list

Return a list of all circuits in the database.