profile
viewpoint
Christiaan Baaij christiaanb QBayLogic Enschede, The Netherlands

christiaanb/clash 18

my branch of clash

christiaanb/clash-bin 2

ghc(i) binary loaded with clash library

christiaanb/haskell12 2

Experiance Report on SoOSiM

christiaanb/cabal 1

Official upstream development repository for Cabal and cabal-install

christiaanb/clash-tryout 1

An easier to maintain clash compiler

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 37596f940243c00e4cf6ba061953cd7e7f16ea46

Add simple-nix

view details

push time in an hour

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha e85cdebb575e24cbf91401407db44b58643eb9cb

Add simple-nix

view details

push time in 2 hours

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha d7c53994340d2bf57e6e7c54e63d88293f0551ba

Add simple-nix

view details

push time in 3 hours

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 9de394ffd4a997e499aefe1ec9e73ff09db25bcc

Add simple-nix

view details

push time in 3 hours

issue openedclash-lang/clash-compiler

Unexpected behaviours when using derived BitPack

Derived bitpacks uses cascade of if's approach. This seems to have unintended side-effects.

Generic derive


data Foo = F0 | F1 | F2 deriving (Generic, BitPack)

f :: Foo -> Unsigned 2
f F0 = 0
f F1 = 1
f F2 = 2

g :: Foo -> Unsigned 2
g F2 = 2
g F1 = 1
g F0 = 0

f' :: BitVector 2 -> Unsigned 2
f' = f . pack

g' :: BitVector 2 -> Unsigned 2
g' = g . pack
  • In simulation both behave identically and for 0b11 return 2
  • In HDL f' behaves like simulation
  • In HDL g' returns 0 for 0b11
  • IMHO the principle of least surprise would indicate that returned value should be errorX. This allows synthesis to produce more efficient implementation and matches behaviour of partial function in Haskell returning ⊥.

Catch-all clause

I'd note that sometimes the simulation-like behaviour is intended:


data MMIOReg = Reg0 | Reg1 | ... RegN | UnknownReg deriving (Generic)

{-# ANN module (DataReprAnn
                  $(liftQ [t|MMIO|])
                  32
                  [ ConstrRepr 'Reg0 0xFFF 0x000 []
                  , ConstrRepr 'Reg1 0xFFF 0x004 []
                  ...
                  , ConstrRepr 'RegN 0xFFF 0x??? []
                  , ConstrRepr 'UnknownReg 0x000 0xFFC []
                  ]) #-}

-- This works as intended
readMMIO :: MMIOState -> MMIOReg -> Unsigned 8
readMMIO st Reg0 = ...
readMMIO st Reg1 = ...
readMMIO st ... = ...
readMMIO _ UnknownReg = 0 -- For unknown values return 0

-- But this always return 0 in HDL (but not simulation)
readMMIO' :: MMIOState -> MMIOReg -> Unsigned 8
readMMIO' _ UnknownReg = 0 -- For unknown values return 0
readMMIO' st Reg0 = ...
readMMIO' st Reg1 = ...
readMMIO' st ... = ...

Proposed behaviour

Since both behaviors seems to have use-cases probably it would be best:

  • Always include errorX as last case (user cannot do it without having dead code warning from GHC)
  • On pattern match don't check for bit representation only but check for all previous states. In case of readMMIO' _ UnknownReg = 0 it would lower to readMMIO' _ r | not (reg0Pattern r || reg1Pattern r || ...) = 0; | otherwise = ...

created time in 3 hours

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha d73d13470ea88775782fc2235073f17c64bbec8f

Add simple-nix

view details

push time in 4 hours

create barnchclash-lang/stack-templates

branch : simple-nix

created branch time in 4 hours

issue commentclash-lang/clash-compiler

Use singletons instead of own SNat

singletons already depends on template-haskell, so perhaps the maintainers would accept a PR?

uzytkownik

comment created time in 8 hours

issue commentclash-lang/clash-compiler

romFile expects incorrect size of address bits

