Page 232 - Hardware Implementation of Finite-Field Arithmetic
P. 232
212 Cha pte r Se v e n
if B(0) = ‘0’ then new_b <= ‘0’ & b(M downto 1);
else new_b <= ‘0’&(b(M downto 1) xor (F(M downto
1))); end if;
else
new_U <= U xor V; new_B <= B xor C;
d := 0; --degree calculation
for i in 0 to m loop
if (U(i) xor V(i)) = ‘1’ then d := i; end if;
end loop;
new_degree_u <= conv_std_logic_vector(d,logM+1);
end if;
end process;
uc_comp: process(b,c,u,v,degree_u,degree_v)
begin
if degree_u < degree_v then
new_v <= u; new_c <= b; new_degree_v <= degree_u;
else new_v <= v; new_c <= c; new_degree_v <= degree_v;
end if;
end process;
degr_a: process(A)
variable d: natural;
begin
d := 0;
for i in 0 to m-1 loop if A(i)= ‘1’ then d := i;
end if; end loop;
degree_a <= conv_std_logic_vector(d,logM+1);
end process;
reg: process(clk, reset)
variable d: natural;
begin
if reset = ‘1’ then
u <= (others => ‘0’); v <= (others => ‘0’);
b <= (others => ‘0’); c <= (others => ‘0’);
degree_v <= (others => ‘0’);
degree_u <= (others => ‘0’);
elsif clk’event and clk = ‘1’ then
if first_step = ‘1’ then
v <= (‘1’ & F); c <= (others => ‘0’);
degree_v <= conv_std_logic_vector(M, logM+1);
elsif ce_vc = ‘1’ then
v <= new_v; c <= new_c; degree_v <= new_degree_v;
end if;
if first_step = ‘1’ then
u <= ‘0’ & A; b <= ONE degree_u <= degree_a;
elsif ce_ub = ‘1’ then
u <= new_u; b <= new_b; degree_u <= new_degree_u;
end if;
end if;
end process;