Source file always_prim_intf.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
(** Common types for the Always DSL *)

open! Core0

module type S = sig
  module Signal : Signal.S

  module Variable : sig
    module Internal : sig
      type t =
        { assigns_to_wire : Signal.t
        ; default : Signal.t
        ; debug_info : Coverage_prim.Always_metadata.Variable.t
        }
      [@@deriving sexp_of]
    end

    type t =
      { value : Signal.t
      ; internal : Internal.t
      }
    [@@deriving sexp_of, fields ~getters]
  end

  module Assign_internal : sig
    type t = { state_metadata : Coverage_prim.State.Named.t option } [@@deriving sexp_of]
  end

  module If_internal : sig
    module Kind : sig
      type t =
        | Condition of Coverage_prim.Always_metadata.If.Kind.t
        | One_hot_switch of
            { var : Variable.t
            ; state : Coverage_prim.State.Named.t
            }
      [@@deriving sexp_of]
    end

    type t =
      { kind : Kind.t
      ; creation_pos : Source_code_position.t
      }
    [@@deriving sexp_of]
  end

  module Match_internal : sig
    type t =
      | Basic
      | Always_state of Coverage_prim.State.Named.t
    [@@deriving sexp_of]
  end

  module Switch_internal : sig
    type t =
      { creation_pos : Source_code_position.t
      ; states : Coverage_prim.State.Named.t list
      }
    [@@deriving sexp_of]
  end

  type match_ =
    { value : Signal.t * t list
    ; internal : Match_internal.t
    }
  [@@deriving sexp_of]

  and t =
    | Assign of
        { value : Variable.t * Signal.t
        ; internal : Assign_internal.t
        }
    | If of
        { value : Signal.t * t list * t list
        ; internal : If_internal.t
        }
    | Switch of
        { value : Signal.t * match_ list
        ; internal : Switch_internal.t
        }
  [@@deriving sexp_of]
end

module type Always_prim = sig
  module type S = S

  module Make (S : Signal.S) : S with module Signal = S
end