Has this been given up on? Since the current romFile is unusable, I don't think there's any backwards compatibility to be maintained.

GuzTech

comment created time in 11 hours

issue commentclash-lang/clash-compiler

Use singletons instead of own SNat

@gergoerdi Yes. The definitions are almost exactly the same:

Singletons:

data SNat (n :: Nat) = KnownNat n => SNat
type instance Sing = SNat

Clash:

data SNat (n :: Nat) where
  SNat :: KnownNat n => SNat n
uzytkownik

comment created time in 12 hours

issue commentclash-lang/clash-compiler

Use singletons instead of own SNat

Can you extract a KnownNat witness from a singletons-style Nat singleton? I would expect that to be the biggest hurdle.

uzytkownik

comment created time in 13 hours

issue openedclash-lang/clash-compiler

Use singletons instead of own SNat

singletons library is already in dependencies of clash. However clash uses own SNat implementation. That means that code using singletons needs to convert back and forth between them.

created time in 20 hours

push eventclash-lang/clash-starters

Clash DevOps

commit sha 1b2054a71711e98de658a783e7697a39150ec39c

Automated push from clash-lang/stack-templates

view details

push time in a day

push eventclash-lang/clash-compiler

Alex McKenna

commit sha 075085754d84b732b75ca9a4b4efeed192a3e6b9

WIP - Implement primops in the partial evaluator

view details

Alex McKenna

commit sha 418a8c8f6a809ee286876a4c1ed092d44171791d

[ci skip] Fixing stuff hopefully

view details

push time in a day

delete branch clash-lang/stack-templates

delete branch : rfc

delete time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 800f23b93befc67b17e77b116b4e184054556ce3

Add doctests to simple project

view details

Martijn Bastiaan

commit sha 44e307288b0a05224d98ec5eb1e1f847c789ef4a

Merge TOUR and README

view details

push time in a day

PR merged clash-lang/stack-templates

RFC comments
  • Add doctests
  • Merge TOUR and README
+371 -272

0 comment

10 changed files

martijnbastiaan

pr closed time in a day

PR opened clash-lang/stack-templates

RFC comments
  • Add doctests
  • Merge TOUR and README
+371 -272

0 comment

10 changed files

pr created time in a day

create barnchclash-lang/stack-templates

branch : rfc

created branch time in a day

push eventclash-lang/clash-starters

Clash DevOps

commit sha 37343676e37020b553021256ee409df0da46c7b0

Automated push from clash-lang/stack-templates

view details

push time in a day

delete branch clash-lang/stack-templates

delete branch : getting-started

delete time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 615c7a768f2803817c82469378c7f885d683a207

Simplify starter project, add TOUR.md

view details

push time in a day

PR merged clash-lang/stack-templates

Simplify starter project, add TOUR.md

I'll add a simple-nix later.

+566 -141

1 comment

9 changed files

martijnbastiaan

pr closed time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 40d084866ebe902eab0756c28f9d9deced6ed380

Simplify starter project, add TOUR.md

view details

push time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 50f0c8b47a6b1c6a7f390f4f59125bf78d8fee3a

Simplify starter project, add TOUR.md

view details

push time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 6ef6076535299edebbf7dbc0161b803cbc58597f

Simplify starter project, add TOUR.md

view details

push time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 3d4c012eafe045e40ce65e2d01a9c7ed325f4a59

debug

view details

push time in a day

push eventclash-lang/stack-templates

Martijn Bastiaan

commit sha 2623dc3bf5ab3ec957d80a4ceb0612ea734aef58

Simplify starter project, add TOUR.md

view details

push time in a day

pull request commentclash-lang/stack-templates

Simplify starter project, add TOUR.md

Implying simple-nix actually exists :wink:

martijnbastiaan

comment created time in 2 days

PR opened clash-lang/stack-templates

Simplify starter project, add TOUR.md

I'll add a simple-nix later.

+413 -110

0 comment

5 changed files

pr created time in 2 days

more