support for multiple waveforms
This commit is contained in:
@@ -6,6 +6,7 @@ import struct
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
import data_structures as msg_types
|
||||
from data_structures import CpiHeader
|
||||
@@ -273,32 +274,36 @@ class RadarManager:
|
||||
timecode = self.axi_read_register(UTIL_REG_ADDR + 0x118)
|
||||
print('FPGA Datestamp %x_%x' % (datecode, timecode))
|
||||
|
||||
def load_waveform(self, ch, amp, bw, pw):
|
||||
# addr = 0x0010000 + 0x0010000 * ch
|
||||
def load_waveform(self, ch, amp, bw, pw, num_wf=1):
|
||||
addr = 0x0020000 + 0x0020000 * ch
|
||||
print('Load', hex(addr))
|
||||
num_samples = pw
|
||||
wf = form_chirp(pw, bw, 1)
|
||||
wf = wf * amp
|
||||
|
||||
bram_address = addr
|
||||
waveforms = np.empty(num_wf*num_samples, dtype=np.complex64)
|
||||
for wf_ind in range(num_wf):
|
||||
wf = form_chirp(pw, bw, 1)
|
||||
wf = wf * amp / (wf_ind + 1)
|
||||
waveforms[(wf_ind * num_samples):(wf_ind * num_samples + num_samples)] = wf
|
||||
|
||||
iq = wf * 0x7FFF
|
||||
# plt.plot(waveforms.real)
|
||||
# plt.show()
|
||||
|
||||
iq = waveforms * 0x7FFF
|
||||
iq_real = iq.real.astype(np.uint16)
|
||||
iq_imag = iq.imag.astype(np.uint16)
|
||||
iq_real = iq_real.astype(np.uint32)
|
||||
iq_imag = iq_imag.astype(np.uint32)
|
||||
data = iq_real | (iq_imag << 16)
|
||||
|
||||
num_bursts = num_samples / msg_types.MAX_BURST_LENGTH
|
||||
num_bursts = len(waveforms) / msg_types.MAX_BURST_LENGTH
|
||||
num_bursts = int(np.ceil(num_bursts))
|
||||
|
||||
for i in range(num_bursts):
|
||||
start_ind = i * msg_types.MAX_BURST_LENGTH
|
||||
stop_ind = start_ind + msg_types.MAX_BURST_LENGTH
|
||||
stop_ind = min(stop_ind, num_samples)
|
||||
stop_ind = min(stop_ind, num_wf*num_samples)
|
||||
burst_data = data[start_ind:stop_ind]
|
||||
self.axi_write_register_burst(bram_address + i * 4 * msg_types.MAX_BURST_LENGTH, burst_data)
|
||||
self.axi_write_register_burst(addr + i * 4 * msg_types.MAX_BURST_LENGTH, burst_data)
|
||||
|
||||
def reset_10g_udp(self):
|
||||
val = self.axi_read_register(0x40050008)
|
||||
@@ -348,7 +353,7 @@ class RadarManager:
|
||||
# Just force the enable high all the time before we start running
|
||||
self.axi_write_register(TIMING_ENGINE_ADDR + 0x88 + i * 8, 0x1FFFFFFF)
|
||||
|
||||
def setup_tx(self, num_samples, start_sample):
|
||||
def setup_tx(self, num_samples, start_sample, num_wf):
|
||||
if JESD204B:
|
||||
self.axi_write_register(WAVEFORM_GEN_ADDR + 0x4, num_samples >> 1)
|
||||
self.axi_write_register(WAVEFORM_GEN_ADDR + 0x8, start_sample >> 1)
|
||||
@@ -356,6 +361,8 @@ class RadarManager:
|
||||
self.axi_write_register(WAVEFORM_GEN_ADDR + 0x4, num_samples >> 2)
|
||||
self.axi_write_register(WAVEFORM_GEN_ADDR + 0x8, start_sample >> 2)
|
||||
|
||||
self.axi_write_register(WAVEFORM_GEN_ADDR + 0xC, num_wf)
|
||||
|
||||
# Setup TX Strobe
|
||||
# self.axi_write_register(TIMING_ENGINE_ADDR + 0x80, start_sample >> 2)
|
||||
# self.axi_write_register(TIMING_ENGINE_ADDR + 0x84, num_samples >> 2)
|
||||
@@ -389,8 +396,11 @@ class RadarManager:
|
||||
|
||||
def configure_cpi(self, pri, inter_cpi, num_pulses, num_samples, start_sample,
|
||||
tx_num_samples, tx_start_sample, rx_lo_offset, tx_lo_offset, dec_rate):
|
||||
self.load_waveform(0, 1, 0.05, tx_num_samples)
|
||||
self.load_waveform(1, 1, 0.05, tx_num_samples)
|
||||
|
||||
num_wf = 4
|
||||
|
||||
self.load_waveform(0, 1, 0.05, tx_num_samples, num_wf)
|
||||
self.load_waveform(1, 1, 0.05, tx_num_samples, num_wf)
|
||||
|
||||
num_samples_quant = int(self.packet_size / 4)
|
||||
if num_samples % num_samples_quant > 0:
|
||||
@@ -421,6 +431,6 @@ class RadarManager:
|
||||
|
||||
self.setup_timing_engine(pri, num_pulses, inter_cpi)
|
||||
self.setup_rx(num_samples, start_sample, dec_rate)
|
||||
self.setup_tx(tx_num_samples, tx_start_sample)
|
||||
self.setup_tx(tx_num_samples, tx_start_sample, num_wf)
|
||||
self.setup_cpi_header(pri, inter_cpi, num_pulses, num_samples, start_sample,
|
||||
tx_num_samples, tx_start_sample, rx_lo_offset, tx_lo_offset)
|
||||
@@ -92,10 +92,16 @@ def main():
|
||||
# # plt.ylim([0, .04])
|
||||
|
||||
plt.figure()
|
||||
plt.plot(iq.T.real, '.-')
|
||||
plt.plot(iq.T.imag, '--.')
|
||||
plt.plot(iq[0:4, :].T.real, '.-')
|
||||
# plt.plot(iq[0:4, :].T.imag, '--.')
|
||||
plt.grid()
|
||||
|
||||
plt.figure()
|
||||
plt.plot(np.mean(iq, axis=0).real, '.-')
|
||||
plt.plot(np.mean(iq, axis=0).imag, '--.')
|
||||
plt.grid()
|
||||
|
||||
|
||||
plt.figure()
|
||||
plt.imshow(db20n(iq), aspect='auto', interpolation='nearest', vmin=vmin, vmax=vmax)
|
||||
plt.ylabel('Pulse Count')
|
||||
|
||||
@@ -45,11 +45,11 @@ def main():
|
||||
# CPI Parameters (timing values are in clk ticks)
|
||||
num_pulses = 128
|
||||
# Should be multiple of udp packet size, currently 4096 bytes, or 1024 samples
|
||||
num_samples = 4096
|
||||
num_samples = 8192
|
||||
start_sample = 2000
|
||||
tx_num_samples = 4096
|
||||
tx_start_sample = start_sample
|
||||
prf = 8000
|
||||
prf = 1000
|
||||
pri = int(1/prf * clk)
|
||||
pri -= (pri % 3)
|
||||
# pri = int(.0001 * clk)
|
||||
@@ -57,7 +57,7 @@ def main():
|
||||
inter_cpi = 20000
|
||||
tx_lo_offset = 10e6
|
||||
rx_lo_offset = 0
|
||||
dec_rate = 16
|
||||
dec_rate = 1
|
||||
test_duration = 2
|
||||
|
||||
pri_float = pri / clk
|
||||
|
||||
Reference in New Issue
Block a user