Using remotesyn and added NCO

This commit is contained in:
Jojojoppe
2025-10-05 23:20:25 +02:00
parent 639541728f
commit 83cc449c6f
35 changed files with 397 additions and 147990 deletions

24
rtl/core/nco_q15_funcs.vh Normal file
View File

@@ -0,0 +1,24 @@
// ==========================================================
// Helper: FTW function (compile-time or runtime call)
// FTW = round( f_hz * 2^PHASE_BITS / FS_HZ )
// Notes:
// - Accepts integer Hz.
// - Uses 64-bit math to avoid overflow for typical params.
// - Can be called from a testbench or combinational logic that
// prepares 'ftw_in' before asserting 'ftw_we'.
// Example:
// initial begin
// #1;
// $display("FTW 1kHz = 0x%08x", ftw_from_hz(1000));
// end
// ==========================================================
function [31:0] ftw_from_hz;
input integer f_hz;
input integer phase_bits;
input integer fs_hz;
reg [63:0] numer;
begin
numer = ((64'd1 << phase_bits) * f_hz) + (fs_hz/2);
ftw_from_hz = numer / fs_hz;
end
endfunction