Forum Discussion
Altera_Forum
Honored Contributor
12 years agocalculate 64 bit unsigned
hi, i've implemented a nco megafunction with a 64 bit phase accumulator in order to obtain very high precision output frequencies. Now to be able to program externally (by microcontroller for ex...
Altera_Forum
Honored Contributor
12 years ago --- Quote Start --- the problem arises when N is 64 as a integer is not enough to represent it. How could i resolve? --- Quote End --- Indeed.. try this since Fo*2^64/clk = Fo*2^32/clk * 2*32/clk.
function phase_inc(Fout,clk, N : natural) return std_logic_vector is
variable phase : integer;
variable temp1,temp2:unsigned(N/2-1 downto 0);
begin
phase := Fout*(2**N/2)/clk;
temp1 := to_unsigned(phase,32);
phase := (2**N/2)/clk;
temp2 := to_unsigned(phase,32);
return std_logic_vector(temp1*temp2);
end function;