Skip to content

Commit

Permalink
Add Clash.Annotations.SynthesisAttributes.markDebug
Browse files Browse the repository at this point in the history
Add a term level way of marking a signal as "debug". This instructs
synthesizers to leave a signal alone, even after optimizations.
  • Loading branch information
martijnbastiaan committed Jul 19, 2023
1 parent 21868f2 commit 793f6a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/2023-07-16T13_34_31+02_00_add_markDebug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ADDED: `Clash.Annotations.SynthesisAttributes.markDebug`: a way of marking a signals "debug", instructing synthesizers to leave the signal alone and offer debug features
18 changes: 18 additions & 0 deletions clash-prelude/src/Clash/Annotations/SynthesisAttributes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Clash.Annotations.SynthesisAttributes
( Attr(..)
, Annotate
, annotate
, markDebug
) where

import Control.DeepSeq (NFData)
Expand Down Expand Up @@ -139,3 +140,20 @@ annotate !_attrs !a = a
templateFunction: "Clash.Primitives.Annotations.SynthesisAttributes.annotateBBF"
workInfo: Always
|] #-}

-- | Insert attributes such that signals are preserved in major synthesis tools.
-- Also inserts "mark_debug", a way of signalling Vivado a signal should show up
-- in a list of signals desired for ILA/VIO insertion.
--
-- Attributes inserted: @keep@, @mark_debug@, @noprune@, and @preserve@.
markDebug :: Signal dom a -> Signal dom a
markDebug = annotate $
BoolAttr "keep" True

-- Vivado:
:> BoolAttr "mark_debug" True

-- Quartus:
:> Attr "noprune"
:> Attr "preserve"
:> Nil

0 comments on commit 793f6a6

Please sign in to comment.