Skip to content

Commit 9bfca00

Browse files
Clarify BitPack is not for creating custom encodings (#2575)
1 parent 540cf0e commit 9bfca00

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

clash-prelude/src/Clash/Class/BitPack/Internal.hs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-|
22
Copyright : (C) 2013-2016, University of Twente,
33
2016-2017, Myrtle Software Ltd,
4-
2021-2022 QBayLogic B.V.,
4+
2021-2023 QBayLogic B.V.,
55
2022, Google Inc.
66
License : BSD2 (see the file LICENSE)
77
Maintainer : QBayLogic B.V. <[email protected]>
@@ -79,6 +79,19 @@ import Clash.XException
7979
-- instances, as even if @a@ has a statically known size, the length of the
8080
-- list cannot be known in advance.
8181
--
82+
-- It is not possible to give data a custom bit representation by providing a
83+
-- @BitPack@ instance. A @BitPack@ instance allows no creativity and should
84+
-- always accurately reflect the bit representation of the data in HDL. You
85+
-- should always @derive ('Generic', BitPack)@ unless you use a custom data
86+
-- representation, in which case you should use
87+
-- 'Clash.Annotations.BitRepresentation.Deriving.deriveBitPack'. Custom
88+
-- encodings can be created with "Clash.Annotations.BitRepresentation" and
89+
-- "Clash.Annotations.BitRepresentation.Deriving".
90+
--
91+
-- If the @BitPack@ instance does not accurately match the bit representation of
92+
-- the data in HDL, Clash designs will exhibit incorrect behavior in various
93+
-- places.
94+
--
8295
-- Clash provides some generic functions on packable types in the prelude, such
8396
-- as indexing into packable stuctures (see "Clash.Class.BitPack.BitIndex") and
8497
-- bitwise reduction of packable data (see "Clash.Class.BitPack.BitReduction").

0 commit comments

Comments
 (0)