Source file ram_with_resizing_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
open Base
open Hardcaml

module type Config = sig
  val log_num_words : int
  val bits_per_word : int
  val log_scale_between_ports : int
  val read_latency : int
  val collision_mode : Collision_mode.t option
end

module type S = sig
  (** number of bits in the write address. *)
  val write_address_bits : int

  (** number of bits in the read address. *)
  val read_address_bits : int

  (** number of bits in the write bus. *)
  val write_data_bits : int

  (** number of bits in the read bus. *)
  val read_data_bits : int

  module I : sig
    type 'a t =
      { clock : 'a
      ; clear : 'a
      ; write_address : 'a
      ; write_data : 'a
      ; write_enable : 'a
      ; read_address : 'a
      ; read_enable : 'a
      }
    [@@deriving sexp_of, hardcaml]
  end

  module O : sig
    type 'a t = { q : 'a } [@@deriving sexp_of, hardcaml]
  end

  val create : Scope.t -> build_mode:Build_mode.t -> Interface.Create_fn(I)(O).t

  val hierarchical
    :  ?instance:string
    -> Scope.t
    -> build_mode:Build_mode.t
    -> Interface.Create_fn(I)(O).t
end

(** RAM for which the the inputs and output data busses are different widths by some power
    of 2 factor. Assumes a write-before-read ordering between the ports. *)
module type Ram_with_resizing = sig
  module type Config = Config
  module type S = S

  module Make (Config : Config) : S
end