packages feed

clash-vhdl 0.6.4 → 0.6.5

raw patch · 20 files changed

+1388/−212 lines, 20 files

Files

CHANGELOG.md view
@@ -1,5 +1,10 @@ # Changelog for the [`clash-vhdl`](http://hackage.haskell.org/package/clash-vhdl) package +## 0.6.5 *January 13th 2015*+* New features:+  * Support for Haskell's: `Char`, `Int8`, `Int16`, `Int32`, `Int64`, `Word`, `Word8`, `Word16`, `Word32`, `Word64`.+  * Int/Word/Integer bitwidth for generated VHDL is configurable using the `-clash-intwidth=N` flag, where `N` can be either 32 or 64.+ ## 0.6.4 *November 17th 2015* * Fixes bugs:   * Integer literals should only be capped to 32-bit when used in assignments.
clash-vhdl.cabal view
@@ -1,5 +1,5 @@ Name:                 clash-vhdl-Version:              0.6.4+Version:              0.6.5 Synopsis:             CAES Language for Synchronous Hardware - VHDL backend Description:   CλaSH (pronounced ‘clash’) is a functional hardware description language that@@ -66,11 +66,13 @@                       primitives/GHC.Classes.json                       primitives/GHC.CString.json                       primitives/GHC.Err.json+                      primitives/GHC.Int.json                       primitives/GHC.Integer.Type.json                       primitives/GHC.Prim.json                       primitives/GHC.Real.json                       primitives/GHC.Typelits.json                       primitives/GHC.Types.json+                      primitives/GHC.Word.json                       primitives/Unsafe.Coerce.json  Cabal-version:        >=1.10
primitives/CLaSH.Prelude.BlockRam.File.json view
@@ -32,13 +32,13 @@   signal wr_~SYM[3]   : integer range 0 to ~LIT[2]-1;   signal rd_~SYM[4]   : integer range 0 to ~LIT[2]-1; begin-  wr_~SYM[3] <= ~ARG[4]+  wr_~SYM[3] <= to_integer(~ARG[4])   -- pragma translate_off                 mod ~LIT[2]   -- pragma translate_on                 ; -  rd_~SYM[4] <= ~ARG[5]+  rd_~SYM[4] <= to_integer(~ARG[5])   -- pragma translate_off                 mod ~LIT[2]   -- pragma translate_on@@ -48,7 +48,7 @@   begin     if (rising_edge(~CLK[1])) then       if ~ARG[6] then-        RAM_~SYM[1](to_integer(wr_~SYM[3])) <= to_bitvector(~ARG[7]);+        RAM_~SYM[1](wr_~SYM[3]) <= to_bitvector(~ARG[7]);       end if;        dout_~SYM[2] <= to_stdlogicvector(RAM_~SYM[1](rd_~SYM[4]));
primitives/CLaSH.Prelude.BlockRam.json view
@@ -17,13 +17,13 @@   signal wr_~SYM[3]   : integer range 0 to ~LIT[0] - 1;   signal rd_~SYM[4]   : integer range 0 to ~LIT[0] - 1; begin-  wr_~SYM[3] <= ~ARG[3]+  wr_~SYM[3] <= to_integer(~ARG[3])   -- pragma translate_off                 mod ~LIT[0]   -- pragma translate_on                 ; -  rd_~SYM[4] <= ~ARG[4]+  rd_~SYM[4] <= to_integer(~ARG[4])   -- pragma translate_off                 mod ~LIT[0]   -- pragma translate_on
primitives/CLaSH.Prelude.RAM.json view
@@ -17,13 +17,13 @@   signal wr_~SYM[2]  : integer range 0 to ~LIT[2] - 1;   signal rd_~SYM[3]  : integer range 0 to ~LIT[2] - 1; begin-  wr_~SYM[2] <= ~ARG[3]+  wr_~SYM[2] <= to_integer(~ARG[3])   -- pragma translate_off                 mod ~LIT[2]   -- pragma translate_on                 ; -  rd_~SYM[3] <= ~ARG[4]+  rd_~SYM[3] <= to_integer(~ARG[4])   -- pragma translate_off                 mod ~LIT[2]   -- pragma translate_on
primitives/CLaSH.Prelude.ROM.File.json view
@@ -26,7 +26,7 @@   signal ROM_~SYM[1] : RomType(0 to ~LIT[1]-1) := InitRomFromFile(~FILE[~LIT[2]]);   signal rd_~SYM[2]  : integer range 0 to ~LIT[1]-1; begin-  rd_~SYM[2] <= ~ARG[3]+  rd_~SYM[2] <= to_integer(~ARG[3])   -- pragma translate_off                 mod ~LIT[1]   -- pragma translate_on@@ -67,7 +67,7 @@   signal rd_~SYM[2]   : integer range 0 to ~LIT[2]-1;   signal dout_~SYM[3] : ~TYPO; begin-  rd_~SYM[2] <= ~ARG[4]+  rd_~SYM[2] <= to_integer(~ARG[4])   -- pragma translate_off                 mod ~LIT[2]   -- pragma translate_on
primitives/CLaSH.Prelude.ROM.json view
@@ -13,7 +13,7 @@ begin   ROM_~SYM[1] <= ~ARG[1]; -  rom_index~SYM[2] <= ~ARG[2]+  rom_index~SYM[2] <= to_integer(~ARG[2])   -- pragma translate_off                       mod ~LIT[0]   -- pragma translate_on@@ -41,7 +41,7 @@ begin   ROM_~SYM[1] <= ~ARG[2]; -  rd_~SYM[2] <= ~ARG[3]+  rd_~SYM[2] <= to_integer(~ARG[3])   -- pragma translate_off                 mod ~LIT[0]   -- pragma translate_on
primitives/CLaSH.Promoted.Nat.json view
@@ -7,7 +7,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Promoted.Nat.snatToInteger"     , "type"      : "snatToInteger :: SNat n -> Integer"-    , "templateE" : "~LIT[0]"+    , "templateE" : "~ARG[0]"     }   } , { "BlackBox" :
primitives/CLaSH.Sized.Internal.BitVector.json view
@@ -1,13 +1,13 @@ [ { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.size#"     , "type"      : "size# :: KnownNat n => BitVector n -> Int"-    , "templateE" : "~LIT[0]"+    , "templateE" : "to_signed(~LIT[0],~SIZE[~TYPO])"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.maxIndex#"     , "type"      : "maxIndex# :: KnownNat n => BitVector n -> Int"-    , "templateE" : "~LIT[0] - 1"+    , "templateE" : "to_signed(~LIT[0] - 1,~SIZE[~TYPO])"     }   } , { "BlackBox" :@@ -142,7 +142,7 @@ begin   vec <= ~ARG[1]; -  vec_index <= ~ARG[2]+  vec_index <= to_integer(~ARG[2])   -- pragma translate_off                mod ~LIT[0]   -- pragma translate_on@@ -169,7 +169,7 @@   signal din       : ~TYP[3]; begin   vec <= ~ARG[1];-  vec_index <= ~ARG[2]+  vec_index <= to_integer(~ARG[2])   -- pragma translate_off                mod ~LIT[0]   -- pragma translate_on@@ -366,7 +366,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.fromInteger#"     , "type"      : "fromInteger# :: KnownNat n => Integer -> BitVector n"-    , "templateE" : "std_logic_vector(to_unsigned(~ARG[1],~LIT[0]))"+    , "templateE" : "std_logic_vector(resize(unsigned(std_logic_vector(~ARG[1])),~LIT[0]))"     }   } , { "BlackBox" :@@ -402,7 +402,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.toInteger#"     , "type"      : "toInteger# :: BitVector n -> Integer"-    , "templateE" : "to_integer(unsigned(~ARG[0]))"+    , "templateE" : "signed(std_logic_vector(resize(unsigned(~ARG[0]),~SIZE[~TYPO])))"     }   } , { "BlackBox" :@@ -432,25 +432,25 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.shiftL#"     , "type"      : "shiftL# :: KnownNat n => BitVector n -> Int -> BitVector n"-    , "templateE" : "std_logic_vector(shift_left(unsigned(~ARG[1]),~ARG[2]))"+    , "templateE" : "std_logic_vector(shift_left(unsigned(~ARG[1]),to_integer(~ARG[2])))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.shiftR#"     , "type"      : "shiftR# :: KnownNat n => BitVector n -> Int -> BitVector n"-    , "templateE" : "std_logic_vector(shift_right(unsigned(~ARG[1]),~ARG[2]))"+    , "templateE" : "std_logic_vector(shift_right(unsigned(~ARG[1]),to_integer(~ARG[2])))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.rotateL#"     , "type"      : "rotateL# :: KnownNat n => BitVector n -> Int -> BitVector n"-    , "templateE" : "std_logic_vector(rotate_left(unsigned(~ARG[1]),~ARG[2]))"+    , "templateE" : "std_logic_vector(rotate_left(unsigned(~ARG[1]),to_integer(~ARG[2])))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.BitVector.rotateR#"     , "type"      : "rotateR# :: KnownNat n => BitVector n -> Int -> BitVector n"-    , "templateE" : "std_logic_vector(rotate_right(unsigned(~ARG[1]),~ARG[2]))"+    , "templateE" : "std_logic_vector(rotate_right(unsigned(~ARG[1]),to_integer(~ARG[2])))"     }   } , { "BlackBox" :
primitives/CLaSH.Sized.Internal.Index.json view
@@ -73,7 +73,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Index.fromInteger#"     , "type"      : "fromInteger# :: KnownNat n => Integer -> Index n"-    , "templateE" : "to_unsigned(~ARG[1],~SIZE[~TYPO])"+    , "templateE" : "resize(unsigned(std_logic_vector(~ARG[1])),~SIZE[~TYPO])"     }   } , { "BlackBox" :@@ -109,7 +109,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Index.toInteger#"     , "type"      : "toInteger# :: Index n -> Integer"-    , "templateE" : "to_integer(~ARG[0])"+    , "templateE" : "signed(std_logic_vector(resize(~ARG[0],~SIZE[~TYPO])))"     }   } , { "BlackBox" :
primitives/CLaSH.Sized.Internal.Signed.json view
@@ -1,7 +1,7 @@ [ { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.size#"     , "type"      : "size# :: KnownNat n => Signed n -> Int"-    , "templateE" : "~LIT[0]"+    , "templateE" : "to_signed(~LIT[0],~SIZE[~TYPO])"     }   } , { "BlackBox" :@@ -101,7 +101,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.fromInteger#"     , "type"      : "fromInteger# :: KnownNat n => Integer -> Signed (n :: Nat)"-    , "templateE" : "to_signed(~ARG[1],~LIT[0])"+    , "templateE" : "resize(~ARG[1],~LIT[0])"     }   } , { "BlackBox" :@@ -162,7 +162,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.toInteger#"     , "type"      : "toInteger# :: Signed n -> Integer"-    , "templateE" : "to_integer(~ARG[0])"+    , "templateE" : "resize(~ARG[0],~SIZE[~TYPO])"     }   } , { "BlackBox" :@@ -192,25 +192,25 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.shiftL#"     , "type"      : "shiftL# :: KnownNat n => Signed n -> Int -> Signed n"-    , "templateE" : "shift_left(~ARG[1],~ARG[2])"+    , "templateE" : "shift_left(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.shiftR#"     , "type"      : "shiftR# :: KnownNat n => Signed n -> Int -> Signed n"-    , "templateE" : "shift_right(~ARG[1],~ARG[2])"+    , "templateE" : "shift_right(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.rotateL#"     , "type"      : "rotateL# :: KnownNat n => Signed n -> Int -> Signed n"-    , "templateE" : "rotate_left(~ARG[1],~ARG[2])"+    , "templateE" : "rotate_left(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Signed.rotateR#"     , "type"      : "rotateR# :: KnownNat n => Signed n -> Int -> Signed n"-    , "templateE" : "rotate_right(~ARG[1],~ARG[2])"+    , "templateE" : "rotate_right(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :
primitives/CLaSH.Sized.Internal.Unsigned.json view
@@ -1,7 +1,7 @@ [ { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.size#"     , "type"      : "size# :: KnownNat n => Unsigned n -> Int"-    , "templateE" : "~LIT[0]"+    , "templateE" : "to_signed(~LIT[0],~SIZE[~TYPO])"     }   } , { "BlackBox" :@@ -93,7 +93,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.fromInteger#"     , "type"      : "fromInteger# :: KnownNat n => Integer -> Unsigned n"-    , "templateE" : "to_unsigned(~ARG[1],~LIT[0])"+    , "templateE" : "resize(unsigned(std_logic_vector(~ARG[1])),~LIT[0])"     }   } , { "BlackBox" :@@ -129,7 +129,7 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.toInteger#"     , "type"      : "toInteger# :: Unsigned n -> Integer"-    , "templateE" : "to_integer(~ARG[0])"+    , "templateE" : "signed(std_logic_vector(resize(~ARG[0],~SIZE[~TYPO])))"     }   } , { "BlackBox" :@@ -159,25 +159,25 @@ , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.shiftL#"     , "type"      : "shiftL# :: KnownNat n => Unsigned n -> Int -> Unsigned n"-    , "templateE" : "shift_left(~ARG[1],~ARG[2])"+    , "templateE" : "shift_left(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.shiftR#"     , "type"      : "shiftR# :: KnownNat n => Unsigned n -> Int -> Unsigned n"-    , "templateE" : "shift_right(~ARG[1],~ARG[2])"+    , "templateE" : "shift_right(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.rotateL#"     , "type"      : "rotateL# :: KnownNat n => Unsigned n -> Int -> Unsigned n"-    , "templateE" : "rotate_left(~ARG[1],~ARG[2])"+    , "templateE" : "rotate_left(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Internal.Unsigned.rotateR#"     , "type"      : "rotateR# :: KnownNat n => Unsigned n -> Int -> Unsigned n"-    , "templateE" : "rotate_right(~ARG[1],~ARG[2])"+    , "templateE" : "rotate_right(~ARG[1],to_integer(~ARG[2]))"     }   } , { "BlackBox" :
primitives/CLaSH.Sized.Vector.json view
@@ -291,7 +291,7 @@ begin   vec <= ~ARG[1]; -  vec_index <= ~ARG[2]+  vec_index <= to_integer(~ARG[2])   -- pragma translate_off                mod ~LIT[0]   -- pragma translate_on@@ -313,7 +313,7 @@   signal din       : ~TYP[3]; begin   vec <= ~ARG[1];-  vec_index <= ~ARG[2]+  vec_index <= to_integer(~ARG[2])   -- pragma translate_off                mod ~LIT[0]   -- pragma translate_on@@ -333,14 +333,14 @@   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Vector.maxIndex"-    , "type"      : "maxIndex :: KnownNat n => Vec n a -> Integer"-    , "templateE" : "~LIT[0] - 1"+    , "type"      : "maxIndex :: KnownNat n => Vec n a -> Int"+    , "templateE" : "to_signed(~LIT[0] - 1,~SIZE[~TYPO])"     }   } , { "BlackBox" :     { "name"      : "CLaSH.Sized.Vector.length"-    , "type"      : "length :: KnownNat n => Vec n a -> Integer"-    , "templateE" : "~LIT[0]"+    , "type"      : "length :: KnownNat n => Vec n a -> Int"+    , "templateE" : "to_signed(~LIT[0],~SIZE[~TYPO])"     }   } , { "BlackBox" :
+ primitives/GHC.Int.json view
@@ -0,0 +1,25 @@+[ { "BlackBox" :+    { "name"      : "GHC.Int.I8#"+    , "type"      : "I8# :: Int# -> Int8"+    , "templateE" : "resize(~ARG[0],8)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Int.I16#"+    , "type"      : "I16# :: Int# -> Int16"+    , "templateE" : "resize(~ARG[0],16)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Int.I32#"+    , "type"      : "I32# :: Int# -> Int32"+    , "templateE" : "resize(~ARG[0],32)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Int.I64#"+    , "type"      : "I64# :: Int# -> Int64"+    , "templateE" : "resize(~ARG[0],64)"+    }+  }+]
primitives/GHC.Integer.Type.json view
@@ -112,49 +112,49 @@ , { "BlackBox" :     { "name"      : "GHC.Integer.Type.eqInteger#"     , "type"      : "eqInteger# :: Integer -> Integer -> Int#"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] = ~ARG[1] else 0;"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] = ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.neqInteger#"     , "type"      : "neqInteger# :: Integer -> Integer -> Int#"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] /= ~ARG[1] else 0;"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] /= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.leInteger#"     , "type"      : "leInteger# :: Integer -> Integer -> Int#"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] <= ~ARG[1] else 0;"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] <= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.gtInteger#"     , "type"      : "gtInteger# :: Integer -> Integer -> Int#"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] > ~ARG[1] else 0;"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] > ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.ltInteger#"     , "type"      : "ltInteger# :: Integer -> Integer -> Int#"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] < ~ARG[1] else 0;"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] < ~ARG[1] else to_signed(1,~SIZE[~TYPO]);"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.geInteger#"     , "type"      : "geInteger# :: Integer -> Integer -> Int#"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] >= ~ARG[1] else 0;"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] >= ~ARG[1] else to_signed(1,~SIZE[~TYPO]);"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.shiftRInteger"     , "type"      : "shiftRInteger :: Integer -> Int# -> Integer"-    , "templateE" : "~ARG[0] / (2**~ARG[1])"+    , "templateE" : "~ARG[0] / (2**to_integer(~ARG[1]))"     }   } , { "BlackBox" :     { "name"      : "GHC.Integer.Type.shiftLInteger"     , "type"      : "shiftLInteger :: Integer -> Int# -> Integer"-    , "templateE" : "~ARG[0] * (2**~ARG[1])"+    , "templateE" : "~ARG[0] * (2**to_integer(~ARG[1]))"     }   } ]
primitives/GHC.Prim.json view
@@ -1,107 +1,1207 @@ [ { "BlackBox" :-    { "name"      : "GHC.Prim.+#"-    , "type"      : "(+#) :: Int# -> Int# -> Int#"-    , "templateE" : "~ARG[0] + ~ARG[1]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.-#"-    , "type"      : "(-#) :: Int# -> Int# -> Int#"-    , "templateE" : "~ARG[0] - ~ARG[1]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.*#"-    , "type"      : "(*#) :: Int# -> Int# -> Int#"-    , "templateE" : "~ARG[0] * ~ARG[1]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.quotInt#"-    , "type"      : "quotInt# :: Int# -> Int# -> Int#"-    , "templateE" : "~ARG[0] / ~ARG[1]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.remInt#"-    , "type"      : "remInt# :: Int# -> Int# -> Int#"-    , "templateE" : "~ARG[0] rem ~ARG[1]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.negateInt#"-    , "type"      : "negateInt# :: Int# -> Int#"-    , "templateE" : "-~ARG[0]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.>#"-    , "type"      : "(>#) :: Int# -> Int# -> Bool"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] > ~ARG[1] else 0;"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.>=#"-    , "type"      : "(>=#) :: Int# -> Int# -> Bool"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] >= ~ARG[1] else 0;"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.==#"-    , "type"      : "(==) :: Int# -> Int# -> Bool"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] = ~ARG[1] else 0;"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim./=#"-    , "type"      : "(/=#) :: Int# -> Int# -> Bool"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] /= ~ARG[1] else 0;"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.<#"-    , "type"      : "(<#) :: Int# -> Int# -> Bool"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] < ~ARG[1] else 0;"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.<=#"-    , "type"      : "(<=#) :: Int# -> Int# -> Bool"-    , "templateD" : "~RESULT <= 1 when ~ARG[0] <= ~ARG[1] else 0;"-    }-  }-, { "Primitive" :-    { "name"     : "GHC.Prim.dataToTag#"-    , "primType" : "Function"-    }-  }-, { "Primitive" :-    { "name"     : "GHC.Prim.tagToEnum#"-    , "primType" : "Function"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.unsafeCoerce#"-    , "type"      : "unsafeCoerce# :: a -> b"-    , "templateE" : "~ARG[0]"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.uncheckedIShiftRA#"-    , "type"      : "uncheckedIShiftRA# :: Int# -> Int# -> Int#"-    , "templateE" : "to_integer(shift_right(to_signed(~ARG[0],32),~ARG[1]))"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.uncheckedIShiftRL#"-    , "type"      : "uncheckedIShiftRL# :: Int# -> Int# -> Int#"-    , "templateE" : "to_integer(to_signed(~ARG[0],32) srl ~ARG[1])"-    }-  }-, { "BlackBox" :-    { "name"      : "GHC.Prim.uncheckedIShiftL#"-    , "type"      : "uncheckedIShiftL# :: Int# -> Int# -> Int#"-    , "templateE" : "to_integer(shift_left(to_signed(~ARG[0],32),~ARG[1]))"+    { "name"      : "GHC.Prim.gtChar#"+    , "type"      : "gtChar# :: Char# -> Char# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] > ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.geChar#"+    , "type"      : "geChar# :: Char# -> Char# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] >= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.eqChar#"+    , "type"      : "eqChar# :: Char# -> Char# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] = ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.neChar#"+    , "type"      : "neChar# :: Char# -> Char# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] /= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ltChar#"+    , "type"      : "ltChar# :: Char# -> Char# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] < ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.leChar#"+    , "type"      : "leChar# :: Char# -> Char# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] <= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ord#"+    , "type"      : "ord# :: Char# -> Int#"+    , "templateE" : "signed(std_logic_vector(resize(~ARG[0],~SIZE[~TYPO])))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.+#"+    , "type"      : "(+#) :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] + ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.-#"+    , "type"      : "(-#) :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] - ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.*#"+    , "type"      : "(*#) :: Int# -> Int# -> Int#"+    , "templateE" : "resize(~ARG[0] * ~ARG[1],~SIZE[~TYPO])"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.quotInt#"+    , "type"      : "quotInt# :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] / ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.remInt#"+    , "type"      : "remInt# :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] rem ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.quotRemInt#"+    , "type"      : "quotRemInt# :: Int# -> Int# -> (#Int#, Int##)"+    , "templateE" : "(~ARG[0] / ~ARG[1], ~ARG[0] rem ~ARG[1])"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.andI#"+    , "type"      : "and# :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] and ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.orI#"+    , "type"      : "or# :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] or ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.xorI#"+    , "type"      : "xor# :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] xor ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.notI#"+    , "type"      : "not# :: Int# -> Int#"+    , "templateE" : "not ~ARG[0]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.negateInt#"+    , "type"      : "negateInt# :: Int# -> Int#"+    , "templateE" : "-~ARG[0]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.>#"+    , "type"      : "(>#) :: Int# -> Int# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] > ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.>=#"+    , "type"      : "(>=#) :: Int# -> Int# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] >= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.==#"+    , "type"      : "(==) :: Int# -> Int# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] = ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim./=#"+    , "type"      : "(/=#) :: Int# -> Int# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] /= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.<#"+    , "type"      : "(<#) :: Int# -> Int# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] < ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.<=#"+    , "type"      : "(<=#) :: Int# -> Int# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] <= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.chr#"+    , "type"      : "ord# :: Int# -> Chr#"+    , "templateE" : "resize(unsigned(std_logic_vector(~ARG[0])),21)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.int2Word#"+    , "type"      : "word2Int# :: Int# -> Word#"+    , "templateE" : "unsigned(std_logic_vector(~ARG[0]))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.uncheckedIShiftL#"+    , "type"      : "uncheckedIShiftL# :: Int# -> Int# -> Int#"+    , "templateE" : "shift_left(~ARG[0],to_integer(~ARG[1]))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.uncheckedIShiftRA#"+    , "type"      : "uncheckedIShiftRA# :: Int# -> Int# -> Int#"+    , "templateE" : "shift_right(~ARG[0],to_integer(~ARG[1]))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.uncheckedIShiftRL#"+    , "type"      : "uncheckedIShiftRL# :: Int# -> Int# -> Int#"+    , "templateE" : "~ARG[0] srl to_integer(~ARG[1])"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.plusWord#"+    , "type"      : "plusWord# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] + ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.minusWord#"+    , "type"      : "minusWord# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] - ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.timesWord#"+    , "type"      : "timesWord# :: Word# -> Word# -> Word#"+    , "templateE" : "resize(~ARG[0] * ~ARG[1],~SIZE[~TYPO])"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.quotWord#"+    , "type"      : "quotWord# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] / ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.remWord#"+    , "type"      : "remWord# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] rem ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.quotRemWord#"+    , "type"      : "quotRemWord# :: Word# -> Word# -> (#Word#, Word##)"+    , "templateE" : "(~ARG[0] / ~ARG[1], ~ARG[0] rem ~ARG[1])"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.and#"+    , "type"      : "and# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] and ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.or#"+    , "type"      : "or# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] or ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.xor#"+    , "type"      : "xor# :: Word# -> Word# -> Word#"+    , "templateE" : "~ARG[0] xor ~ARG[1]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.not#"+    , "type"      : "not# :: Word# -> Word#"+    , "templateE" : "not ~ARG[0]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.uncheckedShiftL#"+    , "type"      : "uncheckedShiftL# :: Word# -> Int# -> Word#"+    , "templateE" : "shift_left(~ARG[0],to_integer(~ARG[1]))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.uncheckedShiftRL#"+    , "type"      : "uncheckedShiftR# :: Word# -> Int# -> Word#"+    , "templateE" : "shift_right(~ARG[0],to_integer(~ARG[1]))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.word2Int#"+    , "type"      : "word2Int# :: word# -> Int#"+    , "templateE" : "signed(std_logic_vector(~ARG[0]))"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.gtWord#"+    , "type"      : "gtWord# :: Word# -> Word# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] > ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.geWord#"+    , "type"      : "geWord# :: Word# -> Word# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] >= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.eqWord#"+    , "type"      : "eqWord# :: Word# -> Word# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] = ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.neWord#"+    , "type"      : "neWord# :: Word# -> Word# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] /= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ltWord#"+    , "type"      : "ltWord# :: Word# -> Word# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] < ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.leWord#"+    , "type"      : "leWord# :: Word# -> Word# -> Int#"+    , "templateD" : "~RESULT <= to_signed(1,~SIZE[~TYPO]) when ~ARG[0] <= ~ARG[1] else to_signed(0,~SIZE[~TYPO]);"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.popCnt8#"+    , "type"      : "popCnt8 :: Word# -> Word#"+    , "templateD" :+"-- popCnt8 begin+popCnt8_~SYM[0] : block+  -- given a level and a depth, calculate the corresponding index into the+  -- intermediate array+  function depth2Index (levels,depth : in natural) return natural is+  begin+    return (2 ** levels - 2 ** depth);+  end function;++  constant width : natural := 8;+  constant levels : natural := natural (ceil (log2 (real (width))));+  type popCnt_res_vec is array (natural range <>) of unsigned(levels downto 0);+  signal intermediate_~SYM[1] : popCnt_res_vec(0 to (2*width)-2);+begin+  -- put input into the first half of the intermediate array+  make_array: for i in 0 to (width - 1) generate+    intermediate_~SYM[1](i) <= resize(~ARG[0](i downto i),levels+1);+  end generate;++  -- Create the tree of adders+  make_tree : if levels /= 0 generate+    tree_depth : for d in levels-1 downto 0 generate+      tree_depth_loop: for i in 0 to (natural(2**d) - 1) generate+        intermediate_~SYM[1](depth2Index(levels+1,d+1)+i) <=+          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)) ++          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)+1);+      end generate;+    end generate;+  end generate;++  -- The last element of the intermediate array holds the result+  ~RESULT <= resize(intermediate_~SYM[1]((2*width)-2),~SIZE[~TYPO]);+end block;+-- popCnt8 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.popCnt16#"+    , "type"      : "popCnt16 :: Word# -> Word#"+    , "templateD" :+"-- popCnt16 begin+popCnt16_~SYM[0] : block+  -- given a level and a depth, calculate the corresponding index into the+  -- intermediate array+  function depth2Index (levels,depth : in natural) return natural is+  begin+    return (2 ** levels - 2 ** depth);+  end function;++  constant width : natural := 16;+  constant levels : natural := natural (ceil (log2 (real (width))));+  type popCnt_res_vec is array (natural range <>) of unsigned(levels downto 0);+  signal intermediate_~SYM[1] : popCnt_res_vec(0 to (2*width)-2);+begin+  -- put input into the first half of the intermediate array+  make_array: for i in 0 to (width - 1) generate+    intermediate_~SYM[1](i) <= resize(~ARG[0](i downto i),levels+1);+  end generate;++  -- Create the tree of adders+  make_tree : if levels /= 0 generate+    tree_depth : for d in levels-1 downto 0 generate+      tree_depth_loop: for i in 0 to (natural(2**d) - 1) generate+        intermediate_~SYM[1](depth2Index(levels+1,d+1)+i) <=+          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)) ++          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)+1);+      end generate;+    end generate;+  end generate;++  -- The last element of the intermediate array holds the result+  ~RESULT <= resize(intermediate_~SYM[1]((2*width)-2),~SIZE[~TYPO]);+end block;+-- popCnt16 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.popCnt32#"+    , "type"      : "popCnt16 :: Word# -> Word#"+    , "templateD" :+"-- popCnt32 begin+popCnt32_~SYM[0] : block+  -- given a level and a depth, calculate the corresponding index into the+  -- intermediate array+  function depth2Index (levels,depth : in natural) return natural is+  begin+    return (2 ** levels - 2 ** depth);+  end function;++  constant width : natural := 32;+  constant levels : natural := natural (ceil (log2 (real (width))));+  type popCnt_res_vec is array (natural range <>) of unsigned(levels downto 0);+  signal intermediate_~SYM[1] : popCnt_res_vec(0 to (2*width)-2);+begin+  -- put input into the first half of the intermediate array+  make_array: for i in 0 to (width - 1) generate+    intermediate_~SYM[1](i) <= resize(~ARG[0](i downto i),levels+1);+  end generate;++  -- Create the tree of adders+  make_tree : if levels /= 0 generate+    tree_depth : for d in levels-1 downto 0 generate+      tree_depth_loop: for i in 0 to (natural(2**d) - 1) generate+        intermediate_~SYM[1](depth2Index(levels+1,d+1)+i) <=+          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)) ++          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)+1);+      end generate;+    end generate;+  end generate;++  -- The last element of the intermediate array holds the result+  ~RESULT <= resize(intermediate_~SYM[1]((2*width)-2),~SIZE[~TYPO]);+end block;+-- popCnt32 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.popCnt64#"+    , "type"      : "popCnt16 :: Word# -> Word#"+    , "templateD" :+"-- popCnt64 begin+popCnt64_~SYM[0] : block+  -- given a level and a depth, calculate the corresponding index into the+  -- intermediate array+  function depth2Index (levels,depth : in natural) return natural is+  begin+    return (2 ** levels - 2 ** depth);+  end function;++  constant width : natural := 64;+  constant levels : natural := natural (ceil (log2 (real (width))));+  type popCnt_res_vec is array (natural range <>) of unsigned(levels downto 0);+  signal intermediate_~SYM[1] : popCnt_res_vec(0 to (2*width)-2);+begin+  -- put input into the first half of the intermediate array+  make_array: for i in 0 to (width - 1) generate+    intermediate_~SYM[1](i) <= resize(~ARG[0](i downto i),levels+1);+  end generate;++  -- Create the tree of adders+  make_tree : if levels /= 0 generate+    tree_depth : for d in levels-1 downto 0 generate+      tree_depth_loop: for i in 0 to (natural(2**d) - 1) generate+        intermediate_~SYM[1](depth2Index(levels+1,d+1)+i) <=+          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)) ++          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)+1);+      end generate;+    end generate;+  end generate;++  -- The last element of the intermediate array holds the result+  ~RESULT <= resize(intermediate_~SYM[1]((2*width)-2),~SIZE[~TYPO]);+end block;+-- popCnt64 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.popCnt#"+    , "type"      : "popCnt :: Word# -> Word#"+    , "templateD" :+"-- popCnt begin+popCnt_~SYM[0] : block+  -- given a level and a depth, calculate the corresponding index into the+  -- intermediate array+  function depth2Index (levels,depth : in natural) return natural is+  begin+    return (2 ** levels - 2 ** depth);+  end function;++  constant width : natural := ~SIZE[~TYPO];+  constant levels : natural := natural (ceil (log2 (real (width))));+  type popCnt_res_vec is array (natural range <>) of unsigned(levels downto 0);+  signal intermediate_~SYM[1] : popCnt_res_vec(0 to (2*width)-2);+begin+  -- put input into the first half of the intermediate array+  make_array: for i in 0 to (width - 1) generate+    intermediate_~SYM[1](i) <= resize(~ARG[0](i downto i),levels+1);+  end generate;++  -- Create the tree of adders+  make_tree : if levels /= 0 generate+    tree_depth : for d in levels-1 downto 0 generate+      tree_depth_loop: for i in 0 to (natural(2**d) - 1) generate+        intermediate_~SYM[1](depth2Index(levels+1,d+1)+i) <=+          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)) ++          intermediate_~SYM[1](depth2Index(levels+1,d+2)+(2*i)+1);+      end generate;+    end generate;+  end generate;++  -- The last element of the intermediate array holds the result+  ~RESULT <= resize(intermediate_~SYM[1]((2*width)-2),~SIZE[~TYPO]);+end block;+-- popCnt end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.clz8#"+    , "type"      : "clz8 :: Word# -> Word#"+    , "templateD" :+"-- clz8 begin+clz8~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz8 (constant v : unsigned(0 to 7)) return unsigned is+    variable e : unsigned(0 to 7);     -- 8+    variable a : unsigned(0 to 2*3-1); -- 6+  begin+    for i in 0 to 3 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 1 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    return clzi(3,a(0 to 5));+  end function;+begin+  ~RESULT <= resize(clz8(~ARG[0](7 downto 0)),~SIZE[~TYPO]);+end block;+-- clz8 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.clz16#"+    , "type"      : "clz16 :: Word# -> Word#"+    , "templateD" :+"-- clz16 begin+clz16~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz16 (constant v : unsigned(0 to 15)) return unsigned is+    variable e : unsigned(0 to 15);    -- 16+    variable a : unsigned(0 to 4*3-1); -- 12+    variable b : unsigned(0 to 2*4-1); -- 8+  begin+    for i in 0 to 7 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 3 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    for i in 0 to 1 loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5)); end loop;+    return clzi(4,b(0 to 7));+  end function;+begin+  ~RESULT <= resize(clz16(~ARG[0](15 downto 0)),~SIZE[~TYPO]);+end block;+-- clz16 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.clz32#"+    , "type"      : "clz32 :: Word# -> Word#"+    , "templateD" :+"-- clz32 begin+clz32~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz32 (constant v : unsigned(0 to 31)) return unsigned is+    variable e : unsigned(0 to 31);    -- 32+    variable a : unsigned(0 to 8*3-1); -- 24+    variable b : unsigned(0 to 4*4-1); -- 16+    variable c : unsigned(0 to 2*5-1); -- 10+  begin+    for i in 0 to 15 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 7  loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    for i in 0 to 3  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5)); end loop;+    for i in 0 to 1  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7)); end loop;+    return clzi(5,c(0 to 9));+  end function;+begin+  ~RESULT <= resize(clz32(~ARG[0](31 downto 0)),~SIZE[~TYPO]);+end block;+-- clz32 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.clz64#"+    , "type"      : "clz64 :: Word# -> Word#"+    , "templateD" :+"-- clz64 begin+clz64~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz64 (constant v : unsigned(0 to 63)) return unsigned is+    variable e : unsigned(0 to 63);     -- 64+    variable a : unsigned(0 to 16*3-1); -- 48+    variable b : unsigned(0 to 8*4-1);  -- 32+    variable c : unsigned(0 to 4*5-1);  -- 20+    variable d : unsigned(0 to 2*6-1);  -- 12+  begin+    for i in 0 to 31 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));      end loop;+    for i in 0 to 15 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3));   end loop;+    for i in 0 to 7  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5));   end loop;+    for i in 0 to 3  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7));   end loop;+    for i in 0 to 1  loop d(i*6 to i*6+5):=clzi(5,c(i*10 to i*10+9)); end loop;+    return clzi(6,d(0 to 11));+  end function;+begin+  ~RESULT <= resize(clz64(~ARG[0]),~SIZE[~TYPO]);+end block;+-- clz64 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.clz#"+    , "type"      : "clz :: Word# -> Word#"+    , "templateD" :+"-- clz begin+clz~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;+~IF ~IW64 ~THEN+  function clz64 (constant v : unsigned(0 to 63)) return unsigned is+    variable e : unsigned(0 to 63);     -- 64+    variable a : unsigned(0 to 16*3-1); -- 48+    variable b : unsigned(0 to 8*4-1);  -- 32+    variable c : unsigned(0 to 4*5-1);  -- 20+    variable d : unsigned(0 to 2*6-1);  -- 12+  begin+    for i in 0 to 31 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));      end loop;+    for i in 0 to 15 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3));   end loop;+    for i in 0 to 7  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5));   end loop;+    for i in 0 to 3  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7));   end loop;+    for i in 0 to 1  loop d(i*6 to i*6+5):=clzi(5,c(i*10 to i*10+9)); end loop;+    return clzi(6,d(0 to 11));+  end function;+~ELSE+  function clz32 (constant v : unsigned(0 to 31)) return unsigned is+    variable e : unsigned(0 to 31);    -- 32+    variable a : unsigned(0 to 8*3-1); -- 24+    variable b : unsigned(0 to 4*4-1); -- 16+    variable c : unsigned(0 to 2*5-1); -- 10+  begin+    for i in 0 to 15 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 7  loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    for i in 0 to 3  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5)); end loop;+    for i in 0 to 1  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7)); end loop;+    return clzi(5,c(0 to 9));+  end function;+~FI+begin+~IF ~IW64 ~THEN+  ~RESULT <= resize(clz64(~ARG[0]),~SIZE[~TYPO]);+~ELSE+  ~RESULT <= resize(clz32(~ARG[0]),~SIZE[~TYPO]);+~FI+end block;+-- clz end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ctz8#"+    , "type"      : "ctz8 :: Word# -> Word#"+    , "templateD" :+"-- ctz8 begin+ctz8~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz8 (constant v : unsigned(0 to 7)) return unsigned is+    variable e : unsigned(0 to 7);     -- 8+    variable a : unsigned(0 to 2*3-1); -- 6+  begin+    for i in 0 to 3 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 1 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    return clzi(3,a(0 to 5));+  end function;++  signal ~SYM[1] : ~TYP[0];+  signal ~SYM[2] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  reverse_loop : for ~SYM[3] in ~SYM[1]'range generate+    ~SYM[2](~SYM[1]'high - ~SYM[3]) <= ~SYM[1](~SYM[3]);+  end generate;+~IF ~IW64 ~THEN+  ~RESULT <= resize(clz8(~SYM[2](63 downto 56)),~SIZE[~TYPO]);+~ELSE+  ~RESULT <= resize(clz8(~SYM[2](31 downto 24)),~SIZE[~TYPO]);+~FI+end block;+-- ctz8 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ctz16#"+    , "type"      : "ctz16 :: Word# -> Word#"+    , "templateD" :+"-- ctz16 begin+ctz16~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz16 (constant v : unsigned(0 to 15)) return unsigned is+    variable e : unsigned(0 to 15);    -- 16+    variable a : unsigned(0 to 4*3-1); -- 12+    variable b : unsigned(0 to 2*4-1); -- 8+  begin+    for i in 0 to 7 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 3 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    for i in 0 to 1 loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5)); end loop;+    return clzi(4,b(0 to 7));+  end function;++  signal ~SYM[1] : ~TYP[0];+  signal ~SYM[2] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  reverse_loop : for ~SYM[3] in ~SYM[1]'range generate+    ~SYM[2](~SYM[1]'high - ~SYM[3]) <= ~SYM[1](~SYM[3]);+  end generate;+~IF ~IW64 ~THEN+  ~RESULT <= resize(clz16(~SYM[2](63 downto 48)),~SIZE[~TYPO]);+~ELSE+  ~RESULT <= resize(clz16(~SYM[2](31 downto 16)),~SIZE[~TYPO]);+~FI+end block;+-- ctz16 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ctz32#"+    , "type"      : "ctz32 :: Word# -> Word#"+    , "templateD" :+"-- ctz32 begin+ctz32~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz32 (constant v : unsigned(0 to 31)) return unsigned is+    variable e : unsigned(0 to 31);    -- 32+    variable a : unsigned(0 to 8*3-1); -- 24+    variable b : unsigned(0 to 4*4-1); -- 16+    variable c : unsigned(0 to 2*5-1); -- 10+  begin+    for i in 0 to 15 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 7  loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    for i in 0 to 3  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5)); end loop;+    for i in 0 to 1  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7)); end loop;+    return clzi(5,c(0 to 9));+  end function;++  signal ~SYM[1] : ~TYP[0];+  signal ~SYM[2] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  reverse_loop : for ~SYM[3] in ~SYM[1]'range generate+    ~SYM[2](~SYM[1]'high - ~SYM[3]) <= ~SYM[1](~SYM[3]);+  end generate;+~IF ~IW64 ~THEN+  ~RESULT <= resize(clz32(~SYM[2](63 downto 32)),~SIZE[~TYPO]);+~ELSE+  ~RESULT <= resize(clz32(~SYM[2]),~SIZE[~TYPO]);+~FI+end block;+-- ctz32 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ctz64#"+    , "type"      : "ctz64 :: Word# -> Word#"+    , "templateD" :+"-- ctz64 begin+ctz64~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++  function clz64 (constant v : unsigned(0 to 63)) return unsigned is+    variable e : unsigned(0 to 63);     -- 64+    variable a : unsigned(0 to 16*3-1); -- 48+    variable b : unsigned(0 to 8*4-1);  -- 32+    variable c : unsigned(0 to 4*5-1);  -- 20+    variable d : unsigned(0 to 2*6-1);  -- 12+  begin+    for i in 0 to 31 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));      end loop;+    for i in 0 to 15 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3));   end loop;+    for i in 0 to 7  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5));   end loop;+    for i in 0 to 3  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7));   end loop;+    for i in 0 to 1  loop d(i*6 to i*6+5):=clzi(5,c(i*10 to i*10+9)); end loop;+    return clzi(6,d(0 to 11));+  end function;++  signal ~SYM[1] : ~TYP[0];+  signal ~SYM[2] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  reverse_loop : for ~SYM[3] in ~SYM[1]'range generate+    ~SYM[2](~SYM[1]'high - ~SYM[3]) <= ~SYM[1](~SYM[3]);+  end generate;++  ~RESULT <= resize(clz64(~SYM[2]),~SIZE[~TYPO]);+end block;+-- ctz64 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.ctz#"+    , "type"      : "ctz :: Word# -> Word#"+    , "templateD" :+"-- ctz begin+ctz~SYM[0] : block+  function enc(constant a : unsigned(1 downto 0)) return unsigned is+  begin+    case a is+      when \"00\" => return \"10\";+      when \"01\" => return \"01\";+      when \"10\" => return \"00\";+      when others => return \"00\";+    end case;+  end function;++  function clzi(+    constant n : in natural;+    constant i : in unsigned) return unsigned is+    variable v : unsigned(i'length-1 downto 0):=i;+  begin+    if v(n-1+n)='0' then+      return (v(n-1+n) and v(n-1)) & '0' & v(2*n-2 downto n);+    else+      return (v(n-1+n) and v(n-1)) & not v(n-1) & v(n-2 downto 0);+    end if;+  end function;++~IF ~IW64 ~THEN+  function clz64 (constant v : unsigned(0 to 63)) return unsigned is+    variable e : unsigned(0 to 63);     -- 64+    variable a : unsigned(0 to 16*3-1); -- 48+    variable b : unsigned(0 to 8*4-1);  -- 32+    variable c : unsigned(0 to 4*5-1);  -- 20+    variable d : unsigned(0 to 2*6-1);  -- 12+  begin+    for i in 0 to 31 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));      end loop;+    for i in 0 to 15 loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3));   end loop;+    for i in 0 to 7  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5));   end loop;+    for i in 0 to 3  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7));   end loop;+    for i in 0 to 1  loop d(i*6 to i*6+5):=clzi(5,c(i*10 to i*10+9)); end loop;+    return clzi(6,d(0 to 11));+  end function;+~ELSE+  function clz32 (constant v : unsigned(0 to 31)) return unsigned is+    variable e : unsigned(0 to 31);    -- 32+    variable a : unsigned(0 to 8*3-1); -- 24+    variable b : unsigned(0 to 4*4-1); -- 16+    variable c : unsigned(0 to 2*5-1); -- 10+  begin+    for i in 0 to 15 loop e(i*2 to i*2+1):=enc(v(i*2 to i*2+1));    end loop;+    for i in 0 to 7  loop a(i*3 to i*3+2):=clzi(2,e(i*4 to i*4+3)); end loop;+    for i in 0 to 3  loop b(i*4 to i*4+3):=clzi(3,a(i*6 to i*6+5)); end loop;+    for i in 0 to 1  loop c(i*5 to i*5+4):=clzi(4,b(i*8 to i*8+7)); end loop;+    return clzi(5,c(0 to 9));+  end function;+~FI++  signal ~SYM[1] : ~TYP[0];+  signal ~SYM[2] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  reverse_loop : for ~SYM[3] in ~SYM[1]'range generate+    ~SYM[2](~SYM[1]'high - ~SYM[3]) <= ~SYM[1](~SYM[3]);+  end generate;+~IF ~IW64 ~THEN+  ~RESULT <= resize(clz64(~SYM[2]),~SIZE[~TYPO]);+~ELSE+  ~RESULT <= resize(clz32(~SYM[2]),~SIZE[~TYPO]);+~FI+end block;+-- ctz end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.byteSwap16#"+    , "type"      : "byteSwap16# :: Word# -> Word#"+    , "templateD" :+"-- byteSwap16 begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+~IF ~IW64 ~THEN+  ~RESULT <= ~SYM[1](63 downto 16) & ~SYM[1](7 downto 0) & ~SYM[1](15 downto 8);+~ELSE+  ~RESULT <= ~SYM[1](31 downto 16) & ~SYM[1](7 downto 0) & ~SYM[1](15 downto 8);+~FI+end block;+-- byteSwap16 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.byteSwap32#"+    , "type"      : "byteSwap32# :: Word# -> Word#"+    , "templateD" :+"-- byteSwap32 begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+~IF ~IW64 ~THEN+  ~RESULT <= ~SYM[1](63 downto 32) & ~SYM[1](7  downto 0 ) & ~SYM[1](15 downto 8)+                                   & ~SYM[1](23 downto 16) & ~SYM[1](31 downto 24);+~ELSE+  ~RESULT <= ~SYM[1](7  downto 0 ) & ~SYM[1](15 downto 8)+           & ~SYM[1](23 downto 16) & ~SYM[1](31 downto 24);+~FI+end block;+-- byteSwap32 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.byteSwap64#"+    , "type"      : "byteSwap64# :: Word# -> Word#"+    , "templateD" :+"-- byteSwap64 begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= ~SYM[1](7  downto 0 ) & ~SYM[1](15 downto 8)+           & ~SYM[1](23 downto 16) & ~SYM[1](31 downto 24)+           & ~SYM[1](39 downto 32) & ~SYM[1](47 downto 40)+           & ~SYM[1](55 downto 48) & ~SYM[1](63 downto 56);+end block;+-- byteSwap64 end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.byteSwap#"+    , "type"      : "byteSwap# :: Word# -> Word#"+    , "templateD" :+"-- byteSwap begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+~IF ~IW64 ~THEN+  ~RESULT <= ~SYM[1](7  downto 0 ) & ~SYM[1](15 downto 8)+           & ~SYM[1](23 downto 16) & ~SYM[1](31 downto 24)+           & ~SYM[1](39 downto 32) & ~SYM[1](47 downto 40)+           & ~SYM[1](55 downto 48) & ~SYM[1](63 downto 56);+~ELSE+  ~RESULT <= ~SYM[1](7  downto 0 ) & ~SYM[1](15 downto 8)+           & ~SYM[1](23 downto 16) & ~SYM[1](31 downto 24);+~FI+end block;+-- byteSwap end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.narrow8Int#"+    , "type"      : "narrow8Int# :: Int# -> Int#"+    , "templateD" :+"-- narrow8Int begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= resize(~SYM[1](7 downto 0),~SIZE[~TYPO]);+end block;+-- narrow8Int end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.narrow16Int#"+    , "type"      : "narrow16Int# :: Int# -> Int#"+    , "templateD" :+"-- narrow16Int begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= resize(~SYM[1](15 downto 0),~SIZE[~TYPO]);+end block;+-- narrow16Int end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.narrow32Int#"+    , "type"      : "narrow32Int# :: Int# -> Int#"+    , "templateD" :+"-- narrow32Int begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= resize(~SYM[1](31 downto 0),~SIZE[~TYPO]);+end block;+-- narrow32Int end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.narrow8Word#"+    , "type"      : "narrow8Word# :: Word# -> Word#"+    , "templateD" :+"-- narrow8Word begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= resize(~SYM[1](7 downto 0),~SIZE[~TYPO]);+end block;+-- narrow8Word end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.narrow16Word#"+    , "type"      : "narrow16Word# :: Word# -> Word#"+    , "templateD" :+"-- narrow16Word begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= resize(~SYM[1](15 downto 0),~SIZE[~TYPO]);+end block;+-- narrow16Word end"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.narrow32Word#"+    , "type"      : "narrow32Word# :: Word# -> Word#"+    , "templateD" :+"-- narrow32Word begin+msb_~SYM[0] : block+  signal ~SYM[1] : ~TYP[0];+begin+  ~SYM[1] <= ~ARG[0];+  ~RESULT <= resize(~SYM[1](31 downto 0),~SIZE[~TYPO]);+end block;+-- narrow32Word end"+    }+  }+, { "Primitive" :+    { "name"     : "GHC.Prim.dataToTag#"+    , "primType" : "Function"+    }+  }+, { "Primitive" :+    { "name"     : "GHC.Prim.tagToEnum#"+    , "primType" : "Function"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Prim.unsafeCoerce#"+    , "type"      : "unsafeCoerce# :: a -> b"+    , "templateE" : "~ARG[0]"     }   } ]
primitives/GHC.Typelits.json view
@@ -1,7 +1,7 @@ [ { "BlackBox" :     { "name"      : "GHC.TypeLits.natVal"     , "type"      : "natVal :: forall n proxy. KnownNat n => proxy n -> Integer"-    , "templateE" : "~LIT[0]"+    , "templateE" : "~ARG[0]"     }   } ]
primitives/GHC.Types.json view
@@ -8,4 +8,22 @@     , "primType"  : "Constructor"     }   }+, { "BlackBox" :+    { "name"      : "GHC.Types.C#"+    , "type"      : "C# :: Char# -> Char"+    , "templateE" : "~ARG[0]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Types.I#"+    , "type"      : "I# :: Int# -> Int"+    , "templateE" : "~ARG[0]"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Types.W#"+    , "type"      : "W# :: Word# -> Word"+    , "templateE" : "~ARG[0]"+    }+  } ]
+ primitives/GHC.Word.json view
@@ -0,0 +1,25 @@+[ { "BlackBox" :+    { "name"      : "GHC.Word.W8#"+    , "type"      : "W8# :: Word# -> Word8"+    , "templateE" : "resize(~ARG[0],8)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Word.W16#"+    , "type"      : "W16# :: Word# -> Word16"+    , "templateE" : "resize(~ARG[0],16)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Word.W32#"+    , "type"      : "W32# :: Word# -> Word32"+    , "templateE" : "resize(~ARG[0],32)"+    }+  }+, { "BlackBox" :+    { "name"      : "GHC.Word.W64#"+    , "type"      : "W64# :: Word# -> Word64"+    , "templateE" : "resize(~ARG[0],64)"+    }+  }+]
src/CLaSH/Backend/VHDL.hs view
@@ -26,7 +26,7 @@  import           CLaSH.Backend import           CLaSH.Netlist.BlackBox.Util          (extractLiterals, renderBlackBox)-import           CLaSH.Netlist.Types+import           CLaSH.Netlist.Types                  hiding (_intWidth, intWidth) import           CLaSH.Netlist.Util import           CLaSH.Util                           (clog2, curLoc, first, makeCached, on, (<:>)) @@ -42,6 +42,7 @@   { _tyCache   :: (HashSet HWType)     -- ^ Previously encountered HWTypes   , _tyCount   :: Int                  -- ^ Product type counter   , _nameCache :: (HashMap HWType Doc) -- ^ Cache for previously generated product type names+  , _intWidth  :: Int                  -- ^ Int/Word/Integer bit-width   }  makeLenses ''VHDLState@@ -66,6 +67,7 @@   genStmt         = const empty   inst            = inst_   expr            = expr_+  iwWidth         = use intWidth  type VHDLM a = State VHDLState a @@ -109,7 +111,7 @@               "end" <> semi      eqReprTy :: HWType -> HWType -> Bool-    eqReprTy (Vector n ty1) (Vector m ty2) = n == m && eqReprTy ty1 ty2+    eqReprTy (Vector n ty1) (Vector m ty2)  = n == m && eqReprTy ty1 ty2     eqReprTy ty1 ty2       | isUnsigned ty1 && isUnsigned ty2 ||         isSLV ty1 && isSLV ty2              = typeSize ty1 == typeSize ty2@@ -201,19 +203,6 @@     "end" <> semi   ) -funDec Integer = Just-  ( "function" <+> "to_integer" <+> parens ("i" <+> colon <+> "in" <+> "integer") <+> "return" <+> "integer" <> semi <$>-    "function" <+> "toSLV" <+> parens ("i" <+> colon <+> "in" <+> "integer") <+> "return" <+> "std_logic_vector" <> semi-  , "function" <+> "to_integer" <+> parens ("i" <+> colon <+> "in" <+> "integer") <+> "return" <+> "integer" <+> "is" <$>-    "begin" <$>-      indent 2 ("return" <+> "i" <> semi) <$>-    "end" <> semi <$>-    "function" <+> "toSLV" <+> parens ("i" <+> colon <+> "in" <+> "integer") <+> "return" <+> "std_logic_vector" <+> "is" <$>-    "begin" <$>-      indent 2 ("return" <+> "std_logic_vector" <> parens ("to_signed" <> parens ("i" <> comma <> int 32)) <> semi) <$>-    "end" <> semi-  )- funDec (Index _) = Just unsignedToSlvDec  funDec (Signed _) = Just@@ -337,7 +326,6 @@ vhdlType' Bool            = "boolean" vhdlType' (Clock _ _)     = "std_logic" vhdlType' (Reset _ _)     = "std_logic"-vhdlType' Integer         = "integer" vhdlType' (BitVector n)   = case n of                               0 -> "std_logic_vector (0 downto 1)"                               _ -> "std_logic_vector" <> parens (int (n-1) <+> "downto 0")@@ -367,7 +355,6 @@     vhdlTypeMark' Bool            = "boolean"     vhdlTypeMark' (Clock _ _)     = "std_logic"     vhdlTypeMark' (Reset _ _)     = "std_logic"-    vhdlTypeMark' Integer         = "integer"     vhdlTypeMark' (BitVector _)   = "std_logic_vector"     vhdlTypeMark' (Index _)       = "unsigned"     vhdlTypeMark' (Signed _)      = "signed"@@ -379,7 +366,6 @@     vhdlTypeMark' t               = error $ $(curLoc) ++ "vhdlTypeMark: " ++ show t  tyName :: HWType -> VHDLM Doc-tyName Integer           = "integer" tyName Bool              = "boolean" tyName (Clock _ _)       = "std_logic" tyName (Reset _ _)       = "std_logic"@@ -399,7 +385,6 @@ -- | Convert a Netlist HWType to an error VHDL value for that type vhdlTypeErrValue :: HWType -> VHDLM Doc vhdlTypeErrValue Bool                = "true"-vhdlTypeErrValue Integer             = "integer'high" vhdlTypeErrValue (BitVector _)       = "(others => 'X')" vhdlTypeErrValue (Index _)           = "(others => 'X')" vhdlTypeErrValue (Signed _)          = "(others => 'X')"@@ -501,6 +486,13 @@     start = typeSize ty - 1     end   = typeSize ty - conSize ty +expr_ _ (Identifier id_ (Just (Indexed ((Signed _ ),_,_))))  = do+  iw <- use intWidth+  "resize" <> parens (text id_ <> "," <> int iw)+expr_ _ (Identifier id_ (Just (Indexed ((Unsigned _),_,_)))) = do+  iw <- use intWidth+  "resize" <> parens (text id_ <> "," <> int iw)+ expr_ _ (Identifier id_ (Just _)) = text id_  expr_ _ (DataCon (Vector 0 _) _ _) =@@ -529,41 +521,66 @@ expr_ _ (BlackBoxE pNm _ bbCtx _)   | pNm == "CLaSH.Sized.Internal.Signed.fromInteger#"   , [Literal _ (NumLit n), Literal _ i] <- extractLiterals bbCtx-  , n > 32   = exprLit (Just (Signed (fromInteger n),fromInteger n)) i  expr_ _ (BlackBoxE pNm _ bbCtx _)   | pNm == "CLaSH.Sized.Internal.Unsigned.fromInteger#"   , [Literal _ (NumLit n), Literal _ i] <- extractLiterals bbCtx-  , n > 32   = exprLit (Just (Unsigned (fromInteger n),fromInteger n)) i  expr_ _ (BlackBoxE pNm _ bbCtx _)   | pNm == "CLaSH.Sized.Internal.BitVector.fromInteger#"   , [Literal _ (NumLit n), Literal _ i] <- extractLiterals bbCtx-  , n > 32   = exprLit (Just (BitVector (fromInteger n),fromInteger n)) i +expr_ _ (BlackBoxE pNm _ bbCtx _)+  | pNm == "GHC.Types.I#"+  , [Literal _ (NumLit n)] <- extractLiterals bbCtx+  = do iw <- use intWidth+       exprLit (Just (Signed iw,iw)) (NumLit n)++expr_ _ (BlackBoxE pNm _ bbCtx _)+  | pNm == "GHC.Types.W#"+  , [Literal _ (NumLit n)] <- extractLiterals bbCtx+  = do iw <- use intWidth+       exprLit (Just (Unsigned iw,iw)) (NumLit n)+ expr_ b (BlackBoxE _ bs bbCtx b') = do   t <- renderBlackBox bs bbCtx   parenIf (b || b') $ string t -expr_ _ (DataTag Bool (Left id_))          = "false when" <+> text id_ <+> "= 0 else true"-expr_ _ (DataTag Bool (Right id_))         = "1 when" <+> text id_ <+> "else 0"-expr_ _ (DataTag hty@(Sum _ _) (Left id_)) = "to_unsigned" <> tupled (sequence [text id_,int (typeSize hty)])-expr_ _ (DataTag (Sum _ _) (Right id_))    = "to_integer" <> parens (text id_)+expr_ _ (DataTag Bool (Left id_)) = "false when" <+> text id_ <+> "= 0 else true"+expr_ _ (DataTag Bool (Right id_)) = do {+  ; iw <- use intWidth+  ; "to_signed" <> parens (int 1 <> "," <> int iw) <+> "when" <+> text id_ <+> "else" <+>+    "to_signed" <> parens (int 0 <> "," <> int iw)+  } -expr_ _ (DataTag (Product _ _) (Right _))  = int 0-expr_ _ (DataTag hty@(SP _ _) (Right id_)) = "to_integer" <> parens-                                               ("unsigned" <> parens-                                               (text id_ <> parens-                                               (int start <+> "downto" <+> int end)))+expr_ _ (DataTag hty@(Sum _ _) (Left id_)) =+  "resize" <> parens ("unsigned" <> parens ("std_logic_vector" <> parens (text id_)) <> "," <> int (typeSize hty))+expr_ _ (DataTag (Sum _ _) (Right id_)) = do+  iw <- use intWidth+  "signed" <> parens ("std_logic_vector" <> parens ("resize" <> parens (text id_ <> "," <> int iw)))++expr_ _ (DataTag (Product _ _) (Right _))  = do+  iw <- use intWidth+  "to_signed" <> parens (int 0 <> "," <> int iw)+expr_ _ (DataTag hty@(SP _ _) (Right id_)) = do {+    ; iw <- use intWidth+    ; "signed" <> parens ("std_logic_vector" <> parens (+      "resize" <> parens ("unsigned" <> parens (text id_ <> parens (int start <+> "downto" <+> int end))+                          <> "," <> int iw)))+    }   where     start = typeSize hty - 1     end   = typeSize hty - conSize hty -expr_ _ (DataTag (Vector 0 _) (Right _)) = int 0-expr_ _ (DataTag (Vector _ _) (Right _)) = int 1+expr_ _ (DataTag (Vector 0 _) (Right _)) = do+  iw <- use intWidth+  "to_signed" <> parens (int 0 <> "," <> int iw)+expr_ _ (DataTag (Vector _ _) (Right _)) = do+  iw <- use intWidth+  "to_signed" <> parens (int 1 <> "," <> int iw)  expr_ _ e = error $ $(curLoc) ++ (show e) -- empty @@ -582,18 +599,13 @@ exprLit Nothing (NumLit i) = integer i  exprLit (Just (hty,sz)) (NumLit i) = case hty of-  Unsigned _  -> "unsigned'" <> parens blit-  Signed   _  -> "signed'" <> parens blit+  Unsigned n+    | i < 2^(31 :: Integer) -> "to_unsigned" <> parens (integer i <> "," <> int n)+    | otherwise -> "unsigned'" <> parens blit+  Signed n+    | i < 2^(31 :: Integer) && i > (-2^(31 :: Integer)) -> "to_signed" <> parens (integer i <> "," <> int n)+    | otherwise -> "signed'" <> parens blit   BitVector _ -> "std_logic_vector'" <> parens blit-  Integer ->-    let integerLow  = -2^(31 :: Integer) :: Integer-        integerHigh = 2^(31 :: Integer) - 1 :: Integer-        i' = if i < integerLow-                then integerLow-                else if i > integerHigh-                     then integerHigh-                     else i-    in  parenIf (i' < 0) (integer i')   _           -> blit    where@@ -604,15 +616,6 @@ exprLit _             l             = error $ $(curLoc) ++ "exprLit: " ++ show l  patLit :: HWType -> Literal -> VHDLM Doc-patLit Integer (NumLit i) =-  let integerLow  = -2^(31 :: Integer) :: Integer-      integerHigh = 2^(31 :: Integer) - 1 :: Integer-      i' = if i < integerLow-              then integerLow-              else if i > integerHigh-                   then integerHigh-                   else i-  in  parenIf (i' < 0) (integer i') patLit hwTy (NumLit i) = bits (toBits (conSize hwTy) i) patLit _    l          = exprLit Nothing l @@ -638,7 +641,6 @@  toSLV :: HWType -> Expr -> VHDLM Doc toSLV Bool         e = "toSLV" <> parens (expr_ False e)-toSLV Integer      e = "std_logic_vector" <> parens ("to_signed" <> tupled (sequence [expr_ False e,int 32])) toSLV (BitVector _) e = expr_ False e toSLV (Signed _)   e = "std_logic_vector" <> parens (expr_ False e) toSLV (Unsigned _) e = "std_logic_vector" <> parens (expr_ False e)@@ -664,7 +666,6 @@  fromSLV :: HWType -> Identifier -> Int -> Int -> VHDLM Doc fromSLV Bool              id_ start _   = "fromSLV" <> parens (text id_ <> parens (int start <+> "downto" <+> int start))-fromSLV Integer           id_ start end = "to_integer" <> parens (fromSLV (Signed 32) id_ start end) fromSLV (BitVector _)     id_ start end = text id_ <> parens (int start <+> "downto" <+> int end) fromSLV (Index _)         id_ start end = "unsigned" <> parens (text id_ <> parens (int start <+> "downto" <+> int end)) fromSLV (Signed _)        id_ start end = "signed" <> parens (text id_ <> parens (int start <+> "downto" <+> int end))