Skip to content
This repository has been archived by the owner on Sep 7, 2018. It is now read-only.

instance BitPack () #77

Open
tomjaguarpaw opened this issue Oct 24, 2016 · 3 comments
Open

instance BitPack () #77

tomjaguarpaw opened this issue Oct 24, 2016 · 3 comments

Comments

@tomjaguarpaw
Copy link

There should be

instance BitPack () where
  type BitSize () = 0
  pack   _ = minBound
  unpack _ = ()

I know this seems trivial but it's going to be needed by someone sooner or later (probably because they are generating code).

@christiaanb
Copy link
Member

@tomjaguarpaw what kind of VHDL/Verilog do you expect CLaSH to output given the following Haskell code?:

topEntity :: BitVector 0 -> BitVector 0
topEntity = id

An entity with 1 input port and 1 output port, both of width 0? Or, an entity without input or output ports?

I'm asking, because VHDL/Verilog synthesis tools loudly complain about things that are 0-bit wide. So if you expect the entity to have an input and an output port, then the instance should be:

instance BitPack () where
  type BitSize () = 1
  pack _ = minBound
  unpack _ = ()

@tomjaguarpaw
Copy link
Author

I've no idea, but this problem seems to be independent of my suggestion.

@tomjaguarpaw
Copy link
Author

I'm not expecting anyone ever to use this instance in a top-level entity in any case ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants