Module Hardcaml.Always
Always is a DSL that lets one describe a circuit in the same style as a Verliog always block.
if and switch control constructs are provided. ($==) is used for assignment.
Code is written as lists of assignments, if and control statements.
variables;
let var = wire (zero 8) in
let var = reg r_sync enable 8 inassignment;
var $== exp;if statements;
if_ condition [ ... ] [ ... ]switch statements;
switch condition [
  consti 3 0 [ ... ];
  consti 3 1 [ ... ];
  consti 3 2 [ ... ];
  consti 3 3 [ ... ];
]signals;
let (s:signal) = q (v:guarded) incompilation;
compile [ ... ]example;
      let state = reg r_sync enable 2 in
      let a = wire 8 in
      compile [
        if_ a#q ==: consti 8 4 [
          a $== consti 8 2
        ] [
          switch (q state) [
          (consti 2 0) [
            a $==. 3;
            state $== const 2 1;
          ];
          (consti 2 1) [
            a $==. 2;
            state $== const 2 2;
          ];
          (consti 2 2) [
            a $==. 1;
            state $== const 2 3;
          ];
          (consti 2 3) [
            a $==. 0;
            state $== const 2 4;
          ]
        ]
      ];
      let state = state#q in
      let a = a#q in
      ....val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
type always= t
module Variable : sig ... endThe type of variables in guarded assignments. Variables may be asychronous
wires, or synchronousregs. The current value of the variable may be accessed through thevaluefield below.
type 'a case= 'a * t Hardcaml__.Import.listtype 'a cases= 'a case Hardcaml__.Import.list
val if_ : Signal.t -> t Hardcaml__.Import.list -> t Hardcaml__.Import.list -> tif statement
val elif : Signal.t -> t Hardcaml__.Import.list -> t Hardcaml__.Import.list -> t Hardcaml__.Import.listelse if branch
val when_ : Signal.t -> t Hardcaml__.Import.list -> tif sel then
...else
val unless : Signal.t -> t Hardcaml__.Import.list -> tif sel then
else...
val proc : t Hardcaml__.Import.list -> tAllows sequences of expressions to be inserted into the code; a syntactic nicety.
val (<--) : Variable.t -> Signal.t -> tassignment
val (<--.) : Variable.t -> Hardcaml__.Import.int -> tassignment with an integer constant - width is inferred
module State_machine : sig ... endval compile : t Hardcaml__.Import.list -> Hardcaml__.Import.unitcompile to structural code