G
Gandalf
Guest
Hi all, I'm trying to develop the mentioned cryptosystem. I've obtained a random number generator but I'm stuck on the Transmitter part. I've written this code :
entity Knapsack_Tx is
port(rnum:in std_logic_vector(7 downto 0);clk : in std_logic;
data:std_logic_vector;cip
ut std_logic_vector(7 downto 0));
end Knapsack_Tx;
architecture Encipher of Knapsack_Tx is
type rndnum is array(7 downto 0) of std_logic;
type easy is array(7 downto 0) of std_logic;
--type index is array (0 to 7) of integer;
function elf(rnum:rndnum) return easy is
variable knap1:easy;
variable i: integer := 0;
variable rnum1 : rndnum :=rnum;
variable int1, int2 :integer :=0;
begin
int1:= to_integer(rnum1(i-1));
int2:= to_integer(rnum1(i));
for i in 0 to 7 loop
if int1 <= int2 then
knap1(i) := rnum1(i);
end if;
end loop;
return knap1;
end function elf;
begin
end architecture Encipher;
The rnum1 variable is an array which is used to store the random values obtained from the RNG. The code is obviously incomplete but essentially it revolves around this. Check Syntax reveals that to_integer is not recognised. If anyone can help it would be nice
entity Knapsack_Tx is
port(rnum:in std_logic_vector(7 downto 0);clk : in std_logic;
data:std_logic_vector;cip
end Knapsack_Tx;
architecture Encipher of Knapsack_Tx is
type rndnum is array(7 downto 0) of std_logic;
type easy is array(7 downto 0) of std_logic;
--type index is array (0 to 7) of integer;
function elf(rnum:rndnum) return easy is
variable knap1:easy;
variable i: integer := 0;
variable rnum1 : rndnum :=rnum;
variable int1, int2 :integer :=0;
begin
int1:= to_integer(rnum1(i-1));
int2:= to_integer(rnum1(i));
for i in 0 to 7 loop
if int1 <= int2 then
knap1(i) := rnum1(i);
end if;
end loop;
return knap1;
end function elf;
begin
end architecture Encipher;
The rnum1 variable is an array which is used to store the random values obtained from the RNG. The code is obviously incomplete but essentially it revolves around this. Check Syntax reveals that to_integer is not recognised. If anyone can help it would be nice