clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.4k stars 147 forks source link

Use of Clash.Signal.Trace trace functions affects simulation #1224

Open JvWesterveld opened 4 years ago

JvWesterveld commented 4 years ago

Code:

module Trace where
import Clash.Prelude

topEntity :: Signal System Bool
topEntity = traceSignal1 "boolean" $ pure True

main = sampleN @System 10 topEntity

clashi 1.2:

Clash.Prelude> :l Trace.hs 
[1 of 1] Compiling Trace            ( Trace.hs, interpreted )
Ok, one module loaded.
*Trace> main
[True,True,True,True,True,True,True,True,True,True]
*Trace> :r
[1 of 1] Compiling Trace            ( Trace.hs, interpreted )
Ok, one module loaded.
*Trace> main
*** Exception: Already tracing a signal with the name: 'boolean'.
CallStack (from HasCallStack):
  error, called at src/Clash/Signal/Trace.hs:171:7 in clash-prelude-1.2.0-inplace:Clash.Signal.Trace

And then clashi needs to be restarted to properly run main again.

leonschoorl commented 4 years ago

@martijnbastiaan has a potential solution for this and many other traceSignal issues in https://github.com/clash-lang/clash-compiler/pull/928