Skip to content

readNew metastability warning #416

Open
@dopamane

Description

@dopamane

Using Clash 0.99.3, the readNew function causes compiler warnings. The following example:

module TopLevel where

import Clash.Prelude

topEntity
  :: Clock System Source
  -> Reset System Asynchronous
  -> Signal System (Unsigned 5)
  -> Signal System (Maybe (Unsigned 5, BitVector 5))
  -> Signal System (BitVector 5)
topEntity = exposeClockReset test

test :: HiddenClockReset dom gated sync
       => Signal dom (Unsigned 5)
       -> Signal dom (Maybe (Unsigned 5, BitVector 5))
       -> Signal dom (BitVector 5)
test rdAddr	wrM = readNew (asyncRam d32) rdAddr wrM

Produces the compiler warning:

Loading dependencies took 0.499845074s
Compiling: TopLevel.topEntity
TopLevel.$sreadNew45574 (:: GHC.Classes.IP
  rst
  (Clash.Signal.Internal.Reset
     (Clash.Signal.Internal.Dom system 10000)
     Clash.Signal.Internal.Asynchronous)
-> GHC.Classes.IP
     clk
     (Clash.Signal.Internal.Clock
        (Clash.Signal.Internal.Dom system 10000)
        Clash.Signal.Internal.Source)
-> Clash.Signal.Internal.Clock
     (Clash.Signal.Internal.Dom system 10000)
     Clash.Signal.Internal.Source
-> Clash.Signal.Internal.Signal
     (Clash.Signal.Internal.Dom system 10000)
     (Clash.Sized.Internal.Unsigned.Unsigned 5)
-> Clash.Signal.Internal.Signal
     (Clash.Signal.Internal.Dom system 10000)
     (GHC.Base.Maybe
        (GHC.Tuple.(,)
           (Clash.Sized.Internal.Unsigned.Unsigned 5)
           (Clash.Sized.Internal.BitVector.BitVector 5)))
-> Clash.Sized.Internal.BitVector.BitVector 5)
has potentially dangerous meta-stability issues:

The following clocks:
* GHC.Classes.IP
  clk
  (Clash.Signal.Internal.Clock
     (Clash.Signal.Internal.Dom system 10000)
     Clash.Signal.Internal.Source)
* Clash.Signal.Internal.Clock
  (Clash.Signal.Internal.Dom system 10000)
  Clash.Signal.Internal.Source
belong to the same clock domain and should be connected to the same clock source in order to prevent meta-stability issues.
Applied 127 transformations
Normalisation took 0.342218385s
Netlist generation took 0.003322493s
Total compilation took 0.846340327s

From what I can tell, there should not be meta-stability issues nor clock connection issues. Removing the readNew results in no compiler warnings, as expected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions