package hardcaml

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file rtl_attribute.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
open! Import


module Value = struct
  type t =
    | Int of int
    | String of string
    | Bool of bool
  [@@deriving sexp_of]
end

type t =
  { name : string
  ; value : Value.t option
  }
[@@deriving sexp_of]

let create ?value name = { name; value }
let name t = t.name
let value t = t.value

module Vivado = struct
  (* see ug901 vivado synthesis guide chapter 2. *)

  let true_or_false_string : _ -> Value.t = function
    | true -> String "TRUE"
    | false -> String "FALSE"
  ;;

  let async_reg b = create "ASYNC_REG" ~value:(true_or_false_string b)


  let dont_touch b = create "dont_touch" ~value:(true_or_false_string b)

  let fsm_encoding enc =
    create
      "fsm_encoding"
      ~value:
        (String
           (match enc with
            | `one_hot -> "one_hot"
            | `sequential -> "sequential"
            | `johnson -> "johnson"
            | `gray -> "gray"
            | `auto -> "auto"
            | `none -> "none"))
  ;;

  let mark_debug b = create "mark_debug" ~value:(true_or_false_string b)

  module Ram_style = struct
    let block = create "RAM_STYLE" ~value:(String "block")
    let distributed = create "RAM_STYLE" ~value:(String "distributed")
    let registers = create "RAM_STYLE" ~value:(String "registers")
    let ultra = create "RAM_STYLE" ~value:(String "ultra")
  end
end