package hardcaml_event_driven_sim

  1. Overview
  2. Docs

Source file two_state_logic.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
open! Core
include Hardcaml.Bits

let to_bits_exn = Fn.id
let of_bits = Fn.id

let create_signal ?initial_value ?resolution width =
  ignore resolution;
  Event_driven_sim.Simulator.Signal.create
    (module struct
      type nonrec t = t [@@deriving sexp_of]

      let ( = ) = Hardcaml.Bits.equal
      let resolve_value = `Unresolved

      let check_value_compatibility new_value =
        if Hardcaml.Bits.width new_value <> width
        then
          raise_s
            [%message
              "attempting to assign value with wrong width" (new_value : t) (width : int)]
      ;;

      let initial_value = initial_value |> Option.value ~default:(zero width)
    end)
;;