package ppx_deriving_hardcaml

  1. Overview
  2. Docs
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 functions

  • Provide an optional bits attribute for signals

  • Provide a required width attribute for list and array

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

Dependencies (7)

  1. ppxlib >= "0.5.0" & < "0.9.0"
  2. dune >= "1.5.1"
  3. ppx_sexp_conv >= "v0.12" & < "v0.13"
  4. ppx_jane >= "v0.12" & < "v0.13"
  5. hardcaml >= "v0.12" & < "v0.13"
  6. base >= "v0.12" & < "v0.13"
  7. ocaml >= "4.07.0"

Dev Dependencies

None

Used by

None

Conflicts

None

OCaml

Innovation. Community. Security.