[ { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.BV" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "BV :: Integer -> Integer -> BitVector n" , "comment" : "THIS IS ONLY USED WHEN WW EXPOSES BITVECTOR INTERNALS" , "template" : "std_logic_vector(resize(unsigned(std_logic_vector(~ARG[1])),~SIZE[~TYPO]))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.Bit" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "Bit :: Integer -> Integer -> BitVector n" , "comment" : "THIS IS ONLY USED WHEN WW EXPOSES BIT INTERNALS" , "template" : "~VAR[i][1][0]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.size#" , "workInfo" : "Constant" , "kind" : "Expression" , "type" : "size# :: KnownNat n => BitVector n -> Int" , "template" : "to_signed(~SIZE[~TYP[1]],~SIZE[~TYPO])" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.maxIndex#" , "workInfo" : "Constant" , "kind" : "Expression" , "type" : "maxIndex# :: KnownNat n => BitVector n -> Int" , "template" : "to_signed(~SIZE[~TYP[1]] - 1,~SIZE[~TYPO])" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.high" , "workInfo" : "Constant" , "kind" : "Expression" , "type" : "high :: Bit" , "template" : "'1'" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.low" , "workInfo" : "Constant" , "kind" : "Expression" , "type" : "low :: Bit" , "template" : "'0'" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.pack#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "pack# :: Bit -> BitVector 1" , "template" : "std_logic_vector'(0 => ~ARG[0])" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.unpack#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "unpack# :: BitVector 1 -> Bit" , "template" : "~VAR[bv][0](0)" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.eq##" , "kind" : "Expression" , "type" : "eq## :: Bit -> Bit -> Bool" , "template" : "~ARG[0] = ~ARG[1]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.neq##" , "kind" : "Expression" , "type" : "neq## :: Bit -> Bit -> Bool" , "template" : "~ARG[0] /= ~ARG[1]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.fromInteger##" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "fromInteger## :: Integer -> Integer -> Bit" , "template" : "~IF~LIT[0]~THEN'U'~ELSE~ARG[1](0)~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.and##" , "kind" : "Expression" , "type" : "and## :: Bit -> Bit -> Bit" , "template" : "~ARG[0] and ~ARG[1]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.or##" , "kind" : "Expression" , "type" : "or## :: Bit -> Bit -> Bit" , "template" : "~ARG[0] or ~ARG[1]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.xor##" , "kind" : "Expression" , "type" : "xor## :: Bit -> Bit -> Bit" , "template" : "~ARG[0] xor ~ARG[1]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.complement##" , "kind" : "Expression" , "type" : "complement## :: Bit -> Bit" , "template" : "not ~ARG[0]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.++#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "(++#) :: KnownNat m => BitVector n -> BitVector m -> BitVector (n + m)" , "template" : "~IF~AND[~SIZE[~TYP[1]],~SIZE[~TYP[2]]]~THENstd_logic_vector'(std_logic_vector'(~ARG[1]) & std_logic_vector'(~ARG[2]))~ELSE~IF~SIZE[~TYP[1]]~THENstd_logic_vector'(~ARG[1])~ELSEstd_logic_vector'(~ARG[2])~FI~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.reduceAnd#" , "kind" : "Declaration" , "type" : "reduceAnd# :: KnownNat n => BitVector n -> Bit" , "template" : "-- reduceAnd begin, ~IF~SIZE[~TYP[1]]~THEN ~GENSYM[reduceAnd][0] : block function and_reduce (arg : std_logic_vector) return std_logic is variable upper, lower : std_logic; variable half : integer; variable argi : std_logic_vector (arg'length - 1 downto 0); variable result : std_logic; begin if (arg'length < 1) then result := '1'; else argi := arg; if (argi'length = 1) then result := argi(argi'left); else half := (argi'length + 1) / 2; -- lsb-biased tree upper := and_reduce (argi (argi'left downto half)); lower := and_reduce (argi (half - 1 downto argi'right)); result := upper and lower; end if; end if; return result; end; begin ~RESULT <= and_reduce(~ARG[1]); end block;~ELSE ~RESULT <= '1';~FI -- reduceAnd end" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.reduceOr#" , "kind" : "Declaration" , "type" : "reduceOr# :: KnownNat n => BitVector n -> Bit" , "template" : "-- reduceOr begin ~IF~SIZE[~TYP[1]]~THEN ~GENSYM[reduceOr][0] : block function or_reduce (arg : std_logic_vector) return std_logic is variable upper, lower : std_logic; variable half : integer; variable argi : std_logic_vector (arg'length - 1 downto 0); variable result : std_logic; begin if (arg'length < 1) then result := '0'; else argi := arg; if (argi'length = 1) then result := argi(argi'left); else half := (argi'length + 1) / 2; -- lsb-biased tree upper := or_reduce (argi (argi'left downto half)); lower := or_reduce (argi (half - 1 downto argi'right)); result := upper or lower; end if; end if; return result; end; begin ~RESULT <= or_reduce(~ARG[1]); end block;~ELSE ~RESULT <= '0'; ~FI -- reduceOr end" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.reduceXor#" , "kind" : "Declaration" , "type" : "reduceXor# :: KnownNat n => BitVector n -> Bit" , "template" : "-- reduceXor begin ~IF~SIZE[~TYP[1]]~THEN ~GENSYM[reduceXor][0] : block function xor_reduce (arg : std_logic_vector) return std_logic is variable upper, lower : std_logic; variable half : integer; variable argi : std_logic_vector (arg'length - 1 downto 0); variable result : std_logic; begin if (arg'length < 1) then result := '0'; else argi := arg; if (argi'length = 1) then result := argi(argi'left); else half := (argi'length + 1) / 2; -- lsb-biased tree upper := xor_reduce (argi (argi'left downto half)); lower := xor_reduce (argi (half - 1 downto argi'right)); result := upper xor lower; end if; end if; return result; end; begin ~RESULT <= xor_reduce(~ARG[1]); end block;~ELSE ~RESULT <= '0';~FI -- reduceXor end" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.index#" , "kind" : "Declaration" , "type" : "index# :: KnownNat n -- ARG[0] => BitVector n -- ARG[1] -> Int -- ARG[2] -> Bit" , "template" : "-- indexBitVector begin ~IF~SIZE[~TYP[1]]~THEN~IF ~ISVAR[1] ~THEN ~GENSYM[indexBitVector][0] : block signal ~GENSYM[vec_index][1] : integer range 0 to ~SIZE[~TYP[1]]-1; begin ~SYM[1] <= to_integer(~ARG[2]) -- pragma translate_off mod ~SIZE[~TYP[1]] -- pragma translate_on ; ~RESULT <= ~ARG[1](~SYM[1]); end block;~ELSE ~SYM[0] : block signal ~SYM[1] : integer range 0 to ~SIZE[~TYP[1]]-1; begin ~SYM[1] <= to_integer(~ARG[2]) -- pragma translate_off mod ~SIZE[~TYP[1]] -- pragma translate_on ; ~RESULT <= ~VAR[bv][1](~SYM[1]); end block;~FI~ELSE ~RESULT <= ~ERRORO;~FI -- indexBitVector end" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.replaceBit#" , "kind" : "Declaration" , "type" : "replaceBit# :: KnownNat n -- ARG[0] => BitVector n -- ARG[1] -> Int -- ARG[2] -> Bit -- ARG[3] -> BitVector n" , "template" : "-- replaceBit begin ~IF~SIZE[~TYP[1]]~THEN ~GENSYM[replaceBit][0] : block signal ~GENSYM[vec_index][1] : integer range 0 to ~SIZE[~TYP[1]]-1; begin ~SYM[1] <= to_integer(~ARG[2]) -- pragma translate_off mod ~SIZE[~TYP[1]] -- pragma translate_on ; process(~SYM[1],~VAR[b][3]~VARS[1]) variable ~GENSYM[ivec][2] : ~TYP[1]; begin ~SYM[2] := ~ARG[1]; ~SYM[2](~SYM[1]) := ~ARG[3]; ~RESULT <= ~SYM[2]; end process; end block; ~ELSE ~RESULT <= ~ERRORO;~FI -- replaceBit end" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.setSlice#" , "workInfo" : "Never" , "kind" : "Declaration" , "type" : "setSlice# :: SNat (m + 1 + i) => BitVector (m + 1 + i) -- ARG[1] -> SNat m -- ARG[2] -> SNat n -- ARG[3] -> BitVector (m + 1 - n) -- ARG[4] -> BitVector (m + 1 + i)" , "template" : "-- setSlice begin ~GENSYM[setSlice][0] : process(~VAR[bv][1]~VARS[4]) variable ~GENSYM[ivec][1] : ~TYP[1]; begin ~SYM[1] := ~VAR[bv][1]; ~SYM[1](~LIT[2] downto ~LIT[3]) := ~ARG[4]; ~RESULT <= ~SYM[1]; end process; -- setSlice end" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.slice#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "slice# :: BitVector (m + 1 + i) -- ARG[0] -> SNat m -- ARG[1] -> SNat n -- ARG[2] -> BitVector (m + 1 - n)" , "template" : "~VAR[bv][0](~LIT[1] downto ~LIT[2])" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.split#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "split# :: KnownNat n -- ARG[0] => BitVector (m + n) -- ARG[1] -> (BitVector m, BitVector n)" , "template" : "(~VAR[bv][1](~VAR[bv][1]'high downto ~LIT[0]),~VAR[bv][1](~LIT[0]-1 downto 0))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.msb#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "msb# :: KnownNat n -- ARG[0] => BitVector n -- ARG[1] -> Bit" , "template" : "~IF ~SIZE[~TYP[1]] ~THEN ~VAR[bv][1](~VAR[bv][1]'high) ~ELSE \"0\" ~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.lsb#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "lsb# :: BitVector n -- ARG[0] -> Bit" , "template" : "~IF ~SIZE[~TYP[0]] ~THEN ~VAR[bv][0](0) ~ELSE \"0\" ~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.eq#" , "kind" : "Expression" , "type" : "eq# :: KnownNat n => BitVector n -> BitVector n -> Bool" , "template" : "~IF~SIZE[~TYP[1]]~THEN~ARG[1] = ~ARG[2]~ELSEtrue~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.neq#" , "kind" : "Expression" , "type" : "neq# :: KnownNat n => BitVector n -> BitVector n -> Bool" , "template" : "~IF~SIZE[~TYP[1]]~THEN~ARG[1] /= ~ARG[2]~ELSEfalse~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.lt#" , "kind" : "Expression" , "type" : "lt# :: KnownNat n => BitVector n -> BitVector n -> Bool" , "template" : "~IF~SIZE[~TYP[1]]~THEN~ARG[1] < ~ARG[2]~ELSEfalse~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.ge#" , "kind" : "Expression" , "type" : "ge# :: KnownNat n => BitVector n -> BitVector n -> Bool" , "template" : "~IF~SIZE[~TYP[1]]~THEN~ARG[1] >= ~ARG[2]~ELSEtrue~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.gt#" , "kind" : "Expression" , "type" : "gt# :: KnownNat n => BitVector n -> BitVector n -> Bool" , "template" : "~IF~SIZE[~TYP[1]]~THEN~ARG[1] > ~ARG[2]~ELSEfalse~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.le#" , "kind" : "Expression" , "type" : "le# :: KnownNat n => BitVector n -> BitVector n -> Bool" , "template" : "~IF~SIZE[~TYP[1]]~THEN~ARG[1] <= ~ARG[2]~ELSEtrue~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.minBound#" , "workInfo" : "Constant" , "kind" : "Expression" , "type" : "minBound# :: BitVector n" , "template" : "~IF~SIZE[~TYPO]~THENstd_logic_vector'(~SIZE[~TYPO]-1 downto 0 => '0')~ELSEstd_logic_vector'(0 downto 1 => '0')~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.maxBound#" , "workInfo" : "Constant" , "kind" : "Expression" , "type" : "maxBound# :: KnownNat n => BitVector n" , "template" : "~IF~SIZE[~TYPO]~THENstd_logic_vector'(~SIZE[~TYPO]-1 downto 0 => '1')~ELSEstd_logic_vector'(0 downto 1 => '1')~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.+#" , "kind" : "Expression" , "type" : "(+#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "std_logic_vector(unsigned(~ARG[1]) + unsigned(~ARG[2]))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.-#" , "kind" : "Expression" , "type" : "(-#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "std_logic_vector(unsigned(~ARG[1]) - unsigned(~ARG[2]))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.*#" , "kind" : "Expression" , "type" : "(*#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "std_logic_vector(resize(unsigned(~ARG[1]) * unsigned(~ARG[2]), ~SIZE[~TYP[1]]))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.negate#" , "kind" : "Expression" , "type" : "negate# :: KnownNat n => BitVector n -> BitVector n" , "template" : "std_logic_vector(-(signed(~ARG[1])))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.fromInteger#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "fromInteger# :: KnownNat n => Integer -> Integer -> BitVector n" , "template" : "std_logic_vector(resize(unsigned(std_logic_vector(~ARG[2])),~SIZE[~TYPO]))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.plus#" , "kind" : "Expression" , "type" : "plus# :: (KnownNat m, KnownNat n) => BitVector m -> BitVector n -> BitVector (Max m n + 1)" , "template" : "~IF~AND[~SIZE[~TYP[2]],~SIZE[~TYP[3]]]~THENstd_logic_vector(resize(unsigned(~ARG[2]),~SIZE[~TYPO]) + resize(unsigned(~ARG[3]),~SIZE[~TYPO]))~ELSE~IF~SIZE[~TYP[2]]~THENstd_logic_vector(resize(unsigned(~ARG[2]),~SIZE[~TYPO]))~ELSEstd_logic_vector(resize(unsigned(~ARG[3]),~SIZE[~TYPO]))~FI~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.minus#" , "kind" : "Expression" , "type" : "minus# :: (KnownNat m, KnownNat n) => BitVector m -> BitVector n -> BitVector (Max m n + 1)" , "template" : "~IF~AND[~SIZE[~TYP[2]],~SIZE[~TYP[3]]]~THENstd_logic_vector(resize(unsigned(~ARG[2]),~SIZE[~TYPO]) - resize(unsigned(~ARG[3]),~SIZE[~TYPO]))~ELSE~IF~SIZE[~TYP[2]]~THENstd_logic_vector(resize(unsigned(~ARG[2]),~SIZE[~TYPO]))~ELSEstd_logic_vector(-resize(signed(~ARG[3]),~SIZE[~TYPO]))~FI~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.times#" , "kind" : "Expression" , "type" : "times# :: (KnownNat m, KnownNat n) => BitVector m -> BitVector n -> BitVector (m + n)" , "template" : "~IF~AND[~SIZE[~TYP[2]],~SIZE[~TYP[3]]]~THENstd_logic_vector(unsigned(~ARG[2]) * unsigned(~ARG[3]))~ELSE(~SIZE[~TYPO]-1 downto 0 => '0')~FI" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.quot#" , "kind" : "Expression" , "type" : "quot# :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "std_logic_vector(unsigned(~ARG[1]) / unsigned(~ARG[2]))" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.rem#" , "kind" : "Expression" , "type" : "rem# :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "std_logic_vector(unsigned(~ARG[1]) rem unsigned(~ARG[2]))" } } , { "BlackBoxHaskell" : { "name" : "Clash.Sized.Internal.BitVector.toInteger#" , "workInfo" : "Never" , "templateFunction" : "Clash.Primitives.Sized.ToInteger.bvToIntegerVHDL" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.and#" , "kind" : "Expression" , "type" : "and# :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "~ARG[1] and ~ARG[2]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.or#" , "kind" : "Expression" , "type" : "or# :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "~ARG[1] or ~ARG[2]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.xor#" , "kind" : "Expression" , "type" : "xor# :: KnownNat n => BitVector n -> BitVector n -> BitVector n" , "template" : "~ARG[1] xor ~ARG[2]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.complement#" , "kind" : "Expression" , "type" : "complement# :: KnownNat n => BitVector n -> BitVector n" , "template" : "not ~ARG[1]" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.shiftL#" , "kind" : "Declaration" , "type" : "shiftL# :: KnownNat n => BitVector n -> Int -> BitVector n" , "template" : "~RESULT <= std_logic_vector(shift_left(unsigned(~ARG[1]), to_integer(~ARG[2]))) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X') -- pragma translate_on ;" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.shiftR#" , "kind" : "Declaration" , "type" : "shiftR# :: KnownNat n => BitVector n -> Int -> BitVector n" , "template" : "~RESULT <= std_logic_vector(shift_right(unsigned(~ARG[1]),to_integer(~ARG[2]))) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X') -- pragma translate_on ;" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.rotateL#" , "kind" : "Declaration" , "type" : "rotateL# :: KnownNat n => BitVector n -> Int -> BitVector n" , "template" : "~RESULT <= std_logic_vector(rotate_left(unsigned(~ARG[1]),to_integer(~ARG[2]))) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X') -- pragma translate_on ;" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.rotateR#" , "kind" : "Declaration" , "type" : "rotateR# :: KnownNat n => BitVector n -> Int -> BitVector n" , "template" : "~RESULT <= std_logic_vector(rotate_right(unsigned(~ARG[1]),to_integer(~ARG[2]))) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X') -- pragma translate_on ;" } } , { "BlackBox" : { "name" : "Clash.Sized.Internal.BitVector.truncateB#" , "workInfo" : "Never" , "kind" : "Expression" , "type" : "truncateB# :: forall a b . KnownNat a => BitVector (a + b) -> BitVector a" , "template" : "std_logic_vector(resize(unsigned(~ARG[1]),~SIZE[~TYPO]))" } } ]