Module Hardcaml.Scope
Scopes control the process of hierarchical circuit generation.
They track a circuit database of instantiated modules, and a scheme for managing the naming of signals within the design.
module Path : sig ... end
module Naming_scheme : sig ... end
Control of name generation in a hierarchy of modules. The position of a module within a hierarchy is determined by a path which leads back to the (single) top most parent module. Signal names may be pre-pended with some represtation of that path.
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val create : ?flatten_design:Hardcaml__.Import.bool -> ?naming_scheme:Naming_scheme.t -> ?name:Hardcaml__.Import.string -> Hardcaml__.Import.unit -> t
create ?flatten_design ?naming_scheme ?name ()
creates a new scope. Ifflatten_design
istrue
, then all module instantions are inlined. Names for wires are determiend bynaming_scheme
.
val sub_scope : t -> Hardcaml__.Import.string -> t
sub_scope t label
returns a new scope withlabel
appended to its hierarchical path
val path : t -> Path.t
path t
returns thePath.t
associated witht
. This will determine the prefix used when naming modules that are associated with this scope.
val circuit_database : t -> Circuit_database.t
circuit_database t
returns the circuit database associated witht
. Note that circuit databases are shared amongsub_scope
s.
val flatten_design : t -> Hardcaml__.Import.bool
flatten_design t
returns true when HardCaml will inline all module instantiations.
val naming_scheme : t -> Naming_scheme.t
naming_scheme t
returns theNaming
.t thatt
was constructed with.
val name : ?sep:Hardcaml__.Import.string -> t -> Hardcaml__.Import.string -> Hardcaml__.Import.string
name ?sep t signal string
creates a heirarchical name based on the path oft
andstring
.sep
, when provided, determines the separator for path components in the heirarchical name (default is$
).
val naming : ?sep:Hardcaml__.Import.string -> t -> Signal.t -> Hardcaml__.Import.string -> Signal.t
Creates a hierarchical name, built with
name
, and applies it to the signal.This is typically used as a partial application to construct a new signal naming operator, .e.g:
let (--) = naming scope in (* ... other code ... *) let named_signal = some_signal -- "data" in (* ... more code ... *)