Skip to content

Synthesis attributes not found when using type aliases #1771

@martijnbastiaan

Description

@martijnbastiaan

This:

module Test where

import Clash.Explicit.Prelude
import Clash.Annotations.SynthesisAttributes

top :: BitVector 1 `Annotate` [ 'StringAttr "chip_pin" "XX" ] -> BitVector 1 
top a = a

produces:

(* chip_pin = "XX" *) input [0:0] a

When using an intermediate type synonym, this fails. E.g., this:

module Test where

import Clash.Explicit.Prelude
import Clash.Annotations.SynthesisAttributes

type X = '[ 'StringAttr "chip_pin" "XX" ]

top :: BitVector 1 `Annotate` X -> BitVector 1 
top a = a

produces:

input [0:0] a

while I would expect them to behave identically. Weirdly, when using:

module Test where

import Clash.Explicit.Prelude
import Clash.Annotations.SynthesisAttributes

-- No []
type X = 'StringAttr "chip_pin" "XX"

top :: BitVector 1 `Annotate` X -> BitVector 1 
top a = a

Clash fails explicitly:

<no location info>: error:
    Clash error call:
    Expected StringAttr, IntegerAttr, BoolAttr or Attr constructor, got:Test.X
    CallStack (from HasCallStack):
      error, called at src-ghc/Clash/GHC/GHC2Core.hs:824:9 in clash-ghc-1.4.1-Fkb2bPkpKD58uHIycIlSqz:Clash.GHC.GHC2Core

This is an issue in GHC2Core. coreToAttrs & friends should account for type synonyms.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions