LUT.py
1 import numpy as np 2 3 # Define parameters 4 fs = 120e6 # Sampling frequency 5 Ts = 1 / fs # Sampling time 6 Tb = 1e-6 # Burst time 7 Tau = 30e-6 # Pulse repetition time 8 fmax = 15e6 # Maximum frequency on ramp 9 fmin = 1e6 # Minimum frequency on ramp 10 11 # Compute number of samples per ramp 12 n = int(Tb / Ts) 13 N = np.arange(0, n, 1) 14 15 # Compute instantaneous phase 16 theta_n = 2 * np.pi * ((N**2 * Ts**2 * (fmax - fmin) / (2 * Tb)) + fmin * N * Ts) 17 18 # Generate waveform and scale it to 8-bit unsigned values (0 to 255) 19 y = 1 + np.sin(theta_n) # Normalize from 0 to 2 20 y_scaled = np.round(y * 127.5).astype(int) # Scale to 8-bit range (0-255) 21 22 # Print values in Verilog-friendly format 23 for i in range(n): 24 print(f"waveform_LUT[{i}] = 8'h{y_scaled[i]:02X};")