graph LR subgraph "C++ Reference" A[lds.hpp] end subgraph "Verilog RTL" B[vdc_16] --> D[circle_2_16] C[vdc_3_ilds] --> E[circle_3_16] D --> F[disk_23] E --> F F --> G[sphere_23] end A -.-> B A -.-> C style A fill:#ff9800 style F fill:#4caf50 style G fill:#2196f3
graph TD A[16-bit Counter] -->|x4 width| B[32-bit Counter] C[15 CORDIC iters] -->|x2 iters| D[31 CORDIC iters] E[Q2.16 internal] -->|+16 frac bits| F[Q2.32 internal] G[atan table ร16] -->|ร2^16 scale| H[atan table ร31] I[10 factors VdC<3>] -->|+10 factors| J[20 factors VdC<3>] style A fill:#ff9800 style B fill:#4caf50 style C fill:#ff9800 style D fill:#4caf50
graph TD subgraph "Base Modules" A[vdc_32\nVdCorput<2>] B[vdc_3_ilds_32\nVdCorput<3>] C[cordic_32\nCORDIC sin/cos] D[cordic_sqrt_32\nCORDIC sqrt] end subgraph "Composite" E[circle_2_32\nA + C] F[circle_3_32\nB + C] G[disk_32\nE + B + D] H[sphere_32\nA + F + D] end A --> E B --> F C --> E C --> F E --> G B --> G D --> G A --> H F --> H D --> H style A fill:#4caf50 style B fill:#4caf50 style C fill:#ff9800 style D fill:#ff9800
graph LR A["Input Angle\nฮธ = 0x40000000"] --> B["Expected cos = ?\nExpected sin = ?"] B --> C{"How to\ncompute?"} C -->|"Option 1"| D["Hardcode\n32 constants\nper test โ ๏ธ"] C -->|"Option 2"| E["Implement\nCORDIC in\nVerilog โ"] C -->|"Option 3"| F["Use Python ?\n(not possible\nin .v files โ)"] style D fill:#f44336 style E fill:#f44336 style F fill:#ff9800
graph LR A["๐ Python\nTest Script"] --> B["๐ VPI/VHPI\nInterface"] B --> C["โ๏ธ HDL Simulator\n(iverilog)"] C --> D["๐ DUT\nSignals"] D --> B B --> A subgraph "Your Code" A end subgraph "Cocotb" B end subgraph "Simulator" C D end style A fill:#4caf50 style B fill:#ff9800 style C fill:#2196f3
sequenceDiagram participant TB as Testbench participant DUT as Hardware TB->>DUT: en = 1 Note over DUT: posedge clk DUT->>DUT: cnt++, valid <= 1 TB->>DUT: await RisingEdge Note over TB: valid still shows OLD value! TB->>DUT: await RisingEdge (again) Note over TB: NOW valid = 1 โ
graph TD A["IEEE 754 Double\n53 bits mantissa"] --> B["Precision: 2^-53"] C["Q1.31 Fixed-Point\n31 fractional bits"] --> D["Precision: 2^-31"] B --> E["FP error < 0.5 ULP\n≈ 2^-53"] D --> F["Fixed-point error\n≈ 2^-31"] E --> G["FP error is 2^-22 ×\nsmaller than fixed-point!"] style A fill:#4caf50 style C fill:#ff9800 style G fill:#2196f3
graph TD subgraph "Golden Model" A["FP cos"] --> B["FPยฒ"] B --> C["FP 1-x"] C --> D["FP sqrt"] end subgraph "Hardware DUT" E["Fixed cos"] --> F["32ร32 mul"] F --> G["64-bit sub"] G --> H[">> 30 trunc"] H --> I["CORDIC iter"] end style D fill:#4caf50 style I fill:#ff9800
graph TD subgraph "Traditional Flow" A1[Edit Verilog] --> A2[Compute golden values manually] A2 --> A3[Hardcode in .v file] A3 --> A4[iverilog + vvp] A4 --> A5{Pass?} A5 -->|No| A1 end subgraph "Cocotb Flow" B1[Edit Verilog] --> B2[Write Python golden model] B2 --> B3[python run.py] B3 --> B4{Pass?} B4 -->|No| B1 B4 -->|No| B2 end style A2 fill:#f44336 style B2 fill:#4caf50 style B3 fill:#2196f3