clash-ghc-0.4: primitives/CLaSH.Sized.Internal.BitVector.json
[ { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.size#"
, "templateE" : "~LIT[0]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.maxIndex#"
, "templateE" : "~LIT[0] - 1"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.high"
, "templateE" : "\"1\""
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.low"
, "templateE" : "\"0\""
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.++#"
, "templateE" : "std_logic_vector'(~ARG[1]) & std_logic_vector'(~ARG[2])"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.reduceAnd#"
, "templateD" :
"reduceAnd_~SYM[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 <= (0 => and_reduce(~ARG[1]));
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.reduceOr#"
, "templateD" :
"reduceOr_~SYM[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 <= (0 => or_reduce(~ARG[0]));
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.reduceXor#"
, "templateD" :
"reduceXor_~SYM[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 <= (0 => xor_reduce(~ARG[0]));
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.index#"
, "comment" :
"index# :: KnownNat n -- ARG[0]
=> BitVector n -- ARG[1]
-> Int -- ARG[2]
-> Bit"
, "templateD" :
"indexBit_~SYM[0] : block
signal ~SYM[1] : ~TYP[1];
signal ~SYM[2] : ~TYP[2];
begin
~SYM[1] <= ~ARG[1];
~SYM[2] <= ~ARG[2];
-- pragma translate_off
process (~SYM[1],~SYM[2])
begin
if ~SYM[2] < ~SYM[1]'low or ~SYM[2] > ~SYM[1]'high then
assert false report (\"Index: \" & integer'image(~SYM[2]) & \", is out of bounds: \" & integer'image(~SYM[1]'low) & \" downto \" & integer'image(~SYM[1]'high)) severity warning;
~RESULT <= ~ERRORO;
else
-- pragma translate_on
~RESULT <= ~SYM[1](~SYM[2] downto ~SYM[2]);
-- pragma translate_off
end if;
end process;
-- pragma translate_on
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.replaceBit#"
, "comment" :
"replaceBit# :: KnownNat n -- ARG[0]
=> BitVector n -- ARG[1]
-> Int -- ARG[2]
-> Bit -- ARG[3]
-> BitVector n"
, "templateD" :
"replaceBit_~SYM[0] : block
signal ~SYM[1] : ~TYP[1];
signal ~SYM[2] : ~TYP[2];
signal ~SYM[3] : ~TYP[3];
begin
~SYM[1] <= ~ARG[1];
~SYM[2] <= ~ARG[2];
~SYM[3] <= ~ARG[3];
process(~SYM[1],~SYM[2],~SYM[3])
variable ~SYM[4] : ~TYP[1];
begin
~SYM[4] := ~SYM[1];
-- pragma translate_off
if ~SYM[2] < ~SYM[4]'low or ~SYM[2] > ~SYM[4]'high then
assert false report (\"Index: \" & integer'image(~SYM[2]) & \", is out of bounds: \" & integer'image(~SYM[1]'low) & \" downto \" & integer'image(~SYM[1]'high)) severity warning;
~SYM[4] := ~ERROR[1];
else
-- pragma translate_on
~SYM[4](~SYM[2] downto ~SYM[2]) := ~SYM[3];
-- pragma translate_off
end if;
-- pragma translate_on
~RESULT <= ~SYM[4];
end process;
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.setSlice#"
, "comment" :
"setSlice# :: BitVector (m + 1 + i) -- ARG[0]
-> SNat m -- ARG[1]
-> SNat n -- ARG[2]
-> BitVector (m + 1 - n) -- ARG[3]
-> BitVector (m + 1 + i)"
, "templateD" :
"setSlice_~SYM[0] : block
signal ~SYM[1] : ~TYP[0];
signal ~SYM[2] : ~TYP[3];
begin
~SYM[1] <= ~ARG[0];
~SYM[2] <= ~ARG[3];
process(~SYM[1],~SYM[2])
variable ~SYM[3] : ~TYP[0];
begin
~SYM[3] := ~SYM[1];
~SYM[3](~LIT[1] downto ~LIT[2]) := ~SYM[2];
~RESULT <= ~SYM[3];
end process;
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.slice#"
, "comment" :
"slice# :: BitVector (m + 1 + i) -- ARG[0]
-> SNat m -- ARG[1]
-> SNat n -- ARG[2]
-> BitVector (m + 1 - n)"
, "templateD" :
"slice_~SYM[0] : block
signal ~SYM[1] : ~TYP[0];
begin
~SYM[1] <= ~ARG[0];
~RESULT <= ~SYM[1](~LIT[1] downto ~LIT[2]);
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.split#"
, "comment" :
"split# :: KnownNat n -- ARG[0]
=> BitVector (m + n) -- ARG[1]
-> (BitVector m, BitVector n)"
, "templateD" :
"split_~SYM[0]: block
signal ~SYM[1] : ~TYP[1];
begin
~SYM[1] <= ~ARG[1];
~RESULT <= ( ~SYM[1](~RESULT.~TYPMO_sel0'left + ~RESULT.~TYPMO_sel1'length downto
~RESULT.~TYPMO_sel0'right + ~RESULT.~TYPMO_sel1'length)
, ~SYM[1](~RESULT.~TYPMO_sel1'left downto ~RESULT.~TYPMO_sel1'right)
);
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.msb#"
, "comment" :
"msb# :: KnownNat n -- ARG[0]
=> BitVector n -- ARG[1]
-> Bit"
, "templateD" :
"msb_~SYM[0] : block
signal ~SYM[1] : ~TYP[1];
begin
~SYM[2]_generate : if ~SYM[1]'length = 0 generate
begin
~RESULT <= \"0\";
end generate;
~SYM[3]_generate : if ~SYM[1]'length /= 0 generate
~SYM[1] <= ~ARG[1];
~RESULT <= ~SYM[1](~SYM[1]'high downto ~SYM[1]'high);
end generate;
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.lsb#"
, "comment" :
"lsb# :: BitVector n -- ARG[0]
-> Bit"
, "templateD" :
"lsb_~SYM[0] : block
signal ~SYM[1] : ~TYP[0];
begin
~SYM[2]_generate : if ~SYM[1]'length = 0 generate
begin
~RESULT <= \"0\";
end generate;
~SYM[3]_generate : if ~SYM[1]'length /= 0 generate
begin
~SYM[1] <= ~ARG[0];
~RESULT <= ~SYM[1](0 downto 0);
end generate;
end block;"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.eq#"
, "templateE" : "~ARG[0] = ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.neq#"
, "templateE" : "~ARG[0] /= ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.lt#"
, "templateE" : "~ARG[0] < ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.ge#"
, "templateE" : "~ARG[0] >= ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.gt#"
, "templateE" : "~ARG[0] > ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.le#"
, "templateE" : "~ARG[0] <= ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.minBound#"
, "comment" : "Generates incorrect VDHL for n=0"
, "templateE" : "std_logic_vector'(~LIT[0]-1 downto 0 => '0');"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.maxBound#"
, "comment" : "Generates incorrect VDHL for n=0"
, "templateE" : "std_logic_vector'(~LIT[0]-1 downto 0 => '1');"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.+#"
, "templateE" : "std_logic_vector(unsigned(~ARG[1]) + unsigned(~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.-#"
, "templateE" : "std_logic_vector(unsigned(~ARG[1]) - unsigned(~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.*#"
, "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]) * unsigned(~ARG[2]), ~LIT[0]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.negate#"
, "templateE" : "std_logic_vector(-(signed(~ARG[1])))"
}
}
, { "Primitive" :
{ "name" : "CLaSH.Sized.Internal.BitVector.fromInteger#"
, "primType" : "Function"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.plus#"
, "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]),~LIT[0]) + resize(unsigned(~ARG[2]),~LIT[0]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.minus#"
, "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]),~LIT[0]) - resize(unsigned(~ARG[2]),~LIT[0]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.times#"
, "templateE" : "std_logic_vector(unsigned(~ARG[1]) * unsigned(~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.quot#"
, "templateE" : "std_logic_vector(unsigned(~ARG[1]) / unsigned(~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.rem#"
, "templateE" : "~ARG[1] rem ~ARG[2]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.mod#"
, "templateE" : "~ARG[1] mod ~ARG[2]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.toInteger#"
, "templateE" : "to_integer(unsigned(~ARG[0]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.and#"
, "templateE" : "~ARG[0] and ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.or#"
, "templateE" : "~ARG[0] or ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.xor#"
, "templateE" : "~ARG[0] xor ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.complement#"
, "templateE" : "not ~ARG[1]"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.shiftL#"
, "templateE" : "std_logic_vector(shift_left(unsigned(~ARG[1]),~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.shiftR#"
, "templateE" : "std_logic_vector(shift_right(unsigned(~ARG[1]),~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.rotateL#"
, "templateE" : "std_logic_vector(rotate_left(unsigned(~ARG[1]),~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.rotateR#"
, "templateE" : "std_logic_vector(rotate_right(unsigned(~ARG[1]),~ARG[2]))"
}
}
, { "BlackBox" :
{ "name" : "CLaSH.Sized.Internal.BitVector.resize#"
, "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]),~LIT[0]))"
}
}
]