Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.15 KB

readme.md

File metadata and controls

52 lines (38 loc) · 1.15 KB

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.