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
open! Import
module Range_direction = struct
type t =
| Up
| Down
[@@deriving compare, sexp_of]
let equal = [%compare.equal: t]
end
module Expression = struct
type t =
| Char of string
| Float of float
| Hex of string
| Id of string
| Int of int
| Neg of t
| Op of string * t * t
| Others of string
| String of string
| X01 of string
[@@deriving compare, sexp_of]
end
module Range = struct
type t = Expression.t * Range_direction.t * Expression.t
[@@deriving compare, sexp_of]
end
module Type = struct
type t =
| Bit
| Bit_vector of Range.t option
| Boolean
| Integer
| Real
| Std_logic
| Std_logic_vector of Range.t option
| String
| Time
[@@deriving compare, sexp_of]
end
module Port_direction = struct
type t = In | Inout | Out
[@@deriving compare, enumerate, sexp_of]
let equal = [%compare.equal: t]
let to_string t = t |> [%sexp_of: t] |> Sexp.to_string
end
module Port = struct
type t =
{ name : string
; dir : Port_direction.t
; type_ : Type.t
; default : Expression.t option }
[@@deriving compare, sexp_of]
end
module Component = struct
type t =
{ name : string
; generics : Port.t list
; ports : Port.t list }
[@@deriving compare, sexp_of]
end