--- Quote Start ---
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 example) the phase increment value and also to make my nco fully programmable, i need to write vhdl code for this function:
Phase_Inc = Fout*2^N/F_clk.
The parameters for the fuction should be Fout, F_clk and N (number of bits). The output should be a std_logic_vector(63 downto 0) in my case.
Could you help me?
Thanks
--- Quote End ---
try this. you need numeric_std library
function get_phase_inc(Fout,clk,N : natural) return std_logic_vector is
variable phase : integer;
begin
phase := Fout*2**N/clk;
return std_logic_vector(to_unsigned(phase,N));
end function;
signal test : std_logic_vector(7 downto 0);
...
test <= get_phase_inc(10,100,8);