package hardcaml_xilinx

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

Source file fifo_async.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
open! Base
open Hardcaml

let create
  ?(showahead = false)
  ?(build_mode = Build_mode.Synthesis)
  ?fifo_memory_type
  ?nearly_full
  ?nearly_empty
  ?scope
  ()
  ~capacity
  ~read_clock
  ~write_clock
  ~clear
  ~write
  ~d
  ~read
  =
  Option.iter fifo_memory_type ~f:(fun fifo_memory_type ->
    match fifo_memory_type with
    | Fifo_memory_type.Ultra ->
      raise_s [%message "Cannot create async fifo with [Ultra] memory type."]
    | Block | Auto | Distributed -> ());
  match (build_mode : Build_mode.t) with
  | Simulation ->
    (* Our async fifo implementation currently only supports showahead mode; in the
       non-showahead case, we just stub in a regular fifo for simulations with an
       arbitrary clock chosen. *)
    if showahead
    then
      let open Signal in
      let module Async_fifo =
        Async_fifo.Make (struct
          let width = Signal.width d
          let log2_depth = Int.ceil_log2 capacity
        end)
      in
      let async_fifo =
        Async_fifo.create
          ?scope
          { clock_write = write_clock
          ; clock_read = read_clock
          ; reset_write = clear
          ; reset_read = gnd
          ; data_in = d
          ; write_enable = write
          ; read_enable = read
          }
      in
      { Fifo.q = async_fifo.data_out
      ; full = async_fifo.full
      ; empty = ~:(async_fifo.valid)
      ; nearly_full = gnd
      ; nearly_empty = async_fifo.almost_empty
      ; used = gnd
      ; rd_rst_busy = gnd
      ; wr_rst_busy = gnd
      }
    else
      Fifo.create
        ?scope
        ?nearly_full
        ?nearly_empty
        ~showahead
        ()
        ~capacity
        ~clock:read_clock
        ~clear
        ~rd:read
        ~wr:write
        ~d
  | Synthesis ->
    Xpm_fifo_async.create
      ?fifo_memory_type
      ?nearly_full
      ?nearly_empty
      ~showahead
      ()
      ~latency:(if showahead then 0 else 1)
      ~capacity
      ~rd_clk:read_clock
      ~wr_clk:write_clock
      ~clr:clear
      ~wr:write
      ~rd:read
      ~d
;;
OCaml

Innovation. Community. Security.