clash-prelude-1.8.4: Clash: a functional hardware description language - Prelude library

Copyright | (C) 2018 Google Inc.
License | BSD2 (see the file LICENSE)
Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com>
Safe Haskell | None
Language | Haskell2010

Clash.Annotations.BitRepresentation.Util

Description

Synopsis

- bitOrigins :: DataRepr' -> ConstrRepr' -> [BitOrigin]
- bitOrigins' :: DataRepr' -> ConstrRepr' -> [BitOrigin]
- bitRanges :: Integer -> [(Int, Int)]
- isContinuousMask :: Integer -> Bool
- data BitOrigin
  - = Lit [Bit]
  - | Field Int Int Int
- data Bit
  - = H
  - | L
  - | U

# Documentation

bitOrigins :: DataRepr' -> ConstrRepr' -> [BitOrigin] Source #

Given a type size and one of its constructor this function will yield a specification of which bits the whole type is made up of. I.e., a construction plan on how to make the whole data structure, given its individual constructor fields.

bitOrigins' :: DataRepr' -> ConstrRepr' -> [BitOrigin] Source #

Same as bitOrigins, but each item in result list represents a single bit.

bitRanges :: Integer -> [(Int, Int)] Source #

Determine consecutively set bits in word. Will produce ranges from high to low. Examples:

bitRanges 0b10 == [(1,1)] bitRanges 0b101 == [(2,2),(0,0)] bitRanges 0b10011001111 == [(10,10),(7,6),(3,0)]

isContinuousMask :: Integer -> Bool Source #

data BitOrigin Source #

Result of various utilty functions. Indicates the origin of a certain bit: either a literal from the constructor (or an undefined bit), or from a literal.

Constructors

Lit [Bit] | Literal (high, low, undefind)
Field Int Int Int | Bits originate from a field. Field fieldnr from downto.

#### Instances

Instances details

Show BitOrigin Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Util Methods showsPrec :: Int -> BitOrigin -> ShowS Source # show :: BitOrigin -> String Source # showList :: [BitOrigin] -> ShowS Source #

data Bit Source #

Constructors

H | High
L | Low
U | Undefined

#### Instances

Instances details

Show Bit Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Util Methods showsPrec :: Int -> Bit -> ShowS Source # show :: Bit -> String Source # showList :: [Bit] -> ShowS Source #
Eq Bit Source # |
Instance details Defined in Clash.Annotations.BitRepresentation.Util Methods (==) :: Bit -> Bit -> Bool Source # (/=) :: Bit -> Bit -> Bool Source #