Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readNew metastability warning #416

Open
dopamane opened this issue Nov 16, 2018 · 2 comments
Open

readNew metastability warning #416

dopamane opened this issue Nov 16, 2018 · 2 comments

Comments

@dopamane
Copy link

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.

@christiaanb christiaanb added this to the 1.0 milestone Dec 19, 2018
@christiaanb
Copy link
Member

The code for this warning should really be revisited before the 1.0 release

@martijnbastiaan
Copy link
Member

This warning has been removed in #493, as it produced too many false positives. Leaving this report open as we do want a warning like it again.

@christiaanb christiaanb modified the milestones: 1.0, 1.1 Jun 3, 2019
@christiaanb christiaanb modified the milestones: 1.1, 1.2 Jan 16, 2020
@martijnbastiaan martijnbastiaan removed this from the 1.4 milestone Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants