Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ede3047
Board settings change
emrhnozdemir Mar 3, 2026
27b05aa
Update bd_2023-1.tcl
emrhnozdemir Mar 5, 2026
74b1930
axis_register_slice_nb
emrhnozdemir Mar 5, 2026
5736970
Update bd_2023-1.tcl
emrhnozdemir Mar 9, 2026
b4756ac
adaptive_sweep module template
emrhnozdemir Mar 10, 2026
1c76d98
bug fix
emrhnozdemir Mar 10, 2026
065fdb0
bug fix
emrhnozdemir Mar 10, 2026
2b2f13b
Peripheral Communication Test
emrhnozdemir Apr 2, 2026
155c27f
Update IP
emrhnozdemir Apr 2, 2026
f691a7d
Update testbench defaults and waveform view
emrhnozdemir Apr 20, 2026
b4f6bcc
Do not use asynchronous reset
emrhnozdemir Apr 24, 2026
2be071d
Python simulation added
emrhnozdemir May 6, 2026
e95f4cd
adaptive sweep & fine tuning sweep code
emrhnozdemir May 13, 2026
0670c7f
Update tb_qick.sv
emrhnozdemir May 13, 2026
3951ca9
update fine tuning algorithm
emrhnozdemir May 14, 2026
b770285
update fine tuning sweep
emrhnozdemir May 14, 2026
083e721
Update fine tuning sweep component
emrhnozdemir May 14, 2026
78f35f1
Fine Tuning Test
emrhnozdemir May 19, 2026
0728dae
Update fine tuning sweep (sync reset)
emrhnozdemir May 21, 2026
2c65038
Fine_tuning_sweep update
emrhnozdemir May 26, 2026
61d2441
Debug Fine Tuning Sweep
emrhnozdemir Jun 3, 2026
9ba3fdc
Debug 2
emrhnozdemir Jun 3, 2026
18a9ebe
Debug 3
emrhnozdemir Jun 3, 2026
54547a4
Debug 4
emrhnozdemir Jun 4, 2026
0346b38
FIne tuning sweep update
emrhnozdemir Jun 5, 2026
a875655
Fine_tuining_sweep_update
emrhnozdemir Jun 5, 2026
c2e29a6
Update component.xml
emrhnozdemir Jun 5, 2026
bd083cf
Update bd_2023-1.tcl
emrhnozdemir Jun 14, 2026
3e2976b
Bug fix fine_tuning_Sweep
emrhnozdemir Jun 23, 2026
2b3bb26
Update fine_tuning_sweep.v
emrhnozdemir Jun 23, 2026
a34abcb
Update fine_tuning_sweep
emrhnozdemir Jun 24, 2026
4656ec3
Bug fix fine tuning sweep
emrhnozdemir Jun 24, 2026
df8e434
Diagnose registers
emrhnozdemir Jun 25, 2026
45876f3
peak_finder debug
emrhnozdemir Jun 25, 2026
96e3bcf
Fine tune bug fix try
emrhnozdemir Jun 25, 2026
52bdbfb
fsm bug fix
emrhnozdemir Jun 26, 2026
bd96236
pending check reg
emrhnozdemir Jun 26, 2026
460906b
Peak finder debug Update
emrhnozdemir Jun 28, 2026
ccc6d13
Update component.xml
emrhnozdemir Jun 28, 2026
16d0704
Update fine_tuning_sweep.v
emrhnozdemir Jun 28, 2026
69fb8f4
New ILA probes
emrhnozdemir Jun 28, 2026
f057676
ILA probes
emrhnozdemir Jun 28, 2026
a0a307e
PB ILA probes
emrhnozdemir Jun 29, 2026
fadf197
PB update
emrhnozdemir Jul 1, 2026
71f2a0a
New ILA probes
emrhnozdemir Jul 3, 2026
2980ba7
Update Amplitude Calculator
emrhnozdemir Jul 5, 2026
753fea7
Pipeline
emrhnozdemir Jul 5, 2026
89533b6
Update component.xml
emrhnozdemir Jul 5, 2026
d46fc32
Pipeline fix
emrhnozdemir Jul 5, 2026
15ea2d7
Pipeline fix
emrhnozdemir Jul 5, 2026
bc145bf
Bug fix
emrhnozdemir Jul 5, 2026
e6f2c5a
Update fine_tuning_sweep
emrhnozdemir Jul 8, 2026
547326d
Optimize fine_tuning_sweep
emrhnozdemir Jul 9, 2026
986f61a
Update bd_2023-1.tcl
emrhnozdemir Jul 9, 2026
a2f2580
Update bd_2023-1.tcl
emrhnozdemir Jul 9, 2026
c188ea4
Update amplitude_calculator.v
emrhnozdemir Jul 10, 2026
faf8e01
Optimize amplitude calculator
emrhnozdemir Jul 10, 2026
4086909
Fine_tuning_sweep optimization
emrhnozdemir Jul 15, 2026
1425a3d
Update tb_amplitude_calculator.sv
emrhnozdemir Jul 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,13 @@ Temporary Items

