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:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style B fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style C fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style D fill:#ffcdd2,stroke:#c62828,color:#2e3440,stroke-width:3px
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:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style B fill:#f3e5f5,stroke:#7b1fa2,color:#2e3440,stroke-width:3px style C fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style D fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style E fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px
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:#ffcdd2,stroke:#c62828,color:#2e3440,stroke-width:3px style B5 fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style A1 fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style A2 fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style A3 fill:#e1f5fe,stroke:#01579b,color:#2e3440,stroke-width:3px style B1 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style B2 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style B3 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style B4 fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px
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:#ffcdd2,stroke:#c62828,color:#2e3440,stroke-width:3px style B_P fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px
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:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style C2 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style C3 fill:#ffcdd2,stroke:#c62828,color:#2e3440,stroke-width:3px
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:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style D fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style F fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style G fill:#ffcdd2,stroke:#c62828,color:#2e3440,stroke-width:3px
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:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style FG fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px
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:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style B fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px style D fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style E fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px
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:#ffcdd2,stroke:#c62828,color:#2e3440,stroke-width:3px style QA1 fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style QA2 fill:#e1f5fe,stroke:#01579b,color:#2e3440,stroke-width:3px style QA3 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style QA4 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style QA6 fill:#dcedc8,stroke:#558b2f,color:#2e3440,stroke-width:3px style DB1 fill:#e3f2fd,stroke:#1565c0,color:#2e3440,stroke-width:3px style DB2 fill:#e1f5fe,stroke:#01579b,color:#2e3440,stroke-width:3px style DB4 fill:#fff3e0,stroke:#e65100,color:#2e3440,stroke-width:3px style DB3 fill:#c8e6c9,stroke:#2e7d32,color:#2e3440,stroke-width:3px