Giter VIP home page Giter VIP logo

clash-wavedrom's Introduction

Clash-WaveDrom

Generate wave diagrams from Clash with WaveDrom.

Examples

It can show records with labeled waves (nested records work as you'd expect).

data Gray n = Gray
  { count  :: Unsigned n
  , gray :: BitVector n
  }
  deriving stock Generic
  deriving anyclass (NFData, ToWave)

readmeSignal :: Signal System (Gray 3)
readmeSignal =
  let count = register 0 (countSucc <$> count)
      gray  = (\x -> (x `shiftR` 1) `xor` x) . bitCoerce <$> count
  in  Gray <$> count <*> gray
renderToSVG "gray.svg" (wavedromWithReset 10 "" readmeSignal)

Gray code wave diagram


It can render the Show representation alongside the BitPack representation very easily.

eitherSignal :: Signal System (Either (Index 8) (Index 3))
eitherSignal = let x = register (Right 0) (countSucc <$> x) in x
renderToSVG
  "either.svg"
  (wavedromWithClock 10 "" (WithBits <$> eitherSignal))
    { config = object ["hscale" .= (2 :: Int)]
    }

Either counter wave diagram

Observe the undefined bits being handled correctly.


clash-wavedrom's People

Contributors

expipiplus1 avatar

Stargazers

Christopher Chappell avatar Jimmy Vogel avatar  avatar  avatar  avatar Tristan de Cacqueray avatar Basile Henry avatar  avatar  avatar Ichiro Kawashima avatar Shae Erisson avatar  avatar  avatar Jakub Kopański avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar

clash-wavedrom's Issues

Fails to build with GHC>=9.0, singletons >=3.0

I tried to patch it myself here but I got stuck!

vanessa@vanessa-desktop /development/haskell/forks/clash-wavedrom 🌸 cabal build -w ghc-9.0.2 --constraint='clash-prelude>=1.6'
Resolving dependencies...
Build profile: -w ghc-9.0.2 -O1
In order, the following will be built (use -v for more details):
 - clash-wavedrom-0.0.0.0 (lib) (first run)
Preprocessing library for clash-wavedrom-0.0.0.0..
Building library for clash-wavedrom-0.0.0.0..
[1 of 3] Compiling Clash.WaveDrom.Internal ( src/Clash/WaveDrom/Internal.hs, /development/haskell/forks/clash-wavedrom/dist-newstyle/build/x86_64-linux/ghc-9.0.2/clash-wavedrom-0.0.0.0/build/Clash/WaveDrom/Internal.o, /development/haskell/forks/clash-wavedrom/dist-newstyle/build/x86_64-linux/ghc-9.0.2/clash-wavedrom-0.0.0.0/build/Clash/WaveDrom/Internal.dyn_o )

src/Clash/WaveDrom/Internal.hs:326:2: error:
    • Couldn't match type: SProxy p0
                           -> SSymbol n0 -> STree (WaveShape a0 n0)
                     with: SLambda f0
      Expected: SLambda f0
        Actual: Sing p0 -> Sing n0 -> Sing (WaveShape a0 n0)
    • Probable cause: ‘sWaveShapeP’ is applied to too few arguments
      In the first argument of ‘applySing’, namely ‘sWaveShapeP’
      In the first argument of ‘applySing’, namely
        ‘((applySing sWaveShapeP) sA)’
      In the second argument of ‘applySing’, namely
        ‘((applySing ((applySing sWaveShapeP) sA))
            ((applySing ((singFun1 @Show_Sym0) sShow_))
               ((applySing ((applySing ((singFun2 @(-@#@$)) (%-))) sI))
                  (sFromInteger (sing :: Sing 1)))))’
    • Relevant bindings include
        sA :: Sing t (bound at src/Clash/WaveDrom/Internal.hs:326:2)
        sIndexedDsc :: Sing t
                       -> Sing t1 -> Sing (Apply (Apply IndexedDscSym0 t) t1)
          (bound at src/Clash/WaveDrom/Internal.hs:326:2)
    |
326 | $(singletonsOnly [d|
    |  ^^^^^^^^^^^^^^^^^^^...

(not sure what is going on with singletons here)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.