clash-prelude-0.10.8: CAES Language for Synchronous Hardware - Prelude library

Copyright(C) 2013-2016, University of Twente
LicenseBSD2 (see the file LICENSE)
MaintainerChristiaan Baaij <christiaan.baaij@gmail.com>
Safe HaskellTrustworthy
LanguageHaskell2010

CLaSH.Sized.Unsigned

Description

 

Synopsis

Documentation

data Unsigned n Source

Arbitrary-width unsigned integer represented by n bits

Given n bits, an Unsigned n number has a range of: [0 .. 2^n-1]

NB: The Num operators perform wrap-around on overflow. If you want saturation on overflow, check out the SaturatingNum class.

>>> maxBound :: Unsigned 3
7
>>> minBound :: Unsigned 3
0
>>> read (show (maxBound :: Unsigned 3)) :: Unsigned 3
7
>>> 1 + 2 :: Unsigned 3
3
>>> 2 + 6 :: Unsigned 3
0
>>> 1 - 3 :: Unsigned 3
6
>>> 2 * 3 :: Unsigned 3
6
>>> 2 * 4 :: Unsigned 3
0
>>> (2 :: Unsigned 3) `times` (4 :: Unsigned 3) :: Unsigned 6
8
>>> (2 :: Unsigned 3) `plus` (6 :: Unsigned 3) :: Unsigned 4
8
>>> satPlus SatSymmetric 2 6 :: Unsigned 3
7
>>> satMin SatSymmetric 2 3 :: Unsigned 3
0