package hardcaml_xilinx_reports

  1. Overview
  2. Docs

Source file primitive_group.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
open! Import

module type Subgroup = sig
  type t

  val primitive_subgroup : t -> string
  val ignore_macro_primitives : t -> bool
end

(* Primtive subgroups *)
module Advanced = struct
  type t =
    | Mac
    | Gt
    | Interlaken
    | Pcie
    | Sysmon
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

module Arithmetic = struct
  type t = Dsp [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

module Blockram = struct
  type t =
    | Fifo
    | Bram
    | Uram
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

module Clb = struct
  type t =
    | Latch
    | Carry
    | Lut
    | Muxf
    | Lutram
    | Srl
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase

  (* Vivado includes MACRO primitives for LUTRAMs which are then expanded into INTERNAL
     primitives. To avoid double-counting we exclude MACRO primitives. *)
  let ignore_macro_primitives = function
    | Lutram -> true
    | _ -> false
  ;;
end

module Clock = struct
  type t =
    | Buffer
    | Mux
    | Pll
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

module Configuration = struct
  type t =
    | Bscan
    | Dna
    | Efuse
    | Ecc
    | Icap
    | Master_jtag
    | Startup
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

module Io = struct
  type t =
    | Bitslice
    | Dci_reset
    | Input_buffer
    | Delay
    | Bidir_buffer
    | Serdes
    | Weak_driver
    | Output_buffer
    | Sdr
    | Metastability
    | Ddr
    | Latch
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

module Register = struct
  type t =
    | Sdr
    | Metastability
    | Ddr
    | Latch
  [@@deriving enumerate, sexp_of, variants]

  let primitive_subgroup t = Variants.to_name t |> String.uppercase
  let ignore_macro_primitives _ = false
end

(* Primitive groups *)
type t =
  | Advanced of Advanced.t list
  | Arithmetic of Arithmetic.t list
  | Blockram of Blockram.t list
  | Clb of Clb.t list
  | Clock of Clock.t list
  | Configuration of Configuration.t list
  | Io of Io.t list
  | Register of Register.t list
[@@deriving sexp_of, variants]

let primitive_group = function
  | Advanced _ -> "ADVANCED"
  | Arithmetic _ -> "ARITHMETIC"
  | Blockram _ -> "BLOCKRAM"
  | Clb _ -> "CLB"
  | Clock _ -> "CLOCK"
  | Configuration _ -> "CONFIGURATION"
  | Io _ -> "IO"
  | Register _ -> "REGISTER"
;;