|
| 1 | +# coralnpu on asap7 |
| 2 | + |
| 3 | +[CoralNPU](https://github.com/google-coral/coralnpu) is Google's open |
| 4 | +RISC-V core for edge machine learning: an in-order scalar core that |
| 5 | +dispatches up to four instructions a cycle, with a float unit, two TCM |
| 6 | +SRAMs and AXI ports. `../../src/coralnpu/CoreMiniAxi.sv` is firtool's |
| 7 | +output for `CoreMiniAxi`, every file of the build concatenated. |
| 8 | + |
| 9 | +| design | what it builds | |
| 10 | +|---|---| |
| 11 | +| `coralnpu` | the snapshot as a synthesis build, its SRAMs generated with their write masks | |
| 12 | +| `coralnpu-regfile` | the integer register file generated by `generate_ram` | |
| 13 | +| `coralnpu-regfiles` | the integer and the floating-point register files generated | |
| 14 | + |
| 15 | +Every design keeps coralnpu's function: the surgery below moves storage |
| 16 | +into modules of its own and changes no logic. |
| 17 | + |
| 18 | +## Results |
| 19 | + |
| 20 | +Not yet measured at this OpenROAD. At an earlier OpenROAD, at global |
| 21 | +route with timing repair and a 1,900 ps clock: |
| 22 | + |
| 23 | +| design | period at global route | std-cell area | CTS + global route | |
| 24 | +|---|---|---|---| |
| 25 | +| `coralnpu` | 2,031 ps | 16,757 µm² | about 8,700 s | |
| 26 | +| `coralnpu-regfile` | 1,902 ps | 15,628 µm² | 836 s | |
| 27 | + |
| 28 | +In `coralnpu`, nearly all of the CTS and global route time is |
| 29 | +`repair_timing` on one family of paths: the register file read, an ALU |
| 30 | +result forwarded through it, dispatch's lane issue, and the load/store |
| 31 | +unit's enqueue in one cycle. |
| 32 | + |
| 33 | +## Surgery |
| 34 | + |
| 35 | +`surgery.py` (`SYNTH_VERILOG_SURGERY`) edits the snapshot before |
| 36 | +synthesis. It recognises each thing it changes token for token, and |
| 37 | +anything else stops the build. |
| 38 | + |
| 39 | +- firtool's verification layers are removed, as a build without layers |
| 40 | + enabled would leave them. The snapshot concatenates 61 binds of |
| 41 | + `*_Verification_Assert` into the core. |
| 42 | +- The two TCM SRAMs, `Sram_512x128` and `Sram_2048x128`, move into |
| 43 | + memory modules of firtool's convention, which `AUTO_MEMORIES` |
| 44 | + generates, write masks and all. ORFS's earlier build swapped them for |
| 45 | + fakerams under `USE_ASAP7`. Those have no write mask, so a masked |
| 46 | + write wrote all 16 bytes. |
| 47 | +- `--regfile`: `Regfile` keeps its 31 words as separate registers among |
| 48 | + a scoreboard, read bypasses and registered read outputs, so there is |
| 49 | + no array for yosys to infer. The words move into `Regfile_rf`, which |
| 50 | + `AUTO_MEMORIES_REGFILES` has `generate_ram` build |
| 51 | + (`../coralnpu-regfile/Regfile_rf.regfile`). |
| 52 | +- `--fregfile`: the same for `FRegfile`'s 32 words, each split into |
| 53 | + mantissa, exponent and sign (`../coralnpu-regfiles/FRegfile_rf.regfile`). |
| 54 | + |
| 55 | +## Where the RTL comes from |
| 56 | + |
| 57 | +The snapshot records neither the coralnpu commit it was generated from |
| 58 | +nor how. Upstream has since reworked the critical path above in Chisel |
| 59 | +([43d2030](https://github.com/google-coral/coralnpu/commit/43d20300e9968a444eec4756f42135226e4fbc59), |
| 60 | +"Drive Regfile busPort.data from unforwarded rdata", and a series of |
| 61 | +LSU timing changes after it). A fresh snapshot is out of scope here. |
0 commit comments