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

Adding custom Eq instance for Axi4StreamM2S #66

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/Protocols/Axi4/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,21 @@
, C.NFDataX userType
) => C.NFDataX (Axi4StreamM2S conf userType)

deriving instance
( KnownAxi4StreamConfig conf
, Eq userType
) => Eq (Axi4StreamM2S conf userType)
instance ( KnownAxi4StreamConfig conf, Eq userType) => Eq (Axi4StreamM2S conf userType) where
axiA == axiB = lastSame && idSame && destSame && userSame && and keepsSame && and bytesValid

Check failure on line 87 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Stack tests

• Couldn't match type ‘1 <=? DataWidth conf’ with ‘'True’

Check failure on line 87 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Couldn't match type ‘1 <=? DataWidth conf’ with ‘'True’

Check failure on line 87 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Couldn't match type ‘1 <=? DataWidth conf’ with ‘'True’
where
keepsSame = (==) <$> _tkeep axiA <*> _tkeep axiB
lastSame = _tlast axiA == _tlast axiB
idSame = _tid axiA == _tid axiB
destSame = _tdest axiA == _tdest axiB
userSame = _tuser axiA == _tuser axiB

-- For all bytes where the keep is high, the data and strb must be the same.
keeps = (||) <$> _tkeep axiA <*> _tkeep axiB
dataSame = (==) <$> _tdata axiA <*> _tdata axiB
strbSame = (==) <$> _tstrb axiA <*> _tstrb axiB
bytesValid = zipWith3 (\ k d s -> (not k) || (d && s)) keeps strbSame dataSame


deriving instance
( KnownAxi4StreamConfig conf
Expand All @@ -98,7 +109,7 @@
-- Manager may not decide whether or not to send 'Nothing' based on
-- the '_tready' signal.
newtype Axi4StreamS2M = Axi4StreamS2M { _tready :: Bool }
deriving (Generic, C.NFDataX, C.ShowX, Eq, NFData, Show, Bundle)

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

Check warning on line 112 in src/Protocols/Axi4/Stream.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

• Both DeriveAnyClass and GeneralizedNewtypeDeriving are enabled

-- | Type for AXI4 Stream protocol.
data Axi4Stream (dom :: Domain) (conf :: Axi4StreamConfig) (userType :: Type)
Expand Down
Loading