packages feed

clash-vhdl-0.5: primitives/CLaSH.Sized.Internal.BitVector.json

[ { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.size#"
    , "type"      : "size# :: KnownNat n => BitVector n -> Int"
    , "templateE" : "~LIT[0]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.maxIndex#"
    , "type"      : "maxIndex# :: KnownNat n => BitVector n -> Int"
    , "templateE" : "~LIT[0] - 1"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.high"
    , "type"      : "high :: Bit"
    , "templateE" : "\"1\""
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.low"
    , "type"      : "low :: Bit"
    , "templateE" : "\"0\""
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.++#"
    , "type"      : "(++#) :: KnownNat m => BitVector n -> BitVector m -> BitVector (n + m)"
    , "templateE" : "std_logic_vector'(~ARG[1]) & std_logic_vector'(~ARG[2])"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.reduceAnd#"
    , "type"      : "reduceAnd# :: KnownNat n => BitVector n -> BitVector 1"
    , "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#"
    , "type"      : "reduceOr# :: BitVector n -> BitVector 1"
    , "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#"
    , "type"      : "reduceXor# :: BitVector n -> BitVector 1"
    , "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#"
    , "type" :
"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#"
    , "type" :
"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#"
    , "type" :
"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#"
    , "type" :
"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#"
    , "type" :
"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#"
    , "type" :
"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#"
    , "type" :
"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#"
    , "type"      : "eq# :: BitVector n -> BitVector n -> Bool"
    , "templateE" : "~ARG[0] = ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.neq#"
    , "type"      : "neq# :: BitVector n -> BitVector n -> Bool"
    , "templateE" : "~ARG[0] /= ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.lt#"
    , "type"      : "lt# :: BitVector n -> BitVector n -> Bool"
    , "templateE" : "~ARG[0] < ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.ge#"
    , "type"      : "ge# :: BitVector n -> BitVector n -> Bool"
    , "templateE" : "~ARG[0] >= ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.gt#"
    , "type"      : "gt# :: BitVector n -> BitVector n -> Bool"
    , "templateE" : "~ARG[0] > ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.le#"
    , "type"      : "le# :: BitVector n -> BitVector n -> Bool"
    , "templateE" : "~ARG[0] <= ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.minBound#"
    , "type"      : "minBound# :: KnownNat n => BitVector n"
    , "comment"   : "Generates incorrect VDHL for n=0"
    , "templateE" : "std_logic_vector'(~LIT[0]-1 downto 0 => '0');"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.maxBound#"
    , "type"      : "maxBound# :: KnownNat n => BitVector n"
    , "comment"   : "Generates incorrect VDHL for n=0"
    , "templateE" : "std_logic_vector'(~LIT[0]-1 downto 0 => '1');"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.+#"
    , "type"      : "(+#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "std_logic_vector(unsigned(~ARG[1]) + unsigned(~ARG[2]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.-#"
    , "type"      : "(-#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "std_logic_vector(unsigned(~ARG[1]) - unsigned(~ARG[2]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.*#"
    , "type"      : "(*#) :: KnownNat n => BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]) * unsigned(~ARG[2]), ~LIT[0]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.negate#"
    , "type"      : "negate# :: KnownNat n => BitVector n -> BitVector n"
    , "templateE" : "std_logic_vector(-(signed(~ARG[1])))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.fromInteger#"
    , "type"      : "fromInteger# :: KnownNat n => Integer -> BitVector n"
    , "templateE" : "std_logic_vector(to_unsigned(~ARG[1],~LIT[0]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.plus#"
    , "type"      : "plus# :: KnownNat (Max m n + 1) => BitVector m -> BitVector n -> BitVector (Max m n + 1)"
    , "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]),~LIT[0]) + resize(unsigned(~ARG[2]),~LIT[0]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.minus#"
    , "type"      : "minus# :: KnownNat (Max m n + 1) => BitVector m -> BitVector n -> BitVector (Max m n + 1)"
    , "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]),~LIT[0]) - resize(unsigned(~ARG[2]),~LIT[0]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.times#"
    , "type"      : "times# :: KnownNat (m + n) => BitVector m -> BitVector n -> BitVector (m + n)"
    , "templateE" : "std_logic_vector(unsigned(~ARG[1]) * unsigned(~ARG[2]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.quot#"
    , "type"      : "quot# :: BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "std_logic_vector(unsigned(~ARG[1]) / unsigned(~ARG[2]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.rem#"
    , "type"      : "rem# :: BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "~ARG[1] rem ~ARG[2]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.mod#"
    , "type"      : "mod# :: BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "~ARG[1] mod ~ARG[2]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.toInteger#"
    , "type"      : "toInteger# :: BitVector n -> Integer"
    , "templateE" : "to_integer(unsigned(~ARG[0]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.and#"
    , "type"      : "and# :: BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "~ARG[0] and ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.or#"
    , "type"      : "or# :: BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "~ARG[0] or ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.xor#"
    , "type"      : "xor# :: BitVector n -> BitVector n -> BitVector n"
    , "templateE" : "~ARG[0] xor ~ARG[1]"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.complement#"
    , "type"      : "complement# :: KnownNat n => BitVector n -> BitVector n"
    , "templateE" : "not ~ARG[1]"
    }
  }
, { "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]))"
    }
  }
, { "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]))"
    }
  }
, { "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]))"
    }
  }
, { "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]))"
    }
  }
, { "BlackBox" :
    { "name"      : "CLaSH.Sized.Internal.BitVector.resize#"
    , "type"      : "resize# :: KnownNat m => BitVector n -> BitVector m"
    , "templateE" : "std_logic_vector(resize(unsigned(~ARG[1]),~LIT[0]))"
    }
  }
]