graph TD A["๐๏ธ Continuous\nOptimization\nmin max R(ฯ)"] --> B["๐ Continuous\nCoefficients h"] B --> C["โ๏ธ CSD Quantization\nround to nearest\npower-of-two sum"] C --> D["โ ๏ธ Violated\nSpecifications!"] style A fill:#2196f3,color:#fff style B fill:#4caf50,color:#fff style C fill:#ff9800,color:#fff style D fill:#f44336,color:#fff
graph TD A["๐ฎ cutting_plane_optim_q\nEllipsoid + Oracle"] --> B{"CSD Quantize\ninside oracle"} B --> C["๐ r_csd\n(quantized autocorrelation)"] C --> D["โ Meets Specs\nat sampled points"] C --> E["๐๏ธ Verilog Module\nshift-and-add"] style A fill:#ff9800,color:#fff style B fill:#9c27b0,color:#fff style C fill:#4caf50,color:#fff style D fill:#4caf50,color:#fff style E fill:#2196f3,color:#fff
graph TD subgraph "Quantize-After ๐ ฐ๏ธ" A1["r* (optimal continuous)"] A2["h = spectral_fact(r*)"] A3["h_csd โ h (rounding)"] A4["โ ๏ธ Spec violations\npossible"] end subgraph "Discrete Optim ๐ ฑ๏ธ" B1["Iterate: xc โ oracle"] B2["h = spectral_fact(xc)"] B3["h_csd = csd_quantize(h)"] B4["rcsd = inv_spect_fact(h_csd)"] B5["Validate rcsd โ "] end A1 --> A2 --> A3 --> A4 B1 --> B2 --> B3 --> B4 --> B5 --> B1 style A4 fill:#f44336,color:#fff style B5 fill:#4caf50,color:#fff style A1 fill:#2196f3,color:#fff style B1 fill:#ff9800,color:#fff
graph LR subgraph "Quantize-After ๐ ฐ๏ธ" A_P["Passband: R(ฯ) โ [0.76, 1.26]\nLOWER BOUND VIOLATED โ"] end subgraph "Discrete Optim ๐ ฑ๏ธ" B_P["Passband: R(ฯ) โ [0.79, 1.26]\nWITHIN BOUNDS โ "] end style A_P fill:#f44336,color:#fff style B_P fill:#4caf50,color:#fff
graph TD subgraph "Continuous Solution (r*)" C1["All constraints satisfied\nL^2 โค R(ฯ) โค U^2"] end subgraph "After CSD Quantization" C2["Some R(ฯ) drop below L^2\nโ spectral_fact roundtrip\nโ coefficient rounding"] C3["Frequency response dips\nbetween oracle sample points"] end C1 -->|"spectral_fact\n+ csd_quantize\n+ inv_spect_fact"| C2 C2 --> C3 style C1 fill:#4caf50,color:#fff style C2 fill:#ff9800,color:#fff style C3 fill:#f44336,color:#fff
graph TD A["Oracle evaluates\nrcsd at xc"] --> B{"Feasible?"} B -->|"โ Shrunk"| C["๐ฏ Record x_best = rcsd\nUpdate gamma\nCentral cut"] B -->|"โ Violated"| D["โ๏ธ Bias cut\nusing rcsd gradient"] B -->|"โญ NoEffect"| E{"More retries\n< 15?"} E -->|"Yes"| F["๐ Retry:\nnew CSD pattern\nfrom updated xc"] E -->|"No"| G["โน๏ธ Give up\n(no better alt)"] C --> A D --> A F --> A style C fill:#4caf50,color:#fff style D fill:#2196f3,color:#fff style F fill:#ff9800,color:#fff style G fill:#f44336,color:#fff
graph LR subgraph "Oracle Grid ๐ฎ" OG["480 sample points\n(15 ร N)\nโ PASS"] end subgraph "Fine Grid ๐ฌ" FG["16384 sample points\nโ ๏ธ Possible dips\nbetween oracle samples"] end style OG fill:#4caf50,color:#fff style FG fill:#ff9800,color:#fff
graph TD Q["Need CSD coefficients?"] -->|"Quick prototype"| A["๐ ฐ๏ธ Quantize-After\nFast, no spec guarantee"] Q -->|"Production hardware"| B["๐ ฑ๏ธ Discrete Optim\nGuaranteed spec compliance"] B --> C{"Tight constraints?"} C -->|"Yes"| D["Increase disc_factor\nโ 30 or higher"] C -->|"No"| E["disc_factor = 15\nGood enough"] style A fill:#ff9800,color:#fff style B fill:#4caf50,color:#fff style D fill:#2196f3,color:#fff style E fill:#4caf50,color:#fff
graph TD subgraph "Quantize-After ๐ ฐ๏ธ" QA1["r* optimal"] --> QA2["Verify: spec OK?"] QA2 -->|"YES (r*)"| QA3["Quantize h"] QA3 --> QA4["Verify: still OK?"] QA4 -->|"NO"| QA5["โ REDO"] QA4 -->|"LUCK"| QA6["โ Maybe OK"] end subgraph "Discrete Optim ๐ ฑ๏ธ" DB1["rcsd from oracle"] --> DB2["Verify at oracle grid"] DB2 -->|"PASS"| DB3["โ GUARANTEED"] DB2 -->|"FAIL"| DB4["๐ Iterate more"] end style QA5 fill:#f44336,color:#fff style DB3 fill:#4caf50,color:#fff