!/.gitignore
!/README.md

# Claude Code
.claude/
CLAUDE.md

# Graphify output
graphify-out/

# Personal Files
personal_files/
10 changes: 10 additions & 0 deletions .graphifyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Vivado build artifacts - regenerated on every synthesis run
**/top.cache/
**/top.gen/
**/top.runs/
**/top.sim/
**/top.hw/
**/top.ip_user_files/
**/.Xil/
**/*.jou
**/*.log
752 changes: 752 additions & 0 deletions firmware/ip/adaptive_sweep/component.xml

Large diffs are not rendered by default.

342 changes: 342 additions & 0 deletions firmware/ip/adaptive_sweep/src/adaptive_sweep.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
`timescale 1ns / 1ps
//
// adaptive_sweep.v -- top wrapper for the adaptive_sweep IP.
//
// Replaces the placeholder 4-entry frequency LUT with the real RTL
// implementation of Section 9 of resonator_sweep.ipynb (KW + Polyak
// averaging + 3 dB bisection).
//
// Hierarchy:
// adaptive_sweep
// adaptive_sweep_control (QP2 opcode FSM, c_clk)
// readout_capture (ro_clk -> c_clk CDC FIFO + trigger)
// polyak_averager (I) (chunked Polyak average of I)
// polyak_averager (Q) (chunked Polyak average of Q)
// iq_power (I_avg^2 + Q_avg^2)
// kw_steps (LUT-driven KW step + clamp)
// bisect_control (3 dB edge bisection FSM)
//
// Ports:
// QP2 slave : qtag_* (unchanged from placeholder)
// AXIS slave : s_ro_axis_* (snoop on m1_axis of axis_dyn_readout_v1)
// trigger_i : 1-bit, ro_clk async
//

module adaptive_sweep #(
parameter integer LUT_DEPTH = 256,
parameter integer LUT_AW = 8,
parameter integer X_WIDTH = 32,
parameter integer IQ_WIDTH = 16,
parameter integer SUM_WIDTH = 48,
parameter integer POW_WIDTH = 32,
parameter integer COUNT_WIDTH = 16,
parameter integer RO_FIFO_DEPTH_LOG2 = 6,
parameter [X_WIDTH-1:0] KW_TOL = 32'h0000_07D0
)(
input wire clk, // c_clk
input wire rst_n,

// ---- QP2 (tProc-side) ----
input wire qtag_en_i,
input wire [4:0] qtag_op_i,
input wire [31:0] qtag_dt1_i,
input wire [31:0] qtag_dt2_i,
input wire [31:0] qtag_dt3_i,
input wire [31:0] qtag_dt4_i,
output wire qtag_rdy_o,
output wire [31:0] qtag_dt1_o,
output wire [31:0] qtag_dt2_o,
output wire qtag_vld_o,

// ---- Readout snoop (m1_axis of axis_dyn_readout_v1) ----
input wire s_ro_axis_aclk, // ro_clk
input wire s_ro_axis_aresetn,
input wire [2*IQ_WIDTH-1:0] s_ro_axis_tdata, // {Q[15:0],I[15:0]}
input wire s_ro_axis_tvalid,
output wire s_ro_axis_tready,

// ---- External trigger (ro_clk async, sourced from tProc trig_0_o) ----
input wire trigger_i
);

// -------------------------------------------------------------
// Inter-module wires
// -------------------------------------------------------------
// adaptive_sweep_control <-> polyak_averagers
wire pa_soft_reset;
wire [31:0] pa_reciprocal;
wire [3:0] pa_chunk_log2;
wire signed [X_WIDTH-1:0] pa_i_xbar;
wire signed [X_WIDTH-1:0] pa_q_xbar;

// adaptive_sweep_control <-> iq_power
wire pwr_compute_pulse;
wire signed [IQ_WIDTH-1:0] pwr_i_in;
wire signed [IQ_WIDTH-1:0] pwr_q_in;
wire [POW_WIDTH-1:0] pwr_value;
wire pwr_valid;

// adaptive_sweep_control <-> kw_steps
wire kw_lut_we;
wire [LUT_AW-1:0] kw_lut_addr;
wire signed [X_WIDTH-1:0] kw_lut_din;
wire kw_step_trigger;
wire signed [X_WIDTH-1:0] kw_dp_signed;
wire [LUT_AW-1:0] kw_k_idx;
wire signed [X_WIDTH-1:0] kw_x_in;
wire signed [X_WIDTH-1:0] kw_x_min;
wire signed [X_WIDTH-1:0] kw_x_max;
wire signed [X_WIDTH-1:0] kw_x_out;
wire kw_conv_flag;
wire kw_valid;

// adaptive_sweep_control <-> bisect_control
wire bs_init;
wire [X_WIDTH-1:0] bs_lo_init;
wire [X_WIDTH-1:0] bs_hi_init;
wire bs_side_left;
wire bs_polarity_peak;
wire [X_WIDTH-1:0] bs_tol_in;
wire bs_step;
wire [X_WIDTH-1:0] bs_pow_mid;
wire [X_WIDTH-1:0] bs_pow_thr;
wire [X_WIDTH-1:0] bs_mid_next;
wire [X_WIDTH-1:0] bs_lo_o;
wire [X_WIDTH-1:0] bs_hi_o;
wire bs_converged;
wire bs_valid;

// adaptive_sweep_control <-> readout_capture
wire rc_arm_pulse;
wire [COUNT_WIDTH-1:0] rc_n_samples;
wire rc_capture_done;
wire [COUNT_WIDTH-1:0] rc_samples_remaining;
wire signed [IQ_WIDTH-1:0] rc_i_out;
wire signed [IQ_WIDTH-1:0] rc_q_out;
wire rc_iq_valid;
wire rc_iq_ready;

// x state visibility (currently unused outside ctrl, but routed for future)
wire signed [X_WIDTH-1:0] x_current;
wire signed [X_WIDTH-1:0] x_min;
wire signed [X_WIDTH-1:0] x_max;
wire [LUT_AW-1:0] iter_k;

// The polyak averagers always consume samples as soon as readout_capture
// presents them. iq_ready is therefore tied high.
assign rc_iq_ready = 1'b1;

// -------------------------------------------------------------
// adaptive_sweep_control
// -------------------------------------------------------------
adaptive_sweep_control #(
.X_WIDTH (X_WIDTH),
.IQ_WIDTH (IQ_WIDTH),
.POW_WIDTH (POW_WIDTH),
.COUNT_WIDTH(COUNT_WIDTH),
.LUT_AW (LUT_AW)
) u_ctrl (
.clk (clk),
.rst_n (rst_n),

.qtag_en_i (qtag_en_i),
.qtag_op_i (qtag_op_i),
.qtag_dt1_i (qtag_dt1_i),
.qtag_dt2_i (qtag_dt2_i),
.qtag_dt3_i (qtag_dt3_i),
.qtag_dt4_i (qtag_dt4_i),
.qtag_rdy_o (qtag_rdy_o),
.qtag_dt1_o (qtag_dt1_o),
.qtag_dt2_o (qtag_dt2_o),
.qtag_vld_o (qtag_vld_o),

.pa_soft_reset (pa_soft_reset),
.pa_reciprocal (pa_reciprocal),
.pa_chunk_log2 (pa_chunk_log2),
.pa_i_xbar (pa_i_xbar),
.pa_q_xbar (pa_q_xbar),

.pwr_compute_pulse (pwr_compute_pulse),
.pwr_i_in (pwr_i_in),
.pwr_q_in (pwr_q_in),
.pwr_value (pwr_value),
.pwr_valid (pwr_valid),

.kw_lut_we (kw_lut_we),
.kw_lut_addr (kw_lut_addr),
.kw_lut_din (kw_lut_din),
.kw_step_trigger (kw_step_trigger),
.kw_dp_signed (kw_dp_signed),
.kw_k_idx (kw_k_idx),
.kw_x_in (kw_x_in),
.kw_x_min (kw_x_min),
.kw_x_max (kw_x_max),
.kw_x_out (kw_x_out),
.kw_conv_flag (kw_conv_flag),
.kw_valid (kw_valid),

.bs_init (bs_init),
.bs_lo_init (bs_lo_init),
.bs_hi_init (bs_hi_init),
.bs_side_left (bs_side_left),
.bs_polarity_peak (bs_polarity_peak),
.bs_tol_in (bs_tol_in),
.bs_step (bs_step),
.bs_pow_mid (bs_pow_mid),
.bs_pow_thr (bs_pow_thr),
.bs_mid_next (bs_mid_next),
.bs_lo_o (bs_lo_o),
.bs_hi_o (bs_hi_o),
.bs_converged (bs_converged),
.bs_valid (bs_valid),

.rc_arm_pulse (rc_arm_pulse),
.rc_n_samples (rc_n_samples),
.rc_capture_done (rc_capture_done),
.rc_samples_remaining (rc_samples_remaining),

.x_current_o (x_current),
.x_min_o (x_min),
.x_max_o (x_max),
.iter_k_o (iter_k)
);

// -------------------------------------------------------------
// readout_capture (ro_clk -> c_clk CDC, trigger gate)
// -------------------------------------------------------------
readout_capture #(
.IQ_WIDTH (IQ_WIDTH),
.FIFO_DEPTH_LOG2(RO_FIFO_DEPTH_LOG2),
.COUNT_WIDTH (COUNT_WIDTH)
) u_rc (
.clk (clk),
.rst_n (rst_n),
.arm_pulse (rc_arm_pulse),
.n_samples (rc_n_samples),
.capture_done_o (rc_capture_done),
.i_out (rc_i_out),
.q_out (rc_q_out),
.iq_valid (rc_iq_valid),
.iq_ready (rc_iq_ready),
.samples_remaining (rc_samples_remaining),

.s_ro_axis_aclk (s_ro_axis_aclk),
.s_ro_axis_aresetn (s_ro_axis_aresetn),
.s_ro_axis_tdata (s_ro_axis_tdata),
.s_ro_axis_tvalid (s_ro_axis_tvalid),
.s_ro_axis_tready (s_ro_axis_tready),
.trigger_i (trigger_i)
);

// -------------------------------------------------------------
// polyak_averager (I)
// -------------------------------------------------------------
polyak_averager #(
.SAMPLE_WIDTH(IQ_WIDTH),
.SUM_WIDTH (SUM_WIDTH),
.AVG_WIDTH (X_WIDTH),
.RECIP_WIDTH (32),
.COUNT_WIDTH (COUNT_WIDTH)
) u_pa_i (
.clk (clk),
.rst_n (rst_n),
.sample_in (rc_i_out),
.sample_valid (rc_iq_valid),
.reciprocal_in (pa_reciprocal),
.chunk_size_log2 (pa_chunk_log2),
.soft_reset (pa_soft_reset),
.xbar_o (pa_i_xbar),
.xbar_delta_o (),
.count_o (),
.valid_o ()
);

// -------------------------------------------------------------
// polyak_averager (Q)
// -------------------------------------------------------------
polyak_averager #(
.SAMPLE_WIDTH(IQ_WIDTH),
.SUM_WIDTH (SUM_WIDTH),
.AVG_WIDTH (X_WIDTH),
.RECIP_WIDTH (32),
.COUNT_WIDTH (COUNT_WIDTH)
) u_pa_q (
.clk (clk),
.rst_n (rst_n),
.sample_in (rc_q_out),
.sample_valid (rc_iq_valid),
.reciprocal_in (pa_reciprocal),
.chunk_size_log2 (pa_chunk_log2),
.soft_reset (pa_soft_reset),
.xbar_o (pa_q_xbar),
.xbar_delta_o (),
.count_o (),
.valid_o ()
);

// -------------------------------------------------------------
// iq_power : I_avg^2 + Q_avg^2 (one-shot, fired by control)
// -------------------------------------------------------------
iq_power #(
.IQ_WIDTH (IQ_WIDTH),
.POW_WIDTH(POW_WIDTH)
) u_iqp (
.clk (clk),
.rst_n (rst_n),
.i_in (pwr_i_in),
.q_in (pwr_q_in),
.valid_in(pwr_compute_pulse),
.power_o (pwr_value),
.valid_o (pwr_valid)
);

// -------------------------------------------------------------
// kw_steps : LUT-driven KW step + clamp
// -------------------------------------------------------------
kw_steps #(
.X_WIDTH (X_WIDTH),
.LUT_DEPTH(LUT_DEPTH),
.LUT_AW (LUT_AW),
.KW_TOL (KW_TOL)
) u_kw (
.clk (clk),
.rst_n (rst_n),
.lut_we (kw_lut_we),
.lut_addr (kw_lut_addr),
.lut_din (kw_lut_din),
.step_trigger(kw_step_trigger),
.dp_signed (kw_dp_signed),
.k_idx (kw_k_idx),
.x_in (kw_x_in),
.x_min (kw_x_min),
.x_max (kw_x_max),
.x_out (kw_x_out),
.conv_flag (kw_conv_flag),
.valid_o (kw_valid)
);

// -------------------------------------------------------------
// bisect_control : 3 dB edge bisection
// -------------------------------------------------------------
bisect_control #(
.X_WIDTH(X_WIDTH)
) u_bs (
.clk (clk),
.rst_n (rst_n),
.init (bs_init),
.lo_init (bs_lo_init),
.hi_init (bs_hi_init),
.side_left (bs_side_left),
.polarity_peak(bs_polarity_peak),
.tol_in (bs_tol_in),
.step (bs_step),
.pow_mid (bs_pow_mid),
.pow_thr (bs_pow_thr),
.mid_next (bs_mid_next),
.lo_o (bs_lo_o),
.hi_o (bs_hi_o),
.converged_o (bs_converged),
.valid_o (bs_valid)
);

endmodule
Loading
Loading