package ppx_deriving_hardcaml
Rewrite OCaml records for use as Hardcaml Interfaces
Install
Dune Dependency
Authors
Maintainers
Sources
ppx_deriving_hardcaml-v0.12.0.tar.gz
sha256=a566bebfb99bb568fac17bf6c8b20756b15bfa6033693bebef6de122b683b9e9
md5=03485663e12f636376b2b47337fbecb7
Description
An interface in Hardcaml is an OCaml record with special attributes including a bit width and RTL netlist name. Input and output ports of a hardware design can then be accessed through the OCaml record. This allows easier management of bundles of ports when working with the Simulator, Netlist generation or hierarchical designs.
Published: 01 Mar 2019
README
ppx_deriving
Plugin for Hardcaml
This module implements a plugin for the ppx_deriving
rewriter that supports the Hardcaml syntax:
Provide a
record
annotation to generate helper functionsProvide an optional
bits
attribute for signalsProvide a required
width
attribute forlist
andarray
It must be used in conjunction with [@@deriving sexp_of]
, like this:
```ocaml
[@@deriving sexp_of, hardcaml]
```
Examples
Module interface
Original syntax:
module S : interface
signal
signal_list{ }
signal_array{| |}
end
New syntax:
module S : sig
type 'a t = {
signal : 'a;
signal_list : 'a list;
signal_array : 'a array;
} [@@deriving sexp_of, hardcaml]
end
Module implementation
Original syntax:
module S = interface
signal[2]
signal_list{2}[4]
signal_array{|2|}[4]
end
New syntax:
module S = struct
type 'a t = {
signal : 'a [@bits 2];
signal_list : 'a list [@length 2][@bits 4];
signal_array : 'a array [@length 2][@bits 4];
} [@@deriving sexp_of, hardcaml]
end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page