From 85846aa2e60a30c64f60ed9b92475508d2296f27 Mon Sep 17 00:00:00 2001 From: jel221 Date: Thu, 3 Dec 2026 06:15:27 -0800 Subject: [PATCH 1/2] fpu: run FDIV/FSQRT as TFU micro-ops and remove the divide/sqrt units --- AGENTS.md | 4 +- CHANGELOG.md | 5 + VX_config.toml | 23 +- ci/testcases/config1.yaml | 14 - ci/testcases/core.yaml | 17 +- ci/testcases/isa/riscv.yaml | 2 +- ci/testcases/unittest.yaml | 2 +- docs/assets/img/fpu_architecture.svg | 34 +- docs/assets/img/fpu_format_sharing.svg | 33 +- docs/designs/floating_point_unit.md | 145 ++--- docs/designs/ray_tracing_architecture.md | 4 +- hw/dpi/dpi_float.cpp | 11 - hw/dpi/dpi_float.vh | 1 - hw/rtl/VX_define.vh | 7 + hw/rtl/VX_gpu_pkg.sv | 4 +- hw/rtl/core/VX_uop_fdiv.sv | 219 ++++++++ hw/rtl/core/VX_uop_sequencer.sv | 20 + hw/rtl/fpu/VX_fdiv_unit.sv | 2 +- hw/rtl/fpu/VX_fdiv_unit_rtl.sv | 3 +- hw/rtl/fpu/VX_fdivsqrt_unit.sv | 669 ----------------------- hw/rtl/fpu/VX_fpu_dpi.sv | 182 +----- hw/rtl/fpu/VX_fpu_dsp.sv | 282 +--------- hw/rtl/fpu/VX_fpu_fpnew.sv | 214 ++------ hw/rtl/fpu/VX_fpu_std.sv | 117 +--- hw/rtl/fpu/VX_fsqrt_unit.sv | 112 ---- hw/rtl/fpu/VX_fsqrt_unit_rtl.sv | 617 --------------------- hw/rtl/rtu/VX_rtu_pkg.sv | 5 +- hw/scripts/altera_ip_gen.sh | 1 - hw/scripts/check_ip_contracts.py | 4 +- hw/scripts/xilinx_ip_gen.tcl | 3 - hw/scripts/xilinx_ip_stubs.sv | 15 - hw/syn/firesim/Makefile | 2 +- hw/syn/foldsim/Makefile | 4 +- hw/syn/xilinx/aved/package_ip.tcl | 2 +- hw/syn/xilinx/dut/project.tcl | 1 - hw/syn/xilinx/xrt/package_kernel.tcl | 1 - hw/unittest/Makefile | 16 - hw/unittest/fdivsqrt_unit/Makefile | 37 -- hw/unittest/fdivsqrt_unit/main.cpp | 198 ------- hw/unittest/fsqrt_unit/Makefile | 46 -- hw/unittest/fsqrt_unit/main.cpp | 199 ------- profiles/a100.json | 6 +- profiles/gtx1080.json | 5 +- profiles/gtx480.json | 4 +- profiles/h100.json | 6 +- profiles/keplertitan.json | 4 +- profiles/mi300x.json | 3 - profiles/p100.json | 4 +- profiles/rtx2060.json | 4 +- profiles/rtx5080.json | 6 +- profiles/v100.json | 6 +- sim/foldsim/xilinx_fp_models.sv | 21 - sim/simx/decode.cpp | 2 + sim/simx/fpu_unit.cpp | 165 ++++-- sim/simx/fpu_unit.h | 23 +- sim/simx/sequencer.cpp | 7 + sim/simx/sequencer.h | 2 + tests/regression/Makefile | 2 +- tests/regression/dogfood/testcases.h | 8 +- tests/regression/fdiv_tfu/Makefile | 18 + tests/regression/fdiv_tfu/common.h | 26 + tests/regression/fdiv_tfu/kernel.cpp | 40 ++ tests/regression/fdiv_tfu/main.cpp | 224 ++++++++ tests/riscv/isa/Makefile | 4 +- 64 files changed, 903 insertions(+), 2964 deletions(-) create mode 100644 hw/rtl/core/VX_uop_fdiv.sv delete mode 100644 hw/rtl/fpu/VX_fdivsqrt_unit.sv delete mode 100644 hw/rtl/fpu/VX_fsqrt_unit.sv delete mode 100644 hw/rtl/fpu/VX_fsqrt_unit_rtl.sv delete mode 100644 hw/unittest/fdivsqrt_unit/Makefile delete mode 100644 hw/unittest/fdivsqrt_unit/main.cpp delete mode 100644 hw/unittest/fsqrt_unit/Makefile delete mode 100644 hw/unittest/fsqrt_unit/main.cpp create mode 100644 tests/regression/fdiv_tfu/Makefile create mode 100644 tests/regression/fdiv_tfu/common.h create mode 100644 tests/regression/fdiv_tfu/kernel.cpp create mode 100644 tests/regression/fdiv_tfu/main.cpp diff --git a/AGENTS.md b/AGENTS.md index f41785c794..1bbfa56234 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -139,9 +139,9 @@ python3 ci/roofline.py --app=sgemm --driver=simx --args="-n128" --flops=4194304 - **Vivado floating-point IP latency is an Fmax knob, and it is already at its maximum.** - `hw/scripts/xilinx_ip_gen.tcl` sets each `floating_point` IP's `C_Latency`. More cycles means more internal pipelining, up to a per-operation maximum; Vivado rejects any value above it. - - The single-precision maxima on V80 and U55C are: FMA 16 (`Medium_Usage`; 19 with `Full_Usage`), divide 28, square root 28, multiply 8, add 11. `xil_fma`, `xil_fdiv`, `xil_fsqrt` and the TCU's `xil_fmul`/`xil_fadd` already use them, so FMA with `Full_Usage` (more DSPs) is the only headroom left. + - The single-precision maxima on V80 and U55C are: FMA 16 (`Medium_Usage`; 19 with `Full_Usage`), divide 28, multiply 8, add 11. `xil_fma`, the RTU's `xil_fdiv` and the TCU's `xil_fmul`/`xil_fadd` already use them, so FMA with `Full_Usage` (more DSPs) is the only headroom left. - A change must move together: `C_Latency`, the matching `VX_CFG_*_LATENCY` in `VX_config.toml` (checked by the `STATIC_ASSERT`s in `hw/rtl/fpu/VX_f*_unit.sv`), and the SimX timing that reads it. - - This applies only to `FPU_TYPE_DSP`. The STD FPU's div/sqrt latency is fixed by its SRT stage count, and only its FMA latency is configurable. + - In the FPU this applies only to `FPU_TYPE_DSP`'s FMA; the FPU has no divider or square root (FDIV/FSQRT expand into TFU micro-ops). - **Pipeline isolation** ([V-ISO-1…6](docs/guidelines/verilog/pipeline_isolation.md)): extensions attach at the extension points (an execution unit behind dispatch, decode, the uop sequencer, the existing scheduler hooks, memory), never inside the shared pipeline; anything else needs the V-ISO-6 justification and the maintainer's approval. The change-impact classifier raises such a change to R3. diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d30fc01c8..3a0bf25e85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,11 @@ follows the version pins recorded in [VERSION](VERSION) (`VORTEX_VERSION`, negation are summed in parallel instead of a negate after the sum. Results stay bit-identical to `sw/common/tfu.cpp` and the pipeline stays 7 stages. Beacon: the `tfu` DUT drops from 24 to 13 logic levels, and a 16-warp, 8-thread core with the TFU from 23 to 15 (the TFU no longer sets its depth); the ASIC estimate of `tfu` rises from 913 to 1239 MHz with 7% fewer cells. +- **FDIV/FSQRT run on the TFU.** The FPU's divide/square-root units are gone: VX_uop_fdiv expands FDIV and FSQRT (.S and .D) into + TFU reciprocal/rsqrt micro-ops plus FMUL, FSUB, FSGNJX and F2F, writing only rd. Results are within 3 ulp, not correctly rounded, + and raise only the flags of the FPU micro-ops (no DZ). The TFU is now part of every F build (`VX_CFG_EXT_TFU_ENABLE` follows + `VX_CFG_EXT_F_ENABLE`) with one lane per 8 FMA lanes. `VX_CFG_FDIV_LATENCY`, `VX_CFG_FSQRT_LATENCY`, `VX_CFG_FDIV_PE_RATIO` and + `VX_CFG_FSQRT_PE_RATIO` are removed. See [docs/designs/floating_point_unit.md](docs/designs/floating_point_unit.md). - **Machine-mode trap CSRs.** `mtvec` is one per core, held by the core scheduler and shared by every warp; `mcause` holds the 4-bit exception codes the core raises; `mtval` reads as zero. `mstatus` (its `MIE`, `MPIE` and `FS` fields), `mepc` and `mcause` stay per warp. Per-warp trap state drops from 160 to at most 39 bits at XLEN 32. diff --git a/VX_config.toml b/VX_config.toml index db2a13d3ce..3f7cd71ebc 100644 --- a/VX_config.toml +++ b/VX_config.toml @@ -44,7 +44,8 @@ VX_CFG_EXT_TEX_ENABLE = false VX_CFG_EXT_RASTER_ENABLE = false VX_CFG_EXT_OM_ENABLE = false VX_CFG_EXT_RTU_ENABLE = false -VX_CFG_EXT_TFU_ENABLE = false +# FDIV/FSQRT expand into TFU micro-ops (VX_uop_fdiv), so F needs the TFU +VX_CFG_EXT_TFU_ENABLE = "expr: $VX_CFG_EXT_F_ENABLE" # Wide loads and stores (vx_flw.d/.q, vx_fsw.d/.q): 2 or 4 consecutive words # to or from an aligned FP register group, one flw/fsw uop per word. Requires # F with FLEN 32 (no D). @@ -163,17 +164,7 @@ VX_CFG_FPU_USE_DSP = "expr: 1 if ($SYNTHESIS and not $ASIC) else 0" fpu_dsp_quartus = "expr: $VX_CFG_FPU_TYPE_DSP and $QUARTUS" fpu_dsp_vivado = "expr: $VX_CFG_FPU_TYPE_DSP and $VIVADO" -# STD: FDIV_LATENCY must equal FSQRT_LATENCY (shared serializer in VX_fpu_std) VX_CFG_FMA_LATENCY = "expr: 16 if $fpu_dsp_vivado else (4 if $fpu_dsp_quartus else (12 if $VX_CFG_EXT_D_ENABLE else 8))" -# STD timing; DPI is a fast STD and takes the same values. -fdiv_latency_std = "expr: 32 if $VX_CFG_EXT_D_ENABLE else 17" -fsqrt_latency_std = "expr: $fdiv_latency_std" -# The vendor divide and square-root IP is F32 only; with D they are the RTL cores. -fdiv_latency_dsp = "expr: 32 if $VX_CFG_EXT_D_ENABLE else (15 if $QUARTUS else (28 if $VIVADO else 17))" -fsqrt_latency_dsp = "expr: 32 if $VX_CFG_EXT_D_ENABLE else (10 if $QUARTUS else (28 if $VIVADO else 17))" - -VX_CFG_FDIV_LATENCY = "expr: 16 if $VX_CFG_FPU_TYPE_FPNEW else ($fdiv_latency_dsp if $VX_CFG_FPU_TYPE_DSP else $fdiv_latency_std)" -VX_CFG_FSQRT_LATENCY= "expr: 16 if $VX_CFG_FPU_TYPE_FPNEW else ($fsqrt_latency_dsp if $VX_CFG_FPU_TYPE_DSP else $fsqrt_latency_std)" VX_CFG_FNCP_LATENCY = 2 VX_CFG_FCVT_LATENCY = 5 @@ -183,14 +174,13 @@ VX_CFG_FCVT_LATENCY = 5 # differs from FMA, the F64 FMAs get a separate pool of F64-only PEs. VX_CFG_FMA_PE_RATIO = 1 VX_CFG_FMA64_PE_RATIO= 1 -VX_CFG_FDIV_PE_RATIO = 1 -VX_CFG_FSQRT_PE_RATIO= 1 VX_CFG_FCVT_PE_RATIO = 1 VX_CFG_FNCP_PE_RATIO = 1 [tfu] # TFU datapath lanes inside the SFU; the SFU's lanes are serialized onto them. -VX_CFG_NUM_TFU_LANES = 1 +# One lane per 8 FMA lanes, the MUFU:FMA ratio of recent GPUs. +VX_CFG_NUM_TFU_LANES = "expr: max(1, $VX_CFG_NUM_FPU_BLOCKS * $VX_CFG_NUM_FPU_LANES // 8)" [amo] # LR/SC reservation stations per LLC bank; line-indexed in BRAM, eviction yields legal spurious SC failures @@ -448,9 +438,8 @@ VX_CFG_RTU_RECIP_DSP_SEED = 0 # inv_d reciprocal backend: 0=LUT-NR, 1=BRAM s # synth, off for ASIC/sim (mirrors VX_CFG_FPU_USE_DSP). VX_CFG_RTU_USE_DSP = "expr: 1 if ($SYNTHESIS and not $ASIC) else 0" # RTU divide latency. Unlike the flexible-latency soft FMA, VX_fdiv_unit has a FIXED -# depth per backend, so this is BACKEND-keyed like VX_CFG_FMA_LATENCY — NOT FPU-type -# keyed like VX_CFG_FDIV_LATENCY (which would hand the RTL divider the DPI/FPNEW -# model's 15/16 that the RTU never uses). Vendor xil_fdiv=28 on Vivado, altera=15 on +# depth per backend, so this is BACKEND-keyed like VX_CFG_FMA_LATENCY, not keyed +# on the FPU type. Vendor xil_fdiv=28 on Vivado, altera=15 on # Quartus, soft VX_fdiv_unit_rtl F32=17 in sim/ASIC. Matches VX_fdiv_unit's own # USE_VENDOR_IP = USE_DSP(=RTU_USE_DSP) && (VIVADO||QUARTUS). VX_CFG_RTU_FDIV_LATENCY = "expr: 28 if $VIVADO else (15 if $QUARTUS else 17)" diff --git a/ci/testcases/config1.yaml b/ci/testcases/config1.yaml index a5d8bdcf45..d90b1e8822 100644 --- a/ci/testcases/config1.yaml +++ b/ci/testcases/config1.yaml @@ -356,20 +356,6 @@ tests: app: dogfood configs: -DVX_CFG_FCVT_PE_RATIO=2 args: -tftoi -- id: dogfood-7 - via: blackbox - drivers: - - rtlsim - app: dogfood - configs: -DVX_CFG_FDIV_PE_RATIO=2 - args: -tfdiv -- id: dogfood-8 - via: blackbox - drivers: - - rtlsim - app: dogfood - configs: -DVX_CFG_FSQRT_PE_RATIO=2 - args: -tfsqrt - id: dogfood-9 via: blackbox drivers: diff --git a/ci/testcases/core.yaml b/ci/testcases/core.yaml index c60982dc5d..02b83b049d 100644 --- a/ci/testcases/core.yaml +++ b/ci/testcases/core.yaml @@ -136,6 +136,15 @@ tests: # check: model_parity — SimX vs rtlsim, same app/args/configs on both drivers # --------------------------------------------------------------------------- +# FDIV/FSQRT as TFU micro-ops (VX_uop_fdiv): every register aliasing of the +# sequences, on one TFU lane (4 threads) and two (16 threads). +- id: parity-fdiv-tfu + check: model_parity + via: blackbox + app: fdiv_tfu + args: -n1024 + shape: + threads: [4, 16] # ALU/LSU/branch streaming pipeline (~314k cycles on the default 1-core shape). - id: parity-vecadd check: model_parity @@ -436,14 +445,6 @@ tests: app: mixfu args: -n40 -i32 configs: -DVX_CFG_NUM_THREADS=16 -DVX_CFG_NUM_WARPS=16 -DVX_CFG_NUM_ALU_LANES=8 -DVX_CFG_NUM_FPU_LANES=8 -DVX_CFG_NUM_LSU_LANES=8 -DMIXFU_DIV -# Division and square root at a quarter rate, as the GPU profiles set them. -# The F64 FMA rate needs XLEN 64, which the parity gate does not run. -- id: parity-raycast-fdiv4 - check: model_parity - via: blackbox - app: raycast - args: -w16 -h12 - configs: -DVX_CFG_FDIV_PE_RATIO=4 -DVX_CFG_FSQRT_PE_RATIO=4 # Matrix fragment loads and stores: SimX and RTL expand and time them alike, # with the wide loads and stores sharing the expander. - id: parity-ldst-matrix diff --git a/ci/testcases/isa/riscv.yaml b/ci/testcases/isa/riscv.yaml index 4cb148af40..0c799d2c6d 100644 --- a/ci/testcases/isa/riscv.yaml +++ b/ci/testcases/isa/riscv.yaml @@ -64,7 +64,7 @@ tests: xlen: - 64 # The F32 and F64 ISA suites on VX_fpu_std, the FPU the ASIC flow builds: its -# merged VX_fdivsqrt_unit and VX_fma_unit_rtl are not reached by the DSP lanes. +# VX_fma_unit_rtl is not reached by the DSP lanes. - id: isa-32f-std via: make-run drivers: diff --git a/ci/testcases/unittest.yaml b/ci/testcases/unittest.yaml index a4c120d4a8..d436bf4c03 100644 --- a/ci/testcases/unittest.yaml +++ b/ci/testcases/unittest.yaml @@ -85,7 +85,7 @@ tests: via: script run: "make -C tests/unittest/cache_replay_evict run" touches: [sim/simx/mem, tests/unittest/cache_replay_evict] - # FPU arithmetic units (VX_fma/fdiv/fsqrt/fcvt/fdivsqrt): the `hw` lane above only + # FPU arithmetic units (VX_fma/fdiv/fcvt): the `hw` lane above only # builds the unit tests; this lane executes them so a softfloat-divergent # regression actually fails CI (each driver checks bit-exact result+fflags over # millions of vectors across all RISC-V rounding modes, default + lean configs). diff --git a/docs/assets/img/fpu_architecture.svg b/docs/assets/img/fpu_architecture.svg index e062a29fc8..5f9e7246ab 100644 --- a/docs/assets/img/fpu_architecture.svg +++ b/docs/assets/img/fpu_architecture.svg @@ -72,8 +72,8 @@ request switch - core = op_type[3:2] — 00 FMA · 01 DIV / SQRT · 10 CVT · 11 NCP; F2F (1101) is steered to CVT - one request is in exactly one core; the four cores run independently and in parallel + core = op_type — 0xxx FMA · 10xx CVT · 11xx NCP; F2F (1101) is steered to CVT + one request is in exactly one core; the three cores run independently and in parallel STD or DSP selected @@ -99,23 +99,15 @@ separate datapaths: F32 is the hot path latency 8 (F32 build) / 12 (F64 build) - - - DIV / SQRT core - DIV, SQRT - - VX_pe_serializer - STD: one shared · DSP: one per operation - - STD: VX_fdivsqrt_unit - one iterator for both operations - DSP: VX_fdiv_unit + VX_fsqrt_unit - F32 vendor IP, else the soft iterator - - the unit packs and NaN-boxes at the - active format; no result mux - merged datapath: sized for the widest format - latency 17 (F32 build) / 32 (F64 build) + + + no DIV / SQRT core + DIV, SQRT (op_type 01xx) never reach the FPU + VX_uop_sequencer expands each into + TFU micro-ops (reciprocal, reciprocal + square root) plus ordinary FPU operations + (FMUL, F2F, FSGNJX, FSUB) + every FPU core is a fixed-latency pipeline @@ -154,17 +146,15 @@ latency 2 - response arbiter - VX_stream_arb over the four cores → {per-lane result, fflags, has_fflags, tag} + VX_stream_arb over the three cores → {per-lane result, fflags, has_fflags, tag} each core merges fflags over its active lanes; responses leave in completion order, the tag restores the instruction - diff --git a/docs/assets/img/fpu_format_sharing.svg b/docs/assets/img/fpu_format_sharing.svg index 49ba2e6187..6265edbc6a 100644 --- a/docs/assets/img/fpu_format_sharing.svg +++ b/docs/assets/img/fpu_format_sharing.svg @@ -86,31 +86,16 @@ stage. no F32 → F64 → F32 path: no double rounding - + - DIV / SQRT — merged - one iterator at the widest format - - - unpack at the active format - - radix-2 carry-save recurrence - significand left-justified into 53 bits - 28 stages, two steps per stage - - convert, normalize, round once at - the active precision - - - - The iterator dominates the area and the - traffic is rare, so one datapath serves - both formats. - The pipeline is fixed-depth: in an F64 - build an F32 divide also takes 32 cycles. - The exponent is tracked in the active - format's frame, so F32 overflows and - underflows at the F32 boundary. + DIV / SQRT — not in the FPU + expanded by the uop sequencer + + FDIV and FSQRT, F32 and F64, become TFU + micro-ops (reciprocal, reciprocal square + root) plus FMA, CVT and NCP operations, + so the format sharing is that of the + cores they run on. diff --git a/docs/designs/floating_point_unit.md b/docs/designs/floating_point_unit.md index 9df9eed98e..3f97c472a7 100644 --- a/docs/designs/floating_point_unit.md +++ b/docs/designs/floating_point_unit.md @@ -2,7 +2,7 @@ **Scope:** the Vortex floating-point unit for the RISC-V F and D extensions — the pipeline front end, the operation encoding, how single and double -precision share hardware, the four per-operation cores and their pipelines, +precision share hardware, the three per-operation cores and their pipelines, the backends and the vendor-IP selection inside them, configuration, and the SimX model. Covers the RTL ([`hw/rtl/fpu/`](../../hw/rtl/fpu/)) and the SimX model ([`sim/simx/fpu_unit.cpp`](../../sim/simx/fpu_unit.cpp)). @@ -18,25 +18,27 @@ This document is the FPU deep-dive. ## 1. Overview -The FPU is a **fixed set of four per-operation cores** behind a shared +The FPU is a **fixed set of three per-operation cores** behind a shared front end: 1. [`VX_fpu_unit`](../../hw/rtl/fpu/VX_fpu_unit.sv) takes dispatched instructions, parks each instruction's header in a tag store, resolves the rounding mode, and submits the operands to the backend. -2. The **backend** steers the request to one of four cores by operation - class — fused multiply-add, divide/square-root, conversion, and - non-computational. +2. The **backend** steers the request to one of three cores by operation + class — fused multiply-add, conversion, and non-computational. 3. Each core **serializes** the request's lanes over its processing elements and runs them through a fixed-latency pipeline. -4. A response arbiter merges the four cores' results; the front end restores +4. A response arbiter merges the three cores' results; the front end restores the header from the tag, accumulates the exception flags, and commits. -The cores run independently, so a long divide does not block an add. Results +The cores run independently, so a conversion does not block an add. Results leave in completion order — the tag, not the order, identifies the -instruction. A fifth core, an F64-only FMA, exists when the F64 FMA is given +instruction. A fourth core, an F64-only FMA, exists when the F64 FMA is given a rate of its own (§5.2). +Division and square root have no core: the uop sequencer expands them before +they reach the FPU (§7), so every core is a fixed-latency pipeline. + Four backends implement the same port list. Two are native Vortex RTL and are the subject of this document: `VX_fpu_std` (soft RTL) and `VX_fpu_dsp` (soft RTL plus FPGA DSP blocks and vendor IP). The other two are @@ -77,7 +79,8 @@ Operands reach the backend as three `XLEN`-wide values per lane — `rs1`, Decode emits a 4-bit operation, a 2-bit `dst_fmt`, a 2-bit `src_fmt`, a 1-bit `op_mod`, and a 3-bit `frm` ([`VX_gpu_pkg.sv`](../../hw/rtl/VX_gpu_pkg.sv)), -as FPnew does. The top two operation bits **are** the core index. +as FPnew does. The top two operation bits select the core: `00` FMA, `10` +CVT, `11` NCP. `DIV` and `SQRT` (`01`) never reach the FPU (§7). The two format fields name the result and the operands. A float format uses the RISC-V `fmt` code (`INST_FMT_S` = 0, `INST_FMT_D` = 1, `INST_FMT_H` = 2) @@ -96,15 +99,15 @@ variant of an operation is `op_mod`. | `0001` | `MUL` | FMA | float | 0 | rounding mode | | `0010` | `MADD` | FMA | float | subtract the addend | rounding mode | | `0011` | `NMADD` | FMA | float | subtract the addend | rounding mode | -| `0100` | `DIV` | DIV/SQRT | float | 0 | rounding mode | -| `0101` | `SQRT` | DIV/SQRT | float | 0 | rounding mode | +| `0100` | `DIV` | expanded (§7) | float | 0 | rounding mode | +| `0101` | `SQRT` | expanded (§7) | float | 0 | rounding mode | | `1000` / `1001` | `F2I` / `F2U` | CVT | integer width / float | 0 | rounding mode | | `1010` / `1011` | `I2F` / `U2F` | CVT | float / integer width | 0 | rounding mode | | `1100` | `CMP` | NCP | float | 0 | `LE` = 0, `LT` = 1, `EQ` = 2 | | `1101` | `F2F` | **CVT** | destination float / source float | 0 | rounding mode | | `1110` | `MISC` | NCP | float (half for `MVXW`/`MVWX` with Zfhmin) | 0 | `SGNJ`, `SGNJN`, `SGNJX`, `CLASS`, `MVXW`, `MVWX`, `FMIN`, `FMAX` = 0–7 | -`F2F` is the exception to the index rule: its top bits say NCP, and the +`F2F` is the exception to that rule: its top bits say NCP, and the request switch steers it to CVT. It covers every pair of distinct enabled formats; decode accepts a pair only when both formats are enabled (F64 with `VX_CFG_FLEN` = 64, F16 with `VX_CFG_EXT_ZFHMIN_ENABLE`), and the half moves @@ -139,9 +142,8 @@ the operand width. A single-precision value in a 64-bit lane is NaN-boxed — upper 32 bits all ones. Every unit boxes its F32 results on the way out. Every unit also checks the box of an F32 operand and treats an unboxed one as the canonical quiet NaN, as the specification requires: the conversion and -non-computational units in place, the FMA and div/sqrt inputs of the STD and -DSP backends through `fp_unbox_s`/`fp_unbox_fmt` in `VX_fpu_pkg`, and the -FPnew wrapper in front of the PULP divider, which ignores the box. +non-computational units in place, and the FMA inputs of the STD and DSP +backends through `fp_unbox_s`/`fp_unbox_fmt` in `VX_fpu_pkg`. **Double precision requires `XLEN = 64`.** Operand lanes are `XLEN` wide, so there is no place to carry a 64-bit value on a 32-bit build; @@ -159,7 +161,6 @@ merging saves is bounded by what the F32 version would have cost. | class | choice | rationale | |---|---|---| | FMA | **separate** | a 24-bit multiplier is about a fifth of a 53-bit one, so merging saves little while putting the F64 multiply and aligner on every F32 operation — the hot path | -| DIV / SQRT | **merged** | the iterator dominates the area and traffic is rare | | CVT | **merged** | conversion is inherently cross-format; one unpack, align and round tree sized to the widest format | | NCP | **merged** | comparators and muxes only, off the hot path | @@ -217,12 +218,8 @@ of elements that each hold `fma32` and `fma64` (the default). When it differs, the backend adds an F64 FMA core: `dst_fmt` routes F64 FMA-class requests to a pool of `fma64`-only elements behind their own serializer, and the F32 pool drops its `fma64` units. A GPU with a narrow FP64 rate then pays for the F64 -multipliers it has, not one per lane. F64 division, square root and -conversions run on the merged units of their classes, at the -`FDIV`/`FSQRT`/`FCVT` ratios. - -In `VX_fpu_std`, division and square root share one unit and serializer, so -`VX_CFG_FSQRT_PE_RATIO` must equal `VX_CFG_FDIV_PE_RATIO`. +multipliers it has, not one per lane. F64 conversions run on the merged CVT +unit, at the `FCVT` ratio. ### 5.3 The result path @@ -256,13 +253,6 @@ cycle after the result leaves. counts no cycle for it (§11), so the simulation backends time as the synthesized ones. -`VX_fpu_std` differs from `VX_fpu_dsp` in one place. Its division and square -root share a unit, a serializer and a skid register, so under back-pressure a -waiting divide stalls the square roots behind it, and the reverse; -`VX_fpu_dsp` gives each its own buffer and arbitrates between them. Without -back-pressure, and with the two at the same ratio, they time alike. -`VX_fpu_dpi` follows `VX_fpu_dsp`, the FPGA target. - --- ## 6. FMA — `VX_fma_unit` @@ -342,45 +332,21 @@ the same units with both at 0 for its geometry path. ## 7. DIV / SQRT -### 7.1 The iterator - -[`VX_fdivsqrt_unit.sv`](../../hw/rtl/fpu/VX_fdivsqrt_unit.sv) is a -non-restoring radix-2 recurrence in **carry-save** form — no carry -propagation inside the loop — shared by division and square root. It is -sized for the widest enabled format and runs the same recurrence whatever -the operation's format; only the ends are format-aware. - -| stage | cycles | work | -|---|---|---| -| PRE | 1 | unpack at the active format; left-justify the significand into the wide datapath | -| INI | 1 | set up the partial remainder and divisor, or the partial root | -| SRT | 13 (F32 build), 28 (F64 build) | two recurrence steps per stage | -| CONV | 1 | carry-save to binary, sign correction | -| NRM | 1 | normalize, round once at the active precision, pack and box | - -| build | significand | SRT stages | latency | -|---|---|---|---| -| `FLEN = 32` | 24 | 13 | 17 | -| `FLEN = 64` | 53 | 28 | 32 | - -The latency is structural: the unit asserts `LATENCY` equals the sum above. -**In an F64 build an F32 divide takes the full 32 cycles.** The exponent is -tracked in the active format's frame, so an F32 operation rounds once at -24-bit precision and overflows or underflows at the F32 boundary — there is -no double rounding through the wider datapath. - -### 7.2 Single-function specializations - -[`VX_fdiv_unit_rtl.sv`](../../hw/rtl/fpu/VX_fdiv_unit_rtl.sv) and -[`VX_fsqrt_unit_rtl.sv`](../../hw/rtl/fpu/VX_fsqrt_unit_rtl.sv) are the same -recurrence with the other operation's path removed. They exist so that a -consumer needing only one operation does not pay for both, and so that each -can sit behind a backend selector (§9.2). - -| backend | units | request paths | -|---|---|---| -| `VX_fpu_std` | one merged `VX_fdivsqrt_unit` | one serializer; `FDIV_LATENCY` must equal `FSQRT_LATENCY` | -| `VX_fpu_dsp` | `VX_fdiv_unit` and `VX_fsqrt_unit` | an inner switch, two serializers, an inner arbiter; the two latencies are independent | +`FDIV` and `FSQRT` are not FPU operations. Decode still emits `DIV` and +`SQRT`, and the uop sequencer +([`VX_uop_sequencer.sv`](../../hw/rtl/core/VX_uop_sequencer.sv)) expands each +into micro-ops on the TFU (reciprocal, reciprocal square root) and ordinary +FPU operations (`FMUL`, `F2F`, `FSGNJX`, `FSUB`). No FPU backend has a divider +or an iterator, so every FPU core is a fixed-latency pipeline. + +The divider leaf unit stays for the ray-tracing unit: +[`VX_fdiv_unit`](../../hw/rtl/fpu/VX_fdiv_unit.sv) selects the vendor +operator or the soft core (§9.2), and +[`VX_fdiv_unit_rtl.sv`](../../hw/rtl/fpu/VX_fdiv_unit_rtl.sv) is a +non-restoring radix-2 recurrence in carry-save form, sized for the widest +format: 17 cycles for F32, 32 with F64. Its latency is +`VX_CFG_RTU_FDIV_LATENCY` +([`ray_tracing_architecture.md`](ray_tracing_architecture.md)). --- @@ -439,12 +405,11 @@ helpers instantiated per format by the units above. | `FPNEW` | `VX_fpu_fpnew` | explicit override only | `VX_fpu_std` and `VX_fpu_dsp` share the front half of every core. They -differ in the DIV/SQRT structure (§7.2) and in what the leaf units resolve -to. +differ in what the leaf units resolve to. ### 9.2 Leaf selectors and vendor IP -`VX_fma_unit`, `VX_fdiv_unit` and `VX_fsqrt_unit` are **selectors**: each +`VX_fma_unit` and `VX_fdiv_unit` (§7) are **selectors**: each instantiates either the soft core or the FPGA vendor's hardened floating-point operator. @@ -492,24 +457,23 @@ cores and is conformant. | `VX_CFG_NUM_FPU_BLOCKS` | issue width | request paths | | `VX_CFG_NUM_FPU_LANES` | SIMD width | lanes per request | | `VX_CFG_FPU_QUEUE_SIZE` | `2 × SIMD_WIDTH / NUM_FPU_LANES` | tag-store depth | -| `VX_CFG_F{MA,DIV,SQRT,CVT,NCP}_PE_RATIO` | 1 | lanes per processing element | +| `VX_CFG_F{MA,CVT,NCP}_PE_RATIO` | 1 | lanes per processing element | | `VX_CFG_FMA64_PE_RATIO` | 1 | lanes per F64 FMA processing element (§5.2) | | `VX_CFG_FNCP_LATENCY` | 2 | | | `VX_CFG_FCVT_LATENCY` | 5 | plus one at `XLEN = 64`, in every backend | -The arithmetic latencies are derived from the backend and the flow: +The FMA latency is derived from the backend and the flow: -| | `FMA` | `FDIV` | `FSQRT` | -|---|---|---|---| -| STD, F32 build | 8 | 17 | 17 | -| STD, F64 build | 12 | 32 | 32 | -| DSP, simulation, F32 / F64 build | 8 / 12 | 17 / 32 | 17 / 32 | -| DSP, Vivado | 16 | 28 | 28 | -| DSP, Quartus | 4 | 15 | 10 | -| DPI | 8 / 12 | 17 / 32 | 17 / 32 | -| FPNEW | 8 / 12 | 16 | 16 | +| | `FMA` | +|---|---| +| STD, F32 / F64 build | 8 / 12 | +| DSP, simulation, F32 / F64 build | 8 / 12 | +| DSP, Vivado | 16 | +| DSP, Quartus | 4 | +| DPI | 8 / 12 | +| FPNEW | 8 / 12 | -The Vivado and Quartus rows are the vendor operators' fixed latencies. +The Vivado and Quartus rows are the vendor operator's fixed latency. --- @@ -522,7 +486,6 @@ latencies: | operation class | modeled latency | |---|---| | FMA | `VX_CFG_FMA_LATENCY` | -| DIV, SQRT | `VX_CFG_FDIV_LATENCY`, `VX_CFG_FSQRT_LATENCY` | | CVT | `VX_CFG_FCVT_LATENCY`, plus one at `XLEN = 64` | | NCP | `VX_CFG_FNCP_LATENCY` | @@ -557,7 +520,7 @@ little: the tags bound the FPU's results to two per round trip. | what | where | checks | |---|---|---| -| leaf units | `hw/unittest/{fma,fdiv,fsqrt,fcvt,fdivsqrt}_unit`, run by `make -C hw/unittest run-fpu` | bit-exact result and flags against soft-float, over every RISC-V rounding mode, in the default and the area-reduced configurations (`fcvt` includes F32↔F16) | +| leaf units | `hw/unittest/{fma,fdiv,fcvt}_unit`, run by `make -C hw/unittest run-fpu` | bit-exact result and flags against soft-float, over every RISC-V rounding mode, in the default and the area-reduced configurations (`fcvt` includes F32↔F16) | | Zfhmin | `zfhmin` category: the `zfhmin` app on simx and rtlsim, with the DPI, STD and DSP backends | every half conversion bit-exact with flags across all rounding modes (widening exhaustive), `flh`/`fsh`/`fmv` NaN-boxing | | FPU RTL end to end | `riscv` category, `isa-32f-dsp`: `rtlsim` rebuilt with the DSP backend, running `rv32uf` | the soft cores under the full pipeline, F32 | | ISA conformance | `riscv` category, every other lane: `rv32uf`, `rv64uf`, `rv64ud` | decode, the front end and writeback — arithmetic comes from the DPI model | @@ -576,20 +539,14 @@ and it is F32 only: the F64 soft cores are covered by the unit tests alone. Approximate transcendentals (`rcp`, `rsqrt`, `ex2`, `lg2`, `sinpi`, `cospi`, `tanh`) run on the TFU, a processing element of the SFU, not on an FPU core. The SFU's lanes are serialized onto `VX_CFG_NUM_TFU_LANES` datapath lanes -(default 1), so FPU and TFU instructions from different warps execute -concurrently; it ignores `frm` and never writes `fflags`. The FPU's -`fsqrt`/`fdiv` remain the correctly rounded operations. +(default one per 8 FMA lanes), so FPU and TFU instructions from different warps execute +concurrently; it ignores `frm` and never writes `fflags`. `fdiv` and `fsqrt` +also reach the TFU, through the expansion of §7. --- ## 13. Known limitations -- **F64 division and square root on a Vivado DSP build.** The latency keys - resolve to the vendor operators' 28 cycles, but only F32 uses the vendor - operator; the F64 path is the soft iterator, which is structurally 32 - cycles. The iterator's latency assertion is compiled out under synthesis, - so the mismatch is silent. FPGA builds are 32-bit today, where the F64 - path does not exist. - **Vendor operators are not IEEE-conformant** (§9.2): round-to-nearest-even only, flush-to-zero, no inexact flag. - **Double precision on a 32-bit build** (§4.1) is not supported by the diff --git a/docs/designs/ray_tracing_architecture.md b/docs/designs/ray_tracing_architecture.md index 986bc845f9..244e43fc06 100644 --- a/docs/designs/ray_tracing_architecture.md +++ b/docs/designs/ray_tracing_architecture.md @@ -318,8 +318,8 @@ from the tag the box PE presents one stage ahead of its result ### 4.4 The geometry PEs -All FP32, all fixed-latency. The FMAs, divides and compares reuse the ISA FPU's -cores (`VX_fma_unit`, `VX_fdiv_unit`, `VX_fncp_unit`); `VX_CFG_RTU_USE_DSP` maps +All FP32, all fixed-latency. The FMAs, divides and compares use the FPU leaf +units (`VX_fma_unit`, `VX_fdiv_unit`, `VX_fncp_unit`); `VX_CFG_RTU_USE_DSP` maps them onto the hardened vendor FP IP on FPGA synthesis (soft cores in sim/ASIC, subnormals flushed either way), and `VX_CFG_FMA_LATENCY` / `VX_CFG_RTU_FDIV_LATENCY` track the active backend — the barrel scheduler hides diff --git a/hw/dpi/dpi_float.cpp b/hw/dpi/dpi_float.cpp index 5e59e6559b..7759291eef 100644 --- a/hw/dpi/dpi_float.cpp +++ b/hw/dpi/dpi_float.cpp @@ -32,7 +32,6 @@ extern "C" { void dpi_fnmsub(bool enable, int dst_fmt, int64_t a, int64_t b, int64_t c, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags); void dpi_fdiv(bool enable, int dst_fmt, int64_t a, int64_t b, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags); - void dpi_fsqrt(bool enable, int dst_fmt, int64_t a, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags); void dpi_ftoi(bool enable, int dst_fmt, int src_fmt, int64_t a, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags); void dpi_ftou(bool enable, int dst_fmt, int src_fmt, int64_t a, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags); @@ -174,16 +173,6 @@ void dpi_fdiv(bool enable, int dst_fmt, int64_t a, int64_t b, const svBitVecVal* } } -void dpi_fsqrt(bool enable, int dst_fmt, int64_t a, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags) { - if (!enable) - return; - if (dst_fmt) { - *result = rv_fsqrt_d(a, *frm, fflags); - } else { - *result = nan_box(rv_fsqrt_s(check_boxing(a), *frm, fflags)); - } -} - void dpi_ftoi(bool enable, int dst_fmt, int src_fmt, int64_t a, const svBitVecVal* frm, int64_t* result, svBitVecVal* fflags) { if (!enable) return; diff --git a/hw/dpi/dpi_float.vh b/hw/dpi/dpi_float.vh index 0bbb0850be..0a7e41accf 100644 --- a/hw/dpi/dpi_float.vh +++ b/hw/dpi/dpi_float.vh @@ -23,7 +23,6 @@ import "DPI-C" function void dpi_fnmadd(input logic enable, input int dst_fmt, i import "DPI-C" function void dpi_fnmsub(input logic enable, input int dst_fmt, input longint a, input longint b, input longint c, input bit[2:0] frm, output longint result, output bit[4:0] fflags); import "DPI-C" function void dpi_fdiv(input logic enable, input int dst_fmt, input longint a, input longint b, input bit[2:0] frm, output longint result, output bit[4:0] fflags); -import "DPI-C" function void dpi_fsqrt(input logic enable, input int dst_fmt, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags); import "DPI-C" function void dpi_ftoi(input logic enable, input int dst_fmt, input int src_fmt, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags); import "DPI-C" function void dpi_ftou(input logic enable, input int dst_fmt, input int src_fmt, input longint a, input bit[2:0] frm, output longint result, output bit[4:0] fflags); diff --git a/hw/rtl/VX_define.vh b/hw/rtl/VX_define.vh index f314bec363..57e3be6771 100644 --- a/hw/rtl/VX_define.vh +++ b/hw/rtl/VX_define.vh @@ -126,6 +126,13 @@ `endif `endif +// FDIV/FSQRT are TFU micro-ops (VX_uop_fdiv) +`ifdef VX_CFG_EXT_F_ENABLE + `ifndef VX_CFG_EXT_TFU_ENABLE + `error "VX_CFG_EXT_F_ENABLE requires VX_CFG_EXT_TFU_ENABLE" + `endif +`endif + `ifdef VX_CFG_EXT_ZFHMIN_ENABLE `ifndef VX_CFG_EXT_F_ENABLE `error "VX_CFG_EXT_ZFHMIN_ENABLE requires VX_CFG_EXT_F_ENABLE" diff --git a/hw/rtl/VX_gpu_pkg.sv b/hw/rtl/VX_gpu_pkg.sv index 1b3d5d594c..3ed6261c75 100644 --- a/hw/rtl/VX_gpu_pkg.sv +++ b/hw/rtl/VX_gpu_pkg.sv @@ -178,7 +178,9 @@ package VX_gpu_pkg; localparam UOP_GFX = UOP_TCU + `VX_CFG_EXT_TCU_ENABLED; // atomics with .aq/.rl expand into fences around the atomic localparam UOP_AMO = UOP_GFX + `EXT_GFX_ANY_ENABLED; - localparam UOP_MAX = UOP_AMO + `VX_CFG_EXT_A_ENABLED; + // FDIV/FSQRT expand into TFU micro-ops + localparam UOP_FDIV = UOP_AMO + `VX_CFG_EXT_A_ENABLED; + localparam UOP_MAX = UOP_FDIV + `VX_CFG_EXT_F_ENABLED; localparam UOP_CTR_W = 8; localparam CTA_TID_WIDTH = `UP(NW_BITS + NT_BITS); diff --git a/hw/rtl/core/VX_uop_fdiv.sv b/hw/rtl/core/VX_uop_fdiv.sv new file mode 100644 index 0000000000..65e19c265c --- /dev/null +++ b/hw/rtl/core/VX_uop_fdiv.sv @@ -0,0 +1,219 @@ +// Copyright © 2019-2023 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +`include "VX_define.vh" + +// VX_uop_fdiv: FDIV and FSQRT as TFU micro-ops (not IEEE-exact). +// +// Every uop writes only rd, so a source that rd aliases is consumed before rd +// is first overwritten: +// +// FDIV, rd != rs1 : rd = rcp(rs2); rd = rs1 * rd +// FDIV, rd == rs1 != rs2 : rd = rcp(rd); rd = rd * rs2; rd = rcp(rd) +// FDIV, rd == rs1 == rs2 : rd = |rd|; rd = lg2(rd); rd = rd - rd; rd = ex2(rd) +// FSQRT : rd = rsqrt(rs1); rd = rcp(rd) +// +// x/x goes through lg2 so that 0, inf and NaN still give NaN. A double runs +// each TFU step on its single-precision conversion: rd = cvt.s.d(src), +// rd = tfu(rd), rd = cvt.d.s(rd). +module VX_uop_fdiv import VX_gpu_pkg::*; ( + input clk, + input reset, + + input ibuffer_t ibuf_in, + output ibuffer_t ibuf_out, + + input wire start, + input wire advance, + input wire [UOP_CTR_W-1:0] uop_idx, + output wire [UOP_CTR_W-1:0] uop_count +); + `UNUSED_VAR ({clk, reset, start, advance}) + + localparam SEL_NONE = 2'd0; + localparam SEL_RS1 = 2'd1; + localparam SEL_RS2 = 2'd2; + localparam SEL_RD = 2'd3; + + localparam STEP_TFU = 3'd0; // fn + localparam STEP_FMUL = 3'd1; + localparam STEP_FSUB = 3'd2; + localparam STEP_FABS = 3'd3; + localparam STEP_CVT_S = 3'd4; // double -> single + localparam STEP_CVT_D = 3'd5; // single -> double + + wire is_sqrt = (ibuf_in.op_type == INST_OP_BITS'(INST_FPU_SQRT)); +`ifdef VX_CFG_EXT_D_ENABLE + wire is_d = (ibuf_in.op_args.fpu.dst_fmt == INST_FMT_D); +`else + wire is_d = 1'b0; +`endif + wire rd_is_rs1 = (ibuf_in.rd == ibuf_in.rs1); + wire rd_is_rs2 = (ibuf_in.rd == ibuf_in.rs2); + + // uop = {step, fn, sel_a, sel_b} + localparam UOPW = 3 + INST_TFU_BITS + 2 + 2; + localparam SEQ_LEN = 8; + + function automatic logic [UOPW-1:0] U(input logic [2:0] step, + input logic [INST_TFU_BITS-1:0] fn, + input logic [1:0] a, + input logic [1:0] b); + return {step, fn, a, b}; + endfunction + + localparam logic [INST_TFU_BITS-1:0] X = '0; + + // The sequences, as constants so the uop lookup is a shallow ROM. A + // double's TFU step becomes cvt.s.d, tfu, cvt.d.s. + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_SQRT = { + {6{U(STEP_TFU, X, SEL_NONE, SEL_NONE)}}, + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_RSQRT, SEL_RS1, SEL_NONE)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_DIV = { + {6{U(STEP_TFU, X, SEL_NONE, SEL_NONE)}}, + U(STEP_FMUL, X, SEL_RS1, SEL_RD), + U(STEP_TFU, INST_TFU_RCP, SEL_RS2, SEL_NONE)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_DIV_RD_RS1 = { + {5{U(STEP_TFU, X, SEL_NONE, SEL_NONE)}}, + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE), + U(STEP_FMUL, X, SEL_RD, SEL_RS2), + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_DIV_SELF = { + {4{U(STEP_TFU, X, SEL_NONE, SEL_NONE)}}, + U(STEP_TFU, INST_TFU_EX2, SEL_RD, SEL_NONE), + U(STEP_FSUB, X, SEL_RD, SEL_RD), + U(STEP_TFU, INST_TFU_LG2, SEL_RD, SEL_NONE), + U(STEP_FABS, X, SEL_RD, SEL_RD)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_SQRT_D = { + {2{U(STEP_TFU, X, SEL_NONE, SEL_NONE)}}, + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RD, SEL_NONE), + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_RSQRT, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RS1, SEL_NONE)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_DIV_D = { + {4{U(STEP_TFU, X, SEL_NONE, SEL_NONE)}}, + U(STEP_FMUL, X, SEL_RS1, SEL_RD), + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RS2, SEL_NONE)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_DIV_RD_RS1_D = { + U(STEP_TFU, X, SEL_NONE, SEL_NONE), + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RD, SEL_NONE), + U(STEP_FMUL, X, SEL_RD, SEL_RS2), + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_RCP, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RD, SEL_NONE)}; + localparam logic [SEQ_LEN-1:0][UOPW-1:0] SEQ_DIV_SELF_D = { + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_EX2, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RD, SEL_NONE), + U(STEP_FSUB, X, SEL_RD, SEL_RD), + U(STEP_CVT_D, X, SEL_RD, SEL_NONE), + U(STEP_TFU, INST_TFU_LG2, SEL_RD, SEL_NONE), + U(STEP_CVT_S, X, SEL_RD, SEL_NONE), + U(STEP_FABS, X, SEL_RD, SEL_RD)}; + + logic [SEQ_LEN-1:0][UOPW-1:0] seq; + logic [UOP_CTR_W-1:0] count; + + always_comb begin + case ({is_d, is_sqrt, rd_is_rs1, rd_is_rs2}) + 4'b0100, 4'b0101, 4'b0110, 4'b0111: begin seq = SEQ_SQRT; count = 2; end + 4'b0000, 4'b0001: begin seq = SEQ_DIV; count = 2; end + 4'b0010: begin seq = SEQ_DIV_RD_RS1; count = 3; end + 4'b0011: begin seq = SEQ_DIV_SELF; count = 4; end + 4'b1100, 4'b1101, 4'b1110, 4'b1111: begin seq = SEQ_SQRT_D; count = 6; end + 4'b1000, 4'b1001: begin seq = SEQ_DIV_D; count = 4; end + 4'b1010: begin seq = SEQ_DIV_RD_RS1_D; count = 7; end + default: begin seq = SEQ_DIV_SELF_D; count = 8; end + endcase + end + + assign uop_count = count; + + wire [2:0] step; + wire [INST_TFU_BITS-1:0] fn; + wire [1:0] sel_a, sel_b; + assign {step, fn, sel_a, sel_b} = seq[uop_idx[2:0]]; + `UNUSED_VAR (uop_idx[UOP_CTR_W-1:3]) + + function automatic logic [NUM_REGS_BITS-1:0] sel_reg(input logic [1:0] sel, + input logic [NUM_REGS_BITS-1:0] rs1, + input logic [NUM_REGS_BITS-1:0] rs2, + input logic [NUM_REGS_BITS-1:0] rd); + case (sel) + SEL_RS1: return rs1; + SEL_RS2: return rs2; + SEL_RD: return rd; + default: return '0; + endcase + endfunction + + wire [INST_FMT_BITS-1:0] fmt = ibuf_in.op_args.fpu.dst_fmt; + + ibuffer_t ibuf_r; + + always_comb begin + ibuf_r = ibuf_in; + ibuf_r.rs1 = sel_reg(sel_a, ibuf_in.rs1, ibuf_in.rs2, ibuf_in.rd); + ibuf_r.rs2 = sel_reg(sel_b, ibuf_in.rs1, ibuf_in.rs2, ibuf_in.rd); + ibuf_r.rs3 = '0; + ibuf_r.used_rs = NUM_SRC_OPDS'({1'b0, (sel_b != SEL_NONE), 1'b1}); + ibuf_r.fu_lock = 1'b1; + ibuf_r.fu_unlock = 1'b1; + ibuf_r.op_args = '0; + if (step == STEP_TFU) begin + ibuf_r.ex_type = EX_SFU; + ibuf_r.op_type = INST_OP_BITS'(INST_SFU_TFU); + ibuf_r.op_args.tfu.fn = fn; + ibuf_r.rd_xregs = '0; + ibuf_r.wr_xregs = '0; + end else begin + ibuf_r.ex_type = EX_FPU; + ibuf_r.op_args.fpu.frm = ibuf_in.op_args.fpu.frm; + ibuf_r.op_args.fpu.src_fmt = fmt; + ibuf_r.op_args.fpu.dst_fmt = fmt; + case (step) + STEP_FMUL: ibuf_r.op_type = INST_OP_BITS'(INST_FPU_MUL); + STEP_FSUB: begin + ibuf_r.op_type = INST_OP_BITS'(INST_FPU_ADD); + ibuf_r.op_args.fpu.op_mod = 1'b1; + end + STEP_FABS: begin + ibuf_r.op_type = INST_OP_BITS'(INST_FPU_MISC); + ibuf_r.op_args.fpu.frm = INST_FRM_BITS'(2); // FSGNJX + ibuf_r.rd_xregs = '0; + ibuf_r.wr_xregs = '0; + end + STEP_CVT_S: begin + ibuf_r.op_type = INST_OP_BITS'(INST_FPU_F2F); + ibuf_r.op_args.fpu.src_fmt = INST_FMT_D; + ibuf_r.op_args.fpu.dst_fmt = INST_FMT_S; + end + default: begin // STEP_CVT_D + ibuf_r.op_type = INST_OP_BITS'(INST_FPU_F2F); + ibuf_r.op_args.fpu.src_fmt = INST_FMT_S; + ibuf_r.op_args.fpu.dst_fmt = INST_FMT_D; + end + endcase + end + end + + assign ibuf_out = ibuf_r; + +endmodule diff --git a/hw/rtl/core/VX_uop_sequencer.sv b/hw/rtl/core/VX_uop_sequencer.sv index c6f92fd869..bc40582395 100644 --- a/hw/rtl/core/VX_uop_sequencer.sv +++ b/hw/rtl/core/VX_uop_sequencer.sv @@ -212,6 +212,26 @@ module VX_uop_sequencer import ); `endif +`ifdef VX_CFG_EXT_F_ENABLE + // ------------------------------------------------------------------ + // FDIV/FSQRT uop expander: TFU reciprocal/rsqrt plus FPU ops + // ------------------------------------------------------------------ + assign uop_in_valid[UOP_FDIV] = (uop_in_data.ex_type == EX_FPU) + && (uop_in_data.op_type == INST_OP_BITS'(INST_FPU_DIV) + || uop_in_data.op_type == INST_OP_BITS'(INST_FPU_SQRT)); + + VX_uop_fdiv uop_fdiv ( + .clk (clk), + .reset (reset), + .ibuf_in (uop_in_data), + .start (uop_in_start[UOP_FDIV]), + .advance (uop_in_next[UOP_FDIV]), + .uop_idx (uop_ctr), + .ibuf_out (uop_out_data[UOP_FDIV]), + .uop_count (uop_out_count[UOP_FDIV]) + ); +`endif + wire uop_hold = is_uop_input && ~uop_active; assign output_if.valid = uop_active || (input_if.valid && ~uop_hold); diff --git a/hw/rtl/fpu/VX_fdiv_unit.sv b/hw/rtl/fpu/VX_fdiv_unit.sv index 842b000474..a1608c01bb 100644 --- a/hw/rtl/fpu/VX_fdiv_unit.sv +++ b/hw/rtl/fpu/VX_fdiv_unit.sv @@ -58,7 +58,7 @@ module VX_fdiv_unit import VX_gpu_pkg::*, VX_fpu_pkg::*; #( localparam USE_VENDOR_IP = (USE_DSP != 0) && (SUBNORM_ENABLE == 0) && IS_F32 && (VENDOR_OK != 0); `STATIC_ASSERT(!USE_VENDOR_IP || (LATENCY == 28), - ("vendor xil_fdiv latency is 28; set VX_CFG_FDIV_LATENCY=28")) + ("vendor xil_fdiv latency is 28")) if (USE_VENDOR_IP) begin : g_vendor // The vendor IP rounds round-to-nearest-even only (frm is ignored). diff --git a/hw/rtl/fpu/VX_fdiv_unit_rtl.sv b/hw/rtl/fpu/VX_fdiv_unit_rtl.sv index cc8ff6cfd5..331d26c2cd 100644 --- a/hw/rtl/fpu/VX_fdiv_unit_rtl.sv +++ b/hw/rtl/fpu/VX_fdiv_unit_rtl.sv @@ -13,8 +13,7 @@ // Single-lane pipelined FDIV (pure RTL, single-function). // -// Specialization of VX_fdivsqrt_unit with the SQRT path removed: the same -// non-restoring radix-2 carry-save NR recurrence, sized for the widest +// A non-restoring radix-2 carry-save NR recurrence, sized for the widest // supported format (SUPER = F64 when FLEN>=64, else F32). Only the front // (unpack) and back (extract/round/pack) stages are format-aware: // - operands are unpacked at their active format (F32/F64) and the diff --git a/hw/rtl/fpu/VX_fdivsqrt_unit.sv b/hw/rtl/fpu/VX_fdivsqrt_unit.sv deleted file mode 100644 index 6942e38e54..0000000000 --- a/hw/rtl/fpu/VX_fdivsqrt_unit.sv +++ /dev/null @@ -1,669 +0,0 @@ -// Copyright © 2019-2023 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Merged single-lane pipelined fused FDIV + FSQRT. -// -// Merged-format design: the iterative SRT datapath is sized for the widest -// supported format (SUPER = F64 when FLEN>=64, else F32) and runs the SAME -// carry-save NR recurrence regardless of the operation's format. Only the -// front (unpack) and back (extract/round/pack) stages are format-aware: -// - operands are unpacked at their active format (F32/F64) and the -// normalized significand is LEFT-justified into the SUPER significand, -// - the exponent is tracked in the ACTIVE format's frame (bias/range), so -// an F32 op rounds ONCE at 24-bit precision (no double rounding) and -// under/overflows at the F32 boundary. -// -// Pipeline: 1 PRE + 1 INI + NR_STAGES SRT + 1 CONV + 1 NRM. -// SUPER=F32: NR_STAGES=13 -> LATENCY 17 -// SUPER=F64: NR_STAGES=28 -> LATENCY 32 -// -// DIV: Non-restoring radix-2 NR. W, D scaled x2^SCALE_DIV; NR invariant |W|<=D. -// SQRT: NR radix-2 with W and S (partial root) scaled x2^SCALE_SQRT. -// SCALE_SQRT is chosen by SUPER_SIG parity so the per-stage ULP schedule -// lands on the same endpoints (step-B ULP last = 2 for NRO=0, 1 for NRO=1) -// for both formats, keeping the CONV correction format-independent. - -`include "VX_fpu_define.vh" - -module VX_fdivsqrt_unit import VX_gpu_pkg::*, VX_fpu_pkg::*; #( - parameter LATENCY = 17, - parameter FLEN = 32 -) ( - input wire clk, - input wire reset, - input wire enable, - input wire mask, - - input wire [INST_FMT_BITS-1:0] fmt, - input wire [INST_FRM_BITS-1:0] frm, - - input wire [FLEN-1:0] dataa, // dividend (DIV) or radicand (SQRT) - input wire [FLEN-1:0] datab, // divisor (DIV only; ignored for SQRT) - input wire is_sqrt, - - output wire [FLEN-1:0] result, - output wire [`FP_FLAGS_BITS-1:0] fflags -); - localparam HAS_D = (FLEN >= 64); - wire is_d = HAS_D && (fmt == INST_FMT_D); - `UNUSED_VAR (fmt) - - // ---- SUPER (widest) format the datapath is built for ---- - localparam SUPER_MAN = HAS_D ? 52 : 23; - localparam SUPER_SIG = SUPER_MAN + 1; // 24 / 53 - - localparam PRE_LATENCY = 1; - localparam INI_LATENCY = 1; - localparam CONV_LATENCY = 1; - localparam NRM_LATENCY = 1; - - localparam SCALE_DIV = 5; - localparam SCALE_SQRT = (SUPER_SIG % 2 == 1) ? 5 : 4; // even SIG->4 (F32), odd->5 (F64) - - localparam W_BITS = SUPER_SIG + SCALE_DIV + 1; // 30 / 59 - localparam CS_BITS = W_BITS + 1; // 31 / 60: carry-save component width - localparam NR_BITS = (SUPER_SIG + 2) + ((SUPER_SIG + 2) % 2); // even: 26 / 56 - localparam NR_STAGES = NR_BITS / 2; // 13 / 28 - localparam EXP_W = HAS_D ? 14 : 10; // signed exponent working width - - // SQRT scaled-S leading-bit position: S in [2^SQRT_LEAD, 2^(SQRT_LEAD+1)) - localparam SQRT_LEAD = SUPER_SIG + SCALE_SQRT - 1; // 27 / 57 - - `STATIC_ASSERT(LATENCY == (PRE_LATENCY + INI_LATENCY + NR_STAGES + CONV_LATENCY + NRM_LATENCY), ("VX_fdivsqrt_unit: LATENCY must be %0d, got %0d", PRE_LATENCY+INI_LATENCY+NR_STAGES+CONV_LATENCY+NRM_LATENCY, LATENCY)) - - reg [LATENCY-1:0] mask_pipe; - always @(posedge clk) begin - if (reset) begin - mask_pipe <= '0; - end else if (enable) begin - mask_pipe <= {mask_pipe[LATENCY-2:0], mask}; - end - end - wire valid_ini = mask_pipe[PRE_LATENCY-1]; - wire valid_conv = mask_pipe[PRE_LATENCY+INI_LATENCY+NR_STAGES-1]; - wire valid_nrm = mask_pipe[PRE_LATENCY+INI_LATENCY+NR_STAGES+CONV_LATENCY-1]; - - // ---- SRT state vector layout ---- - localparam EXC_LO = 0; - localparam FRM_LO = EXC_LO + 5; - localparam SGN_LO = FRM_LO + INST_FRM_BITS; - localparam EXP_LO = SGN_LO + 1; - localparam QI_LO = EXP_LO + EXP_W; - localparam QB_LO = QI_LO + 1; - localparam DS_LO = QB_LO + NR_BITS; // D (DIV) or S (SQRT) - localparam W_LO = DS_LO + W_BITS; // Ws (CS_BITS wide) - localparam WC_LO = W_LO + CS_BITS; // Wc (CS_BITS wide) - localparam NRO_LO = WC_LO + CS_BITS; // nr_offset - localparam SQ_LO = NRO_LO + 1; // is_sqrt - localparam ISD_LO = SQ_LO + 1; // is_double - localparam STAGE_W = ISD_LO + 1; - - // ========================================================================= - // Active-format unpack: classify, LZC-normalize the active significand, then - // LEFT-justify it into the SUPER significand. Exponent stays in active frame. - // ========================================================================= - wire [EXP_W-1:0] BIAS = is_d ? EXP_W'(1023) : EXP_W'(127); - - // -- raw active field extraction -- - wire s_a = is_d ? dataa[FLEN-1] : dataa[31]; - wire s_b = is_d ? datab[FLEN-1] : datab[31]; - - // active exponent / mantissa selectors and classification - wire ea_allones, eb_allones, ea_zero, eb_zero, ma_nz, mb_nz, ma_q, mb_q; - wire [SUPER_SIG-1:0] siga_ljn, sigb_ljn; // normalized, left-justified into SUPER_SIG - wire signed [EXP_W-1:0] exp_a, exp_b; - - // Build {classify, normalize, left-justify} for one operand at a chosen format. - // Implemented inline per format and muxed by is_d (when HAS_D). - // --- F32 view --- - wire f32a_z = (dataa[30:23] == 8'd0) && (dataa[22:0] == 23'd0); - wire f32a_sub= (dataa[30:23] == 8'd0) && (dataa[22:0] != 23'd0); - wire f32b_z = (datab[30:23] == 8'd0) && (datab[22:0] == 23'd0); - wire f32b_sub= (datab[30:23] == 8'd0) && (datab[22:0] != 23'd0); - wire [23:0] f32a_sig = {~(f32a_z | f32a_sub), dataa[22:0]}; - wire [23:0] f32b_sig = {~(f32b_z | f32b_sub), datab[22:0]}; - wire [4:0] f32a_lzc, f32b_lzc; - wire f32a_lvld, f32b_lvld; - VX_lzc #(.N(24)) lz_f32a (.data_in(f32a_sig), .data_out(f32a_lzc), .valid_out(f32a_lvld)); - VX_lzc #(.N(24)) lz_f32b (.data_in(f32b_sig), .data_out(f32b_lzc), .valid_out(f32b_lvld)); - wire [23:0] f32a_norm = f32a_sub ? (f32a_sig << f32a_lzc) : f32a_sig; - wire [23:0] f32b_norm = f32b_sub ? (f32b_sig << f32b_lzc) : f32b_sig; - wire signed [EXP_W-1:0] f32a_exp = f32a_sub ? (EXP_W'(1) - EXP_W'(f32a_lzc)) : f32a_z ? '0 : EXP_W'(dataa[30:23]); - wire signed [EXP_W-1:0] f32b_exp = f32b_sub ? (EXP_W'(1) - EXP_W'(f32b_lzc)) : f32b_z ? '0 : EXP_W'(datab[30:23]); - `UNUSED_VAR ({f32a_lvld, f32b_lvld}) - - if (HAS_D) begin : g_unpack_d - wire f64a_z = (dataa[62:52] == 11'd0) && (dataa[51:0] == 52'd0); - wire f64a_sub= (dataa[62:52] == 11'd0) && (dataa[51:0] != 52'd0); - wire f64b_z = (datab[62:52] == 11'd0) && (datab[51:0] == 52'd0); - wire f64b_sub= (datab[62:52] == 11'd0) && (datab[51:0] != 52'd0); - wire [52:0] f64a_sig = {~(f64a_z | f64a_sub), dataa[51:0]}; - wire [52:0] f64b_sig = {~(f64b_z | f64b_sub), datab[51:0]}; - wire [5:0] f64a_lzc, f64b_lzc; - wire f64a_lvld, f64b_lvld; - VX_lzc #(.N(53)) lz_f64a (.data_in(f64a_sig), .data_out(f64a_lzc), .valid_out(f64a_lvld)); - VX_lzc #(.N(53)) lz_f64b (.data_in(f64b_sig), .data_out(f64b_lzc), .valid_out(f64b_lvld)); - wire [52:0] f64a_norm = f64a_sub ? (f64a_sig << f64a_lzc) : f64a_sig; - wire [52:0] f64b_norm = f64b_sub ? (f64b_sig << f64b_lzc) : f64b_sig; - wire signed [EXP_W-1:0] f64a_exp = f64a_sub ? (EXP_W'(1) - EXP_W'(f64a_lzc)) : f64a_z ? '0 : EXP_W'(dataa[62:52]); - wire signed [EXP_W-1:0] f64b_exp = f64b_sub ? (EXP_W'(1) - EXP_W'(f64b_lzc)) : f64b_z ? '0 : EXP_W'(datab[62:52]); - `UNUSED_VAR ({f64a_lvld, f64b_lvld}) - - assign ea_allones = is_d ? (&dataa[62:52]) : (&dataa[30:23]); - assign eb_allones = is_d ? (&datab[62:52]) : (&datab[30:23]); - assign ea_zero = is_d ? f64a_z : f32a_z; - assign eb_zero = is_d ? f64b_z : f32b_z; - assign ma_nz = is_d ? (|dataa[51:0]) : (|dataa[22:0]); - assign mb_nz = is_d ? (|datab[51:0]) : (|datab[22:0]); - assign ma_q = is_d ? dataa[51] : dataa[22]; // quiet bit (msb of man) - assign mb_q = is_d ? datab[51] : datab[22]; - assign siga_ljn = is_d ? f64a_norm : {f32a_norm, {(SUPER_SIG-24){1'b0}}}; - assign sigb_ljn = is_d ? f64b_norm : {f32b_norm, {(SUPER_SIG-24){1'b0}}}; - assign exp_a = is_d ? f64a_exp : f32a_exp; - assign exp_b = is_d ? f64b_exp : f32b_exp; - end else begin : g_unpack_s - assign ea_allones = &dataa[30:23]; - assign eb_allones = &datab[30:23]; - assign ea_zero = f32a_z; - assign eb_zero = f32b_z; - assign ma_nz = |dataa[22:0]; - assign mb_nz = |datab[22:0]; - assign ma_q = dataa[22]; - assign mb_q = datab[22]; - assign siga_ljn = f32a_norm; - assign sigb_ljn = f32b_norm; - assign exp_a = f32a_exp; - assign exp_b = f32b_exp; - end - - // classification flags (active format) - wire nan_a = ea_allones & ma_nz; - wire nan_b = eb_allones & mb_nz; - wire inf_a = ea_allones & ~ma_nz; - wire inf_b = eb_allones & ~mb_nz; - wire zero_a = ea_zero & ~ma_nz; - wire zero_b = eb_zero & ~mb_nz; - wire snan_a = nan_a & ~ma_q; - wire snan_b = nan_b & ~mb_q; - - // ========================================================================= - // PRE: DIV path - // ========================================================================= - wire sign_r0_div = s_a ^ s_b; - wire signed [EXP_W-1:0] exp_r0_div = exp_a - exp_b + BIAS; - - wire nv0_div = snan_a | snan_b | (zero_a & zero_b) | (inf_a & inf_b); - wire dz0_div = zero_b & ~nan_a & ~nan_b & ~zero_a & ~inf_a; // DZ only for finite x/0 - wire rnan_div = nan_a | nan_b | nv0_div; - wire rinf_div = (inf_a | zero_b) & ~rnan_div; - wire rzro_div = (zero_a | inf_b) & ~rnan_div; - wire [4:0] exc0_div = {rnan_div, rinf_div, rzro_div, dz0_div, nv0_div}; - - // ========================================================================= - // PRE: SQRT path - // ========================================================================= - wire signed [EXP_W-1:0] exp_r0_sqrt = ($signed(exp_a) + BIAS) >>> 1; - - wire nv0_sq = snan_a | (s_a & ~nan_a & ~zero_a); - wire rnan_sq = nan_a | nv0_sq; - wire rinf_sq = inf_a & ~rnan_sq; - wire rzro_sq = zero_a & ~rnan_sq; - wire [4:0] exc0_sq = {rnan_sq, rinf_sq, rzro_sq, 1'b0, nv0_sq}; - wire sign_r0_sq = zero_a & s_a; // sqrt(-0) = -0; other valid: + - - // Biased exponent even <=> unbiased odd (both F32/F64 biases are odd) -> scale sig x2. - // Biased-exponent LSB of the radicand (active format); FLEN=32 has only F32. - wire ea_lsb_sq = exp_a[0]; // normalized-exponent parity (correct for subnormals) - wire is_scale2_sq = ~ea_lsb_sq; - // Q_0=1.5 pre-commit when scaling and sig >= 1.125 (top 3 mantissa bits nonzero). - wire [2:0] top3_man = siga_ljn[SUPER_SIG-2 -: 3]; - wire nr_offset0_sq = is_scale2_sq & (|top3_man); - - // man (fraction) as integer at SUPER width - wire [SUPER_MAN-1:0] man_a = siga_ljn[SUPER_MAN-1:0]; - - // SQRT W_0 / S_0 (see header; derived symbolically; reduce to the F32 constants at SUPER=F32) - wire [W_BITS-1:0] manSC1 = W_BITS'(man_a) << (SCALE_SQRT + 1); // man * 2^(SC+1) - - wire [W_BITS-1:0] S0_sq = nr_offset0_sq ? W_BITS'(3) << (SQRT_LEAD - 1) // 3*2^(LEAD-1) - : W_BITS'(1) << SQRT_LEAD; // 2^LEAD - - wire [W_BITS-1:0] W0_sq = !is_scale2_sq ? (W_BITS'(man_a) << SCALE_SQRT) // case1: man*2^SC - : !nr_offset0_sq ? ((W_BITS'(1) << SQRT_LEAD) + manSC1) // case2: 2^LEAD + man*2^(SC+1) - : (manSC1 - (W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 3))); // case3 - - // ========================================================================= - // PRE pipeline register (cycle 1): normalize + exc. - // ========================================================================= - localparam INI_SIG_LO = 0; - localparam INI_SIGB_LO = INI_SIG_LO + SUPER_SIG; - localparam INI_EXPD_LO = INI_SIGB_LO + SUPER_SIG; - localparam INI_EXPS_LO = INI_EXPD_LO + EXP_W; - localparam INI_SGND_LO = INI_EXPS_LO + EXP_W; - localparam INI_SGNS_LO = INI_SGND_LO + 1; - localparam INI_NRO_LO = INI_SGNS_LO + 1; - localparam INI_W0SQ_LO = INI_NRO_LO + 1; - localparam INI_S0SQ_LO = INI_W0SQ_LO + W_BITS; - localparam INI_EXCDV_LO = INI_S0SQ_LO + W_BITS; - localparam INI_EXCSQ_LO = INI_EXCDV_LO + 5; - localparam INI_FRM_LO = INI_EXCSQ_LO + 5; - localparam INI_SQRT_LO = INI_FRM_LO + INST_FRM_BITS; - localparam INI_ISD_LO = INI_SQRT_LO + 1; - localparam INI_W = INI_ISD_LO + 1; - - wire [INI_W-1:0] ini_in; - assign ini_in[INI_SIG_LO +: SUPER_SIG] = siga_ljn; - assign ini_in[INI_SIGB_LO +: SUPER_SIG] = sigb_ljn; - assign ini_in[INI_EXPD_LO +: EXP_W] = exp_r0_div; - assign ini_in[INI_EXPS_LO +: EXP_W] = exp_r0_sqrt; - assign ini_in[INI_SGND_LO] = sign_r0_div; - assign ini_in[INI_SGNS_LO] = sign_r0_sq; - assign ini_in[INI_NRO_LO] = nr_offset0_sq; - assign ini_in[INI_W0SQ_LO +: W_BITS] = W0_sq; - assign ini_in[INI_S0SQ_LO +: W_BITS] = S0_sq; - assign ini_in[INI_EXCDV_LO +: 5] = exc0_div; - assign ini_in[INI_EXCSQ_LO +: 5] = exc0_sq; - assign ini_in[INI_FRM_LO +: INST_FRM_BITS] = frm; - assign ini_in[INI_SQRT_LO] = is_sqrt; - assign ini_in[INI_ISD_LO] = is_d; - - wire [INI_W-1:0] ini_out; - VX_pipe_register #(.DATAW (INI_W), .DEPTH (1)) pre_reg ( - .clk (clk), .reset (reset), .enable (enable && mask), - .data_in (ini_in), .data_out (ini_out) - ); - - // ========================================================================= - // INI pipeline register (cycle 2): DIV initial W0, pack SRT state. - // ========================================================================= - wire [SUPER_SIG-1:0] i_sig_a = ini_out[INI_SIG_LO +: SUPER_SIG]; - wire [SUPER_SIG-1:0] i_sig_b = ini_out[INI_SIGB_LO +: SUPER_SIG]; - wire [EXP_W-1:0] i_exp_div = ini_out[INI_EXPD_LO +: EXP_W]; - wire [EXP_W-1:0] i_exp_sq = ini_out[INI_EXPS_LO +: EXP_W]; - wire i_sgn_div = ini_out[INI_SGND_LO]; - wire i_sgn_sq = ini_out[INI_SGNS_LO]; - wire i_nro_sq = ini_out[INI_NRO_LO]; - wire [W_BITS-1:0] i_W0_sq = ini_out[INI_W0SQ_LO +: W_BITS]; - wire [W_BITS-1:0] i_S0_sq = ini_out[INI_S0SQ_LO +: W_BITS]; - wire [4:0] i_exc_div = ini_out[INI_EXCDV_LO +: 5]; - wire [4:0] i_exc_sq = ini_out[INI_EXCSQ_LO +: 5]; - wire [INST_FRM_BITS-1:0] i_frm = ini_out[INI_FRM_LO +: INST_FRM_BITS]; - wire i_sqrt = ini_out[INI_SQRT_LO]; - wire i_isd = ini_out[INI_ISD_LO]; - - wire [W_BITS-1:0] i_D0_div = {1'b0, i_sig_b, {SCALE_DIV{1'b0}}}; - wire i_q_int0_div = (i_sig_a >= i_sig_b); - wire [SUPER_SIG-1:0] i_pre_diff = i_sig_a - (i_q_int0_div ? i_sig_b : {SUPER_SIG{1'b0}}); - wire [W_BITS-1:0] i_W0_div = {1'b0, i_pre_diff, {SCALE_DIV{1'b0}}}; - - wire [STAGE_W-1:0] srt_stage [0:NR_STAGES]; - wire [STAGE_W-1:0] pre_in; - - assign pre_in[W_LO +: CS_BITS] = i_sqrt ? {1'b0, i_W0_sq} : {1'b0, i_W0_div}; - assign pre_in[WC_LO +: CS_BITS] = '0; - assign pre_in[DS_LO +: W_BITS] = i_sqrt ? i_S0_sq : i_D0_div; - assign pre_in[QB_LO +: NR_BITS] = {NR_BITS{1'b0}}; - assign pre_in[QI_LO] = i_sqrt ? 1'b1 : i_q_int0_div; - assign pre_in[EXP_LO +: EXP_W] = i_sqrt ? i_exp_sq : i_exp_div; - assign pre_in[SGN_LO] = i_sqrt ? i_sgn_sq : i_sgn_div; - assign pre_in[FRM_LO +: INST_FRM_BITS] = i_frm; - assign pre_in[EXC_LO +: 5] = i_sqrt ? i_exc_sq : i_exc_div; - assign pre_in[NRO_LO] = i_sqrt ? i_nro_sq : 1'b0; - assign pre_in[SQ_LO] = i_sqrt; - assign pre_in[ISD_LO] = i_isd; - - VX_pipe_register #(.DATAW (STAGE_W), .DEPTH (1)) ini_reg ( - .clk (clk), .reset (reset), .enable (enable && valid_ini), - .data_in (pre_in), .data_out (srt_stage[0]) - ); - - // ========================================================================= - // SRT stages 1..NR_STAGES (two NR steps each, carry-save W). Format-independent. - // ========================================================================= - for (genvar k = 0; k < NR_STAGES; k++) begin : g_srt - localparam [W_BITS-1:0] ULP_A_NRO0 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 2 - 2*k); - localparam [W_BITS-1:0] ULP_B_NRO0 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 3 - 2*k); - localparam [W_BITS-1:0] ULP_A_NRO1 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 3 - 2*k); - localparam [W_BITS-1:0] ULP_B_NRO1 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 4 - 2*k); - - wire [CS_BITS-1:0] Ws_in = srt_stage[k][W_LO +: CS_BITS]; - wire [CS_BITS-1:0] Wc_in = srt_stage[k][WC_LO +: CS_BITS]; - wire [W_BITS-1:0] DS_in = srt_stage[k][DS_LO +: W_BITS]; - wire [NR_BITS-1:0] qb_in = srt_stage[k][QB_LO +: NR_BITS]; - wire qi_in = srt_stage[k][QI_LO]; - wire [EXP_W-1:0] exp_in = srt_stage[k][EXP_LO +: EXP_W]; - wire sgn_in = srt_stage[k][SGN_LO]; - wire [INST_FRM_BITS-1:0] frm_in = srt_stage[k][FRM_LO +: INST_FRM_BITS]; - wire [4:0] exc_in = srt_stage[k][EXC_LO +: 5]; - wire nro_in = srt_stage[k][NRO_LO]; - wire sq_in = srt_stage[k][SQ_LO]; - wire isd_in = srt_stage[k][ISD_LO]; - - wire [W_BITS-1:0] ulp_a = nro_in ? ULP_A_NRO1 : ULP_A_NRO0; - wire [W_BITS-1:0] ulp_b = nro_in ? ULP_B_NRO1 : ULP_B_NRO0; - - // --- Step A --- - wire [W_BITS-1:0] D_S_a30 = sq_in ? (nro_in ? DS_in : {DS_in[W_BITS-2:0], 1'b0}) : DS_in; - wire [W_BITS-1:0] D_ulp_a = sq_in ? (nro_in ? (ulp_a >> 1) : ulp_a) : '0; - wire [W_BITS-1:0] val_a_add = D_S_a30 - D_ulp_a; - wire [W_BITS-1:0] val_a_neg = D_S_a30 + D_ulp_a; - wire [W_BITS-1:0] DS_a_plus = DS_in + ulp_a; - wire [W_BITS-1:0] DS_a_minus = DS_in - ulp_a; - - wire [CS_BITS:0] W_a_sum = {1'b0, Ws_in} + {1'b0, Wc_in}; - wire q_a = ~W_a_sum[CS_BITS-1]; - - wire [CS_BITS-1:0] X_a = q_a ? {1'b1, ~val_a_neg} : {1'b0, val_a_add}; - wire [CS_BITS-1:0] W2s_a = {Ws_in[CS_BITS-2:0], q_a}; - wire [CS_BITS-1:0] W2c_a = {Wc_in[CS_BITS-2:0], 1'b0}; - wire [CS_BITS-1:0] Ws_a = W2s_a ^ W2c_a ^ X_a; - wire [W_BITS-1:0] Wca_raw = (W2s_a[W_BITS-1:0] & W2c_a[W_BITS-1:0]) | (W2c_a[W_BITS-1:0] & X_a[W_BITS-1:0]) | (W2s_a[W_BITS-1:0] & X_a[W_BITS-1:0]); - wire [CS_BITS-1:0] Wc_a = {Wca_raw, 1'b0}; - - wire [W_BITS-1:0] DS_a = sq_in ? (q_a ? DS_a_plus : DS_a_minus) : DS_in; - - // --- Step B --- - wire [W_BITS-1:0] D_S_b30 = sq_in ? (nro_in ? DS_a : {DS_a[W_BITS-2:0], 1'b0}) : DS_a; - wire [W_BITS-1:0] D_ulp_b = sq_in ? (nro_in ? (ulp_b >> 1) : ulp_b) : '0; - wire [W_BITS-1:0] val_b_add = D_S_b30 - D_ulp_b; - wire [W_BITS-1:0] val_b_neg = D_S_b30 + D_ulp_b; - wire [W_BITS-1:0] DS_b_plus = DS_a + ulp_b; - wire [W_BITS-1:0] DS_b_minus = DS_a - ulp_b; - - wire [CS_BITS:0] W_b_sum = {1'b0, Ws_a} + {1'b0, Wc_a}; - wire q_b = ~W_b_sum[CS_BITS-1]; - - wire [CS_BITS-1:0] X_b = q_b ? {1'b1, ~val_b_neg} : {1'b0, val_b_add}; - wire [CS_BITS-1:0] W2s_b = {Ws_a[CS_BITS-2:0], q_b}; - wire [CS_BITS-1:0] W2c_b = {Wc_a[CS_BITS-2:0], 1'b0}; - wire [CS_BITS-1:0] Ws_b = W2s_b ^ W2c_b ^ X_b; - wire [W_BITS-1:0] Wcb_raw = (W2s_b[W_BITS-1:0] & W2c_b[W_BITS-1:0]) | (W2c_b[W_BITS-1:0] & X_b[W_BITS-1:0]) | (W2s_b[W_BITS-1:0] & X_b[W_BITS-1:0]); - wire [CS_BITS-1:0] Wc_b = {Wcb_raw, 1'b0}; - - wire [W_BITS-1:0] DS_b = sq_in ? (q_b ? DS_b_plus : DS_b_minus) : DS_a; - - `UNUSED_VAR (qb_in[NR_BITS-1:NR_BITS-2]) - wire [NR_BITS-1:0] qb_new = {qb_in[NR_BITS-3:0], q_a, q_b}; - - wire [STAGE_W-1:0] s_out; - assign s_out[W_LO +: CS_BITS] = Ws_b; - assign s_out[WC_LO +: CS_BITS] = Wc_b; - assign s_out[DS_LO +: W_BITS] = DS_b; - assign s_out[QB_LO +: NR_BITS] = qb_new; - assign s_out[QI_LO] = qi_in; - assign s_out[EXP_LO +: EXP_W] = exp_in; - assign s_out[SGN_LO] = sgn_in; - assign s_out[FRM_LO +: INST_FRM_BITS] = frm_in; - assign s_out[EXC_LO +: 5] = exc_in; - assign s_out[NRO_LO] = nro_in; - assign s_out[SQ_LO] = sq_in; - assign s_out[ISD_LO] = isd_in; - - VX_pipe_register #(.DATAW (STAGE_W), .DEPTH (1)) srt_reg ( - .clk (clk), .reset (reset), - .enable (enable && mask_pipe[PRE_LATENCY+INI_LATENCY-1+k]), - .data_in (s_out), .data_out (srt_stage[k+1]) - ); - end - - // ========================================================================= - // CONV (combinational after srt_stage[NR_STAGES]) - // ========================================================================= - wire [CS_BITS-1:0] Ws_cv = srt_stage[NR_STAGES][W_LO +: CS_BITS]; - wire [CS_BITS-1:0] Wc_cv = srt_stage[NR_STAGES][WC_LO +: CS_BITS]; - wire [W_BITS-1:0] DS_cv = srt_stage[NR_STAGES][DS_LO +: W_BITS]; - wire [NR_BITS-1:0] qb_cv = srt_stage[NR_STAGES][QB_LO +: NR_BITS]; - wire qi_cv = srt_stage[NR_STAGES][QI_LO]; - wire [EXP_W-1:0] exp_cv = srt_stage[NR_STAGES][EXP_LO +: EXP_W]; - wire sgn_cv = srt_stage[NR_STAGES][SGN_LO]; - wire [INST_FRM_BITS-1:0] frm_cv = srt_stage[NR_STAGES][FRM_LO +: INST_FRM_BITS]; - wire [4:0] exc_cv = srt_stage[NR_STAGES][EXC_LO +: 5]; - wire nro_cv = srt_stage[NR_STAGES][NRO_LO]; - wire sq_cv = srt_stage[NR_STAGES][SQ_LO]; - wire isd_cv = srt_stage[NR_STAGES][ISD_LO]; - - wire signed [CS_BITS:0] W_cv_sum = $signed(Ws_cv) + $signed(Wc_cv); - wire [CS_BITS-1:0] W_cv_cs = W_cv_sum[CS_BITS-1:0]; - wire [W_BITS-1:0] W_cv = W_cv_cs[W_BITS-1:0]; - `UNUSED_VAR (W_cv_sum[CS_BITS]) - - // ---- DIV CONV ---- - wire [NR_BITS:0] Q_frac = {qb_cv, 1'b0} - {1'b0, {NR_BITS{1'b1}}}; - `UNUSED_VAR (Q_frac[NR_BITS]) - wire [NR_BITS:0] Q_tot = {qi_cv, Q_frac[NR_BITS-1:0]}; - - wire W_neg_div = W_cv[W_BITS-1]; - wire [NR_BITS:0] Q_corr = W_neg_div ? (Q_tot - 1'b1) : Q_tot; - wire [W_BITS-1:0] W_corr_div = W_neg_div ? (W_cv + DS_cv) : W_cv; - wire sticky_div_r = (W_corr_div != '0); - - // Q_rnd: NR_BITS+1 bits, integer bit at MSB (NR_BITS) when qi=1. - wire [NR_BITS:0] Q_rnd = qi_cv ? Q_corr : {Q_corr[NR_BITS-1:0], 1'b0}; - wire signed [EXP_W-1:0] exp_res_div = $signed(exp_cv) - (qi_cv ? '0 : EXP_W'(1)); - - // Extract man/G/R/S from the top of Q_rnd at the active precision. - // Built for both formats and muxed (avoids a variable part-select). - wire [SUPER_SIG-1:0] man_div_d = Q_rnd[NR_BITS -: SUPER_SIG]; - wire guard_div_d= Q_rnd[NR_BITS - SUPER_SIG]; - wire round_div_d= Q_rnd[NR_BITS - SUPER_SIG - 1]; - wire sticky_div_d=(|Q_rnd[NR_BITS - SUPER_SIG - 2 : 0]) | sticky_div_r; - - wire [23:0] man_div_s = Q_rnd[NR_BITS -: 24]; - wire guard_div_s = Q_rnd[NR_BITS - 24]; - wire round_div_s = Q_rnd[NR_BITS - 25]; - wire sticky_div_s = (|Q_rnd[NR_BITS - 26 : 0]) | sticky_div_r; - - // ---- SQRT CONV ---- - // The final SQRT remainder spans the full carry-save width: with SCALE_SQRT - // equal to SCALE_DIV (F64 super format) it reaches -(2^(W_BITS-1)) - 2. - wire W_neg_sq = W_cv_cs[CS_BITS-1]; - wire [W_BITS-1:0] ulp_last = nro_cv ? W_BITS'(1) : W_BITS'(2); - wire [W_BITS-1:0] S_corr = W_neg_sq ? (DS_cv - ulp_last) : DS_cv; - - wire [CS_BITS-1:0] W_D_sq = nro_cv ? ({1'b0, DS_cv} - {1'b0, ulp_last}) - : ({DS_cv, 1'b0} - {1'b0, ulp_last}); - wire [CS_BITS-1:0] W_corr_sq = W_neg_sq ? (W_cv_cs + W_D_sq) : W_cv_cs; - wire sticky_sq_w = (W_corr_sq != '0); - - // S_corr leading bit at SQRT_LEAD; man=[LEAD -: act_sig], guard=[LEAD-act_sig], etc. - wire [SUPER_SIG-1:0] man_sq_d = S_corr[SQRT_LEAD -: SUPER_SIG]; - wire guard_sq_d = S_corr[SQRT_LEAD - SUPER_SIG]; - wire round_sq_d = S_corr[SQRT_LEAD - SUPER_SIG - 1]; - wire sticky_sq_d= (|S_corr[SQRT_LEAD - SUPER_SIG - 2 : 0]) | sticky_sq_w; - - wire [23:0] man_sq_s = S_corr[SQRT_LEAD -: 24]; - wire guard_sq_s = S_corr[SQRT_LEAD - 24]; - wire round_sq_s = S_corr[SQRT_LEAD - 25]; - wire sticky_sq_s = (|S_corr[SQRT_LEAD - 26 : 0]) | sticky_sq_w; - `UNUSED_VAR (S_corr[W_BITS-1:SQRT_LEAD+1]) - - wire signed [EXP_W-1:0] exp_res_sq = $signed(exp_cv); - - // ---- Unified CONV output (mux format then op) ---- - wire act_s = (HAS_D && !isd_cv); // active F32 extraction - wire [SUPER_SIG-1:0] man_div = act_s ? SUPER_SIG'(man_div_s) : man_div_d; - wire [SUPER_SIG-1:0] man_sq = act_s ? SUPER_SIG'(man_sq_s) : man_sq_d; - wire guard_div = act_s ? guard_div_s : guard_div_d; - wire round_div = act_s ? round_div_s : round_div_d; - wire sticky_div = act_s ? sticky_div_s : sticky_div_d; - wire guard_sq = act_s ? guard_sq_s : guard_sq_d; - wire round_sq = act_s ? round_sq_s : round_sq_d; - wire sticky_sq = act_s ? sticky_sq_s : sticky_sq_d; - - wire [SUPER_SIG-1:0] man_cv_out = sq_cv ? man_sq : man_div; - wire guard_cv_out = sq_cv ? guard_sq : guard_div; - wire round_cv_out = sq_cv ? round_sq : round_div; - wire sticky_cv_out= sq_cv ? sticky_sq : sticky_div; - wire signed [EXP_W-1:0] exp_res = sq_cv ? exp_res_sq : exp_res_div; - - // NRM decisions that depend on the exponent alone are made here, so the NRM - // stage starts at the shifter. Subnormal: when the biased exponent is <= 0, - // the significand is shifted right by 1-exp and rounded once at the - // subnormal LSB (dsh=0 is the normal path). Overflow is tested for both - // values of the rounding carry, and NRM picks one. - localparam SH_W = `CLOG2(SUPER_SIG + 2) + 1; - wire cv_special = exc_cv[4] | exc_cv[3] | exc_cv[2]; // NaN, inf, zero - wire result_sub_cv = ($signed(exp_res) <= 0) & ~cv_special; - wire signed [EXP_W-1:0] denorm_amt = result_sub_cv ? (EXP_W'(1) - exp_res) : '0; - wire huge_denorm_cv = result_sub_cv & ($signed(denorm_amt) >= $signed(EXP_W'(SUPER_SIG + 1))); - wire [SH_W-1:0] dsh_cv = huge_denorm_cv ? SH_W'(SUPER_SIG) : SH_W'(denorm_amt); - wire signed [EXP_W-1:0] exp_res_p1 = exp_res + EXP_W'(1); - wire [EXP_W-1:0] cv_allones = (HAS_D && isd_cv) ? EXP_W'(2047) : EXP_W'(255); - wire of_nocarry_cv = ($signed(exp_res) >= $signed(cv_allones)); - wire of_carry_cv = ($signed(exp_res_p1) >= $signed(cv_allones)); - - // ========================================================================= - // CONV pipeline register - // ========================================================================= - localparam CONV_W = SUPER_SIG + 1 + 1 + 1 + EXP_W + 1 + INST_FRM_BITS + 5 + 1 - + SH_W + 1 + 1 + EXP_W + 1 + 1; - - wire [CONV_W-1:0] conv_in = {man_cv_out, guard_cv_out, round_cv_out, sticky_cv_out, - exp_res, sgn_cv, frm_cv, exc_cv, isd_cv, - dsh_cv, result_sub_cv, huge_denorm_cv, exp_res_p1, - of_nocarry_cv, of_carry_cv}; - wire [CONV_W-1:0] conv_out; - VX_pipe_register #(.DATAW (CONV_W), .DEPTH (1)) conv_reg ( - .clk (clk), .reset (reset), .enable (enable && valid_conv), - .data_in (conv_in), .data_out (conv_out) - ); - - // ========================================================================= - // NRM stage: round, overflow/underflow, pack at active format. - // ========================================================================= - wire [SUPER_SIG-1:0] s_man; - wire s_guard, s_round, s_sticky; - wire [EXP_W-1:0] s_exp_bits; - wire s_sign; - wire [INST_FRM_BITS-1:0] s_frm; - wire [4:0] s_exc; - wire s_isd; - wire [SH_W-1:0] dsh; - wire result_sub, huge_denorm; - wire [EXP_W-1:0] s_exp_p1; - wire of_nocarry, of_carry; - - assign {s_man, s_guard, s_round, s_sticky, s_exp_bits, s_sign, s_frm, s_exc, s_isd, - dsh, result_sub, huge_denorm, s_exp_p1, of_nocarry, of_carry} = conv_out; - - wire act_d = HAS_D ? s_isd : 1'b0; // double result - - wire is_nan = s_exc[4]; - wire is_inf = s_exc[3]; - wire is_zero = s_exc[2]; - wire dz_flag = s_exc[1]; - wire nv_flag = s_exc[0]; - - // Bits below the guard position: [dsh-2:0], none when dsh <= 1. - wire [SUPER_SIG-1:0] below_gmsk; - for (genvar i = 0; i < SUPER_SIG; ++i) begin : g_below_gmsk - assign below_gmsk[i] = (SH_W'(i + 1) < dsh); - end - wire [SUPER_SIG-1:0] sub_man = s_man >> dsh; - wire sub_guard = (dsh == 0) ? s_guard : huge_denorm ? 1'b0 : s_man[dsh - 1]; - wire sub_sticky = (dsh == 0) ? (s_round | s_sticky) - : ((huge_denorm ? (|s_man) : (|(s_man & below_gmsk))) | s_guard | s_round | s_sticky); - - wire [SUPER_SIG-1:0] abs_rounded; - wire round_sign, exact_zero; - VX_fp_rounding #(.DAT_WIDTH(SUPER_SIG)) u_rnd ( - .abs_value_i (sub_man), - .sign_i (s_sign), - .round_sticky_bits_i ({sub_guard, sub_sticky}), - .rnd_mode_i (s_frm), - .effective_subtraction_i(1'b0), - .abs_rounded_o (abs_rounded), - .sign_o (round_sign), - .exact_zero_o (exact_zero), - `UNUSED_PIN (round_up_o) - ); - - wire sub_carry = abs_rounded[SUPER_MAN]; - wire norm_carry; - if (HAS_D) begin : g_rcarry_d - wire rc_d = (abs_rounded == '0) & (sub_man != '0); // 53-bit wrap (F64) - wire rc_s = abs_rounded[24]; // carry out of 24-bit man (F32) - assign norm_carry = act_d ? rc_d : rc_s; - end else begin : g_rcarry_s - assign norm_carry = (abs_rounded == '0) & (sub_man != '0); // 24-bit wrap - end - wire [EXP_W-1:0] fin_exp = result_sub ? (sub_carry ? EXP_W'(1) : '0) - : (norm_carry ? s_exp_p1 : s_exp_bits); - `UNUSED_VAR (fin_exp) - `UNUSED_VAR (act_d) - - wire [SUPER_MAN-1:0] fin_man_d = abs_rounded[SUPER_MAN-1:0]; - wire [22:0] fin_man_s = abs_rounded[22:0]; - - // A subnormal result's exponent is 0 or 1, never an overflow. - wire of_flag = ~result_sub & (norm_carry ? of_carry : of_nocarry) & ~is_nan & ~is_inf; - wire nx_flag = (sub_guard | sub_sticky) & ~is_nan & ~is_inf & ~is_zero; - wire uf_flag = result_sub & nx_flag; - // Overflow result: max-normal vs inf per rounding mode/sign (IEEE). - wire ovf_to_max = (s_frm == INST_FRM_RTZ) - | (s_frm == INST_FRM_RDN & ~round_sign) - | (s_frm == INST_FRM_RUP & round_sign); - - // F32 pack (always present) - wire [31:0] nan_s = 32'h7FC00000; - wire [31:0] inf_s = {round_sign, 8'hFF, 23'd0}; - wire [31:0] maxnorm_s = {round_sign, 8'hFE, 23'h7FFFFF}; - wire [31:0] zero_s = {round_sign, 31'd0}; - wire [31:0] norm_s = {round_sign, fin_exp[7:0], fin_man_s}; - - reg [31:0] res_s; - always @(*) begin - if (is_nan) res_s = nan_s; - else if (is_inf) res_s = inf_s; - else if (of_flag) res_s = ovf_to_max ? maxnorm_s : inf_s; - else if (is_zero | exact_zero) res_s = zero_s; - else res_s = norm_s; // includes subnormals - end - - // Pack into FLEN: F64 fills the width; F32 is NaN-boxed (upper bits ones). - // The F64 packing is only elaborated when HAS_D (fin_exp/fin_man are wide enough). - wire [FLEN-1:0] nrm_result; - if (HAS_D) begin : g_pack_d - wire [63:0] nan_d = 64'h7FF8000000000000; - wire [63:0] inf_d = {round_sign, 11'h7FF, 52'd0}; - wire [63:0] maxnorm_d = {round_sign, 11'h7FE, 52'hFFFFFFFFFFFFF}; - wire [63:0] zero_d = {round_sign, 63'd0}; - wire [63:0] norm_d = {round_sign, fin_exp[10:0], fin_man_d}; - reg [63:0] res_d; - always @(*) begin - if (is_nan) res_d = nan_d; - else if (is_inf) res_d = inf_d; - else if (of_flag) res_d = ovf_to_max ? maxnorm_d : inf_d; - else if (is_zero | exact_zero) res_d = zero_d; - else res_d = norm_d; // includes subnormals - end - assign nrm_result = act_d ? FLEN'(res_d) : {{(FLEN-32){1'b1}}, res_s}; - end else begin : g_pack_s - assign nrm_result = FLEN'(res_s); - `UNUSED_VAR (fin_man_d) - end - - fflags_t nrm_fflags; - assign nrm_fflags.NV = nv_flag; - assign nrm_fflags.DZ = dz_flag; - assign nrm_fflags.OF = of_flag; - assign nrm_fflags.UF = uf_flag; - assign nrm_fflags.NX = nx_flag | of_flag | uf_flag; - - VX_pipe_register #(.DATAW (FLEN + `FP_FLAGS_BITS), .DEPTH (1)) nrm_reg ( - .clk (clk), .reset (reset), .enable (enable && valid_nrm), - .data_in ({nrm_result, nrm_fflags}), - .data_out ({result, fflags}) - ); - -endmodule diff --git a/hw/rtl/fpu/VX_fpu_dpi.sv b/hw/rtl/fpu/VX_fpu_dpi.sv index 5048179000..d992be9510 100644 --- a/hw/rtl/fpu/VX_fpu_dpi.sv +++ b/hw/rtl/fpu/VX_fpu_dpi.sv @@ -59,8 +59,6 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( localparam NUM_PES_FMA64 = `UP(NUM_LANES / `VX_CFG_FMA64_PE_RATIO); localparam BATCHES_FMA = NUM_LANES / NUM_PES_FMA; localparam BATCHES_FMA64 = NUM_LANES / NUM_PES_FMA64; - localparam BATCHES_DIV = NUM_LANES / `UP(NUM_LANES / `VX_CFG_FDIV_PE_RATIO); - localparam BATCHES_SQRT = NUM_LANES / `UP(NUM_LANES / `VX_CFG_FSQRT_PE_RATIO); localparam BATCHES_CVT = NUM_LANES / `UP(NUM_LANES / `VX_CFG_FCVT_PE_RATIO); localparam BATCHES_NCP = NUM_LANES / `UP(NUM_LANES / `VX_CFG_FNCP_PE_RATIO); localparam CVT_LATENCY = (`VX_CFG_XLEN == 64) ? `VX_CFG_FCVT_LATENCY + 1 : `VX_CFG_FCVT_LATENCY; @@ -68,11 +66,10 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( localparam FMA64_SPLIT = (`VX_CFG_FLEN >= 64) && (NUM_PES_FMA64 != NUM_PES_FMA); localparam FPU_FMA = 0; - localparam FPU_DIVSQRT = 1; - localparam FPU_CVT = 2; - localparam FPU_NCP = 3; - localparam FPU_FMA64 = 4; - localparam NUM_FPC = FMA64_SPLIT ? 5 : 4; + localparam FPU_CVT = 1; + localparam FPU_NCP = 2; + localparam FPU_FMA64 = 3; + localparam NUM_FPC = FMA64_SPLIT ? 4 : 3; localparam FPC_BITS = `LOG2UP(NUM_FPC); localparam FMA_PIPES = FMA64_SPLIT ? 2 : 1; @@ -87,14 +84,6 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( wire [NUM_FPC-1:0] per_core_has_fflags; fflags_t [NUM_FPC-1:0] per_core_fflags; - wire div_ready_in, sqrt_ready_in; - wire [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] div_result, sqrt_result; - wire [TAG_WIDTH-1:0] div_tag_out, sqrt_tag_out; - wire div_ready_out, sqrt_ready_out; - wire div_valid_out, sqrt_valid_out; - wire div_has_fflags, sqrt_has_fflags; - fflags_t div_fflags, sqrt_fflags; - reg [FPC_BITS-1:0] core_select; // The models run only for an operation the pipeline has issued: at the first @@ -104,7 +93,7 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( wire dpi_en = ~reset; reg is_fadd, is_fsub, is_fmul, is_fmadd, is_fmsub, is_fnmadd, is_fnmsub; - reg is_div, is_fcmp, is_itof, is_utof, is_ftoi, is_ftou, is_f2f; + reg is_fcmp, is_itof, is_utof, is_ftoi, is_ftou, is_f2f; reg [NUM_LANES-1:0][63:0] operands [3]; @@ -132,7 +121,6 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( is_fmsub = 0; is_fnmadd = 0; is_fnmsub = 0; - is_div = 0; is_fcmp = 0; is_itof = 0; is_utof = 0; @@ -145,8 +133,6 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( INST_FPU_MADD: begin core_select = fma_select; is_fmadd = ~op_mod; is_fmsub = op_mod; end INST_FPU_NMADD: begin core_select = fma_select; is_fnmadd = ~op_mod; is_fnmsub = op_mod; end INST_FPU_MUL: begin core_select = fma_select; is_fmul = 1; end - INST_FPU_DIV: begin core_select = FPU_DIVSQRT; is_div = 1; end - INST_FPU_SQRT: begin core_select = FPU_DIVSQRT; end INST_FPU_CMP: begin core_select = FPU_NCP; is_fcmp = 1; end INST_FPU_F2I: begin core_select = FPU_CVT; is_ftoi = 1; end INST_FPU_F2U: begin core_select = FPU_CVT; is_ftou = 1; end @@ -270,142 +256,6 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( end - if (1) begin : g_fdiv - - reg [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] result_fdiv_r; - reg [NUM_LANES-1:0][63:0] result_fdiv; - fflags_t [NUM_LANES-1:0] fflags_fdiv; - - wire fdiv_valid = (valid_in && core_select == FPU_DIVSQRT) && is_div; - wire pipe_valid_out, pipe_ready_out; - wire [PIPE_DATAW-1:0] pipe_data_out; - wire fdiv_ready = pipe_ready_out || ~pipe_valid_out; - wire fdiv_last; - - if (BATCHES_DIV > 1) begin : g_batch - reg [`LOG2UP(BATCHES_DIV)-1:0] batch_idx; - always @(posedge clk) begin - if (reset) begin - batch_idx <= '0; - end else if (fdiv_valid && fdiv_ready) begin - batch_idx <= fdiv_last ? '0 : (batch_idx + 1'b1); - end - end - assign fdiv_last = (batch_idx == `LOG2UP(BATCHES_DIV)'(BATCHES_DIV-1)); - end else begin : g_no_batch - assign fdiv_last = 1'b1; - end - - wire fdiv_fire = fdiv_valid && fdiv_ready && fdiv_last; - - always @(*) begin - for (integer i = 0; i < NUM_LANES; ++i) begin - dpi_fdiv (fdiv_fire && dpi_en, int'(is_d), operands[0][i], operands[1][i], frm, result_fdiv[i], fflags_fdiv[i]); - result_fdiv_r[i] = result_fdiv[i][`VX_CFG_XLEN-1:0]; - end - end - - fflags_t fflags_merged; - `FPU_MERGE_FFLAGS(fflags_merged, fflags_fdiv, mask_in, NUM_LANES); - - VX_shift_register #( - .DATAW (1 + PIPE_DATAW), - .DEPTH (`VX_CFG_FDIV_LATENCY), - .RESETW (1) - ) shift_reg ( - .clk (clk), - .reset (reset), - .enable (fdiv_ready), - .data_in ({fdiv_valid && fdiv_last, tag_in, result_fdiv_r, fflags_merged}), - .data_out ({pipe_valid_out, pipe_data_out}) - ); - - VX_bypass_buffer #( - .DATAW (PIPE_DATAW) - ) out_buf ( - .clk (clk), - .reset (reset), - .valid_in (pipe_valid_out), - .ready_in (pipe_ready_out), - .data_in (pipe_data_out), - .data_out ({div_tag_out, div_result, div_fflags}), - .valid_out (div_valid_out), - .ready_out (div_ready_out) - ); - - assign div_has_fflags = 1; - assign div_ready_in = fdiv_ready && fdiv_last; - - end - - if (1) begin : g_fsqrt - - reg [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] result_fsqrt_r; - reg [NUM_LANES-1:0][63:0] result_fsqrt; - fflags_t [NUM_LANES-1:0] fflags_fsqrt; - - wire fsqrt_valid = (valid_in && core_select == FPU_DIVSQRT) && ~is_div; - wire pipe_valid_out, pipe_ready_out; - wire [PIPE_DATAW-1:0] pipe_data_out; - wire fsqrt_ready = pipe_ready_out || ~pipe_valid_out; - wire fsqrt_last; - - if (BATCHES_SQRT > 1) begin : g_batch - reg [`LOG2UP(BATCHES_SQRT)-1:0] batch_idx; - always @(posedge clk) begin - if (reset) begin - batch_idx <= '0; - end else if (fsqrt_valid && fsqrt_ready) begin - batch_idx <= fsqrt_last ? '0 : (batch_idx + 1'b1); - end - end - assign fsqrt_last = (batch_idx == `LOG2UP(BATCHES_SQRT)'(BATCHES_SQRT-1)); - end else begin : g_no_batch - assign fsqrt_last = 1'b1; - end - - wire fsqrt_fire = fsqrt_valid && fsqrt_ready && fsqrt_last; - - always @(*) begin - for (integer i = 0; i < NUM_LANES; ++i) begin - dpi_fsqrt (fsqrt_fire && dpi_en, int'(is_d), operands[0][i], frm, result_fsqrt[i], fflags_fsqrt[i]); - result_fsqrt_r[i] = result_fsqrt[i][`VX_CFG_XLEN-1:0]; - end - end - - fflags_t fflags_merged; - `FPU_MERGE_FFLAGS(fflags_merged, fflags_fsqrt, mask_in, NUM_LANES); - - VX_shift_register #( - .DATAW (1 + PIPE_DATAW), - .DEPTH (`VX_CFG_FSQRT_LATENCY), - .RESETW (1) - ) shift_reg ( - .clk (clk), - .reset (reset), - .enable (fsqrt_ready), - .data_in ({fsqrt_valid && fsqrt_last, tag_in, result_fsqrt_r, fflags_merged}), - .data_out ({pipe_valid_out, pipe_data_out}) - ); - - VX_bypass_buffer #( - .DATAW (PIPE_DATAW) - ) out_buf ( - .clk (clk), - .reset (reset), - .valid_in (pipe_valid_out), - .ready_in (pipe_ready_out), - .data_in (pipe_data_out), - .data_out ({sqrt_tag_out, sqrt_result, sqrt_fflags}), - .valid_out (sqrt_valid_out), - .ready_out (sqrt_ready_out) - ); - - assign sqrt_has_fflags = 1; - assign sqrt_ready_in = fsqrt_ready && fsqrt_last; - - end - if (1) begin : g_fcvt reg [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] result_fcvt; @@ -625,28 +475,6 @@ module VX_fpu_dpi import VX_gpu_pkg::*, VX_fpu_pkg::*; #( /////////////////////////////////////////////////////////////////////////// - assign per_core_ready_in[FPU_DIVSQRT] = is_div ? div_ready_in : sqrt_ready_in; - - VX_stream_arb #( - .NUM_INPUTS (2), - .DATAW (RSP_DATAW), - .ARBITER ("P"), - .OUT_BUF (0) - ) div_sqrt_arb ( - .clk (clk), - .reset (reset), - .valid_in ({sqrt_valid_out, div_valid_out}), - .ready_in ({sqrt_ready_out, div_ready_out}), - .data_in ({{sqrt_result, sqrt_has_fflags, sqrt_fflags, sqrt_tag_out}, - {div_result, div_has_fflags, div_fflags, div_tag_out}}), - .data_out ({per_core_result[FPU_DIVSQRT], per_core_has_fflags[FPU_DIVSQRT], per_core_fflags[FPU_DIVSQRT], per_core_tag_out[FPU_DIVSQRT]}), - .valid_out (per_core_valid_out[FPU_DIVSQRT]), - .ready_out (per_core_ready_out[FPU_DIVSQRT]), - `UNUSED_PIN (sel_out) - ); - - /////////////////////////////////////////////////////////////////////////// - wire [NUM_FPC-1:0][RSP_DATAW-1:0] per_core_data_out; for (genvar i = 0; i < NUM_FPC; ++i) begin : g_per_core_data_out diff --git a/hw/rtl/fpu/VX_fpu_dsp.sv b/hw/rtl/fpu/VX_fpu_dsp.sv index aa87aca5d2..2d6ef8e95f 100644 --- a/hw/rtl/fpu/VX_fpu_dsp.sv +++ b/hw/rtl/fpu/VX_fpu_dsp.sv @@ -51,8 +51,6 @@ module VX_fpu_dsp import VX_gpu_pkg::*, VX_fpu_pkg::*; #( ); localparam NUM_PES_FMA = `UP(NUM_LANES / `VX_CFG_FMA_PE_RATIO); localparam NUM_PES_FMA64 = `UP(NUM_LANES / `VX_CFG_FMA64_PE_RATIO); - localparam NUM_PES_DIV = `UP(NUM_LANES / `VX_CFG_FDIV_PE_RATIO); - localparam NUM_PES_SQRT = `UP(NUM_LANES / `VX_CFG_FSQRT_PE_RATIO); localparam NUM_PES_CVT = `UP(NUM_LANES / `VX_CFG_FCVT_PE_RATIO); localparam NUM_PES_NCP = `UP(NUM_LANES / `VX_CFG_FNCP_PE_RATIO); localparam CVT_LATENCY = (`VX_CFG_XLEN == 64) ? `VX_CFG_FCVT_LATENCY + 1 : `VX_CFG_FCVT_LATENCY; @@ -63,15 +61,14 @@ module VX_fpu_dsp import VX_gpu_pkg::*, VX_fpu_pkg::*; #( localparam FMA_HAS_F64 = (`VX_CFG_FLEN >= 64) && !FMA64_SPLIT; localparam FPU_FMA = 0; - localparam FPU_DIVSQRT = 1; - localparam FPU_CVT = 2; - localparam FPU_NCP = 3; - localparam FPU_FMA64 = 4; - localparam NUM_FPCORES = FMA64_SPLIT ? 5 : 4; + localparam FPU_CVT = 1; + localparam FPU_NCP = 2; + localparam FPU_FMA64 = 3; + localparam NUM_FPCORES = FMA64_SPLIT ? 4 : 3; localparam FPCORES_BITS = `LOG2UP(NUM_FPCORES); // The vendor FP IP (Xilinx/Altera) is flush-to-zero, so on those FPGA flows the - // FMA/DIV/SQRT units run FTZ to select it; every other flow (ASIC, simulation) + // FMA units run FTZ to select it; every other flow (ASIC, simulation) // keeps full IEEE subnormals in the soft core. `ifdef VIVADO localparam FPU_SNORM = 0; @@ -107,9 +104,13 @@ module VX_fpu_dsp import VX_gpu_pkg::*, VX_fpu_pkg::*; #( wire [NUM_FPCORES-1:0] per_core_ready_out; // Decode fpu core type - wire is_fma64 = FMA64_SPLIT && (op_type[3:2] == 2'(FPU_FMA)) && (dst_fmt == INST_FMT_D); - wire [FPCORES_BITS-1:0] core_select = (op_type == INST_FPU_F2F) ? FPCORES_BITS'(FPU_CVT) - : (is_fma64 ? FPCORES_BITS'(FPU_FMA64) : FPCORES_BITS'(op_type[3:2])); + wire is_fma = ~op_type[3]; + wire is_ncp = (op_type[3:2] == 2'b11) && (op_type != INST_FPU_F2F); + wire is_fma64 = FMA64_SPLIT && is_fma && (dst_fmt == INST_FMT_D); + wire [FPCORES_BITS-1:0] core_select = is_fma64 ? FPCORES_BITS'(FPU_FMA64) + : is_fma ? FPCORES_BITS'(FPU_FMA) + : is_ncp ? FPCORES_BITS'(FPU_NCP) + : FPCORES_BITS'(FPU_CVT); VX_stream_switch #( .DATAW (REQ_DATAW), @@ -390,265 +391,6 @@ module VX_fpu_dsp import VX_gpu_pkg::*, VX_fpu_pkg::*; #( end - // Div/Sqrt core ////////////////////////////////////////////////////////// - - if (1) begin : g_fdivsqrt - - localparam PATH_REQ_DATAW = NUM_LANES + TAG_WIDTH + INST_FMT_BITS + INST_FRM_BITS + 2 * (NUM_LANES * `VX_CFG_XLEN); - localparam PATH_RSP_DATAW = (NUM_LANES * `VX_CFG_XLEN) + 1 + $bits(fflags_t) + TAG_WIDTH; - - wire is_sqrt = per_core_op_type[FPU_DIVSQRT][0]; - - wire [1:0] path_valid_in; - wire [1:0][PATH_REQ_DATAW-1:0] path_data_in; - wire [1:0] path_ready_in; - - wire [1:0][NUM_LANES-1:0] path_mask; - wire [1:0][TAG_WIDTH-1:0] path_tag; - wire [1:0][INST_FMT_BITS-1:0] path_fmt; - wire [1:0][INST_FRM_BITS-1:0] path_frm; - wire [1:0][NUM_LANES-1:0][`VX_CFG_XLEN-1:0] path_dataa; - wire [1:0][NUM_LANES-1:0][`VX_CFG_XLEN-1:0] path_datab; - - `UNUSED_VAR (per_core_datac[FPU_DIVSQRT]) - `UNUSED_VAR (path_datab[1]) - - VX_stream_switch #( - .DATAW (PATH_REQ_DATAW), - .NUM_INPUTS (1), - .NUM_OUTPUTS (2), - .OUT_BUF (0) - ) req_switch ( - .clk (clk), - .reset (reset), - .sel_in (is_sqrt), - .valid_in (per_core_valid_in[FPU_DIVSQRT]), - .ready_in (per_core_ready_in[FPU_DIVSQRT]), - .data_in ({per_core_mask_in[FPU_DIVSQRT], per_core_tag_in[FPU_DIVSQRT], per_core_dst_fmt[FPU_DIVSQRT], per_core_frm[FPU_DIVSQRT], per_core_dataa[FPU_DIVSQRT], per_core_datab[FPU_DIVSQRT]}), - .data_out (path_data_in), - .valid_out (path_valid_in), - .ready_out (path_ready_in) - ); - - for (genvar i = 0; i < 2; ++i) begin : g_unpack - assign { - path_mask[i], - path_tag[i], - path_fmt[i], - path_frm[i], - path_dataa[i], - path_datab[i] - } = path_data_in[i]; - end - - wire [1:0] path_valid_out; - wire [1:0][PATH_RSP_DATAW-1:0] path_data_out; - wire [1:0] path_ready_out; - - // DIV path (index 0) - - wire [TAG_WIDTH-1:0] div_tag_out; - wire [NUM_LANES-1:0] div_mask_out; - wire [NUM_LANES-1:0][(`FP_FLAGS_BITS+`VX_CFG_XLEN)-1:0] div_data_out; - wire [NUM_PES_DIV-1:0] div_pe_enable; - wire [NUM_PES_DIV-1:0] div_pe_mask_out; - wire [NUM_PES_DIV-1:0][(2*`VX_CFG_XLEN)-1:0] div_pe_data_in; - wire [INST_FMT_BITS+INST_FRM_BITS-1:0] div_pe_shared; - wire [NUM_PES_DIV-1:0][(`FP_FLAGS_BITS+`VX_CFG_XLEN)-1:0] div_pe_data_out; - wire [NUM_LANES-1:0][(2*`VX_CFG_XLEN)-1:0] div_lane_data; - - for (genvar i = 0; i < NUM_LANES; ++i) begin : g_div_lane_data - assign div_lane_data[i] = {path_datab[0][i], path_dataa[0][i]}; - end - - VX_pe_serializer #( - .NUM_LANES (NUM_LANES), - .NUM_PES (NUM_PES_DIV), - .LATENCY (`VX_CFG_FDIV_LATENCY), - .DATA_IN_WIDTH (2*`VX_CFG_XLEN), - .DATA_OUT_WIDTH (`FP_FLAGS_BITS+`VX_CFG_XLEN), - .SHARED_WIDTH (INST_FMT_BITS+INST_FRM_BITS), - .TAG_WIDTH (TAG_WIDTH), - .PE_REG (0), - .OUT_BUF (`OUT_BUF_BYPASS), - .PE_ENABLES (NUM_PES_DIV) - ) div_pe_ser ( - .clk (clk), - .reset (reset), - .valid_in (path_valid_in[0]), - .mask_in (path_mask[0]), - .data_in (div_lane_data), - .shared_in ({path_fmt[0], path_frm[0]}), - .tag_in (path_tag[0]), - .ready_in (path_ready_in[0]), - .pe_enable (div_pe_enable), - .pe_mask_out (div_pe_mask_out), - .pe_data_out (div_pe_data_in), - .pe_shared_out (div_pe_shared), - .pe_data_in (div_pe_data_out), - .valid_out (path_valid_out[0]), - .mask_out (div_mask_out), - .data_out (div_data_out), - .tag_out (div_tag_out), - .ready_out (path_ready_out[0]) - ); - - fflags_t [NUM_LANES-1:0] div_fflags_lanes; - wire [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] div_result; - - // Pass-through: the F32 IPs box their output explicitly; the native - // merged unit self-boxes (F64 fills the width, F32 NaN-boxed). - for (genvar i = 0; i < NUM_LANES; ++i) begin : g_div_result - assign div_result[i] = div_data_out[i][0+:`VX_CFG_XLEN]; - assign div_fflags_lanes[i] = div_data_out[i][`VX_CFG_XLEN+:`FP_FLAGS_BITS]; - end - - wire div_has_fflags; - - // Per-IP enable copies so each backend IP's clock-enable fanout stays - // local routing instead of merging into one global buffer. - wire [NUM_PES_DIV-1:0] div_pe_ce; - assign div_pe_ce = div_pe_enable; - - wire div_pe_is_s = (div_pe_shared[INST_FRM_BITS+:INST_FMT_BITS] == INST_FMT_S); - - for (genvar i = 0; i < NUM_PES_DIV; ++i) begin : g_div_units - if (`VX_CFG_XLEN > `VX_CFG_FLEN) begin : g_pad - assign div_pe_data_out[i][`VX_CFG_FLEN +: (`VX_CFG_XLEN-`VX_CFG_FLEN)] = '0; - end - VX_fdiv_unit #( - .LATENCY (`VX_CFG_FDIV_LATENCY), - .FLEN (`VX_CFG_FLEN), - .USE_DSP (1), - .SUBNORM_ENABLE (FPU_SNORM) - ) fdiv_unit ( - .clk (clk), - .reset (reset), - .enable (div_pe_ce[i]), - .mask (div_pe_mask_out[i]), - .fmt (div_pe_shared[INST_FRM_BITS+:INST_FMT_BITS]), - .frm (div_pe_shared[0+:INST_FRM_BITS]), - .dataa (fp_unbox_fmt(div_pe_data_in[i][0+:`VX_CFG_FLEN], div_pe_is_s)), - .datab (fp_unbox_fmt(div_pe_data_in[i][`VX_CFG_XLEN+:`VX_CFG_FLEN], div_pe_is_s)), - .result (div_pe_data_out[i][0+:`VX_CFG_FLEN]), - .fflags (div_pe_data_out[i][`VX_CFG_XLEN+:`FP_FLAGS_BITS]) - ); - end - - assign div_has_fflags = 1; - - fflags_t div_merged_fflags; - `FPU_MERGE_FFLAGS(div_merged_fflags, div_fflags_lanes, div_mask_out, NUM_LANES); - assign path_data_out[0] = {div_result, div_has_fflags, div_merged_fflags, div_tag_out}; - - // SQRT path (index 1) - - wire [TAG_WIDTH-1:0] sqrt_tag_out; - wire [NUM_LANES-1:0] sqrt_mask_out; - wire [NUM_LANES-1:0][(`FP_FLAGS_BITS+`VX_CFG_XLEN)-1:0] sqrt_data_out; - wire [NUM_PES_SQRT-1:0] sqrt_pe_enable; - wire [NUM_PES_SQRT-1:0] sqrt_pe_mask_out; - wire [NUM_PES_SQRT-1:0][`VX_CFG_XLEN-1:0] sqrt_pe_data_in; - wire [INST_FMT_BITS+INST_FRM_BITS-1:0] sqrt_pe_shared; - wire [NUM_PES_SQRT-1:0][(`FP_FLAGS_BITS+`VX_CFG_XLEN)-1:0] sqrt_pe_data_out; - - VX_pe_serializer #( - .NUM_LANES (NUM_LANES), - .NUM_PES (NUM_PES_SQRT), - .LATENCY (`VX_CFG_FSQRT_LATENCY), - .DATA_IN_WIDTH (`VX_CFG_XLEN), - .DATA_OUT_WIDTH (`FP_FLAGS_BITS+`VX_CFG_XLEN), - .SHARED_WIDTH (INST_FMT_BITS+INST_FRM_BITS), - .TAG_WIDTH (TAG_WIDTH), - .PE_REG (0), - .OUT_BUF (`OUT_BUF_BYPASS), - .PE_ENABLES (NUM_PES_SQRT) - ) sqrt_pe_ser ( - .clk (clk), - .reset (reset), - .valid_in (path_valid_in[1]), - .mask_in (path_mask[1]), - .data_in (path_dataa[1]), - .shared_in ({path_fmt[1], path_frm[1]}), - .tag_in (path_tag[1]), - .ready_in (path_ready_in[1]), - .pe_enable (sqrt_pe_enable), - .pe_mask_out (sqrt_pe_mask_out), - .pe_data_out (sqrt_pe_data_in), - .pe_shared_out (sqrt_pe_shared), - .pe_data_in (sqrt_pe_data_out), - .valid_out (path_valid_out[1]), - .mask_out (sqrt_mask_out), - .data_out (sqrt_data_out), - .tag_out (sqrt_tag_out), - .ready_out (path_ready_out[1]) - ); - - fflags_t [NUM_LANES-1:0] sqrt_fflags_lanes; - wire [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] sqrt_result; - - // Pass-through: F32 IP boxes explicitly; native merged unit self-boxes. - for (genvar i = 0; i < NUM_LANES; ++i) begin : g_sqrt_result - assign sqrt_result[i] = sqrt_data_out[i][0+:`VX_CFG_XLEN]; - assign sqrt_fflags_lanes[i] = sqrt_data_out[i][`VX_CFG_XLEN+:`FP_FLAGS_BITS]; - end - - wire sqrt_has_fflags; - - // Per-IP enable copies so each backend IP's clock-enable fanout stays - // local routing instead of merging into one global buffer. - wire [NUM_PES_SQRT-1:0] sqrt_pe_ce; - assign sqrt_pe_ce = sqrt_pe_enable; - - wire sqrt_pe_is_s = (sqrt_pe_shared[INST_FRM_BITS+:INST_FMT_BITS] == INST_FMT_S); - - for (genvar i = 0; i < NUM_PES_SQRT; ++i) begin : g_sqrt_units - if (`VX_CFG_XLEN > `VX_CFG_FLEN) begin : g_pad - assign sqrt_pe_data_out[i][`VX_CFG_FLEN +: (`VX_CFG_XLEN-`VX_CFG_FLEN)] = '0; - end - VX_fsqrt_unit #( - .LATENCY (`VX_CFG_FSQRT_LATENCY), - .FLEN (`VX_CFG_FLEN), - .USE_DSP (1), - .SUBNORM_ENABLE (FPU_SNORM) - ) fsqrt_unit ( - .clk (clk), - .reset (reset), - .enable (sqrt_pe_ce[i]), - .mask (sqrt_pe_mask_out[i]), - .fmt (sqrt_pe_shared[INST_FRM_BITS+:INST_FMT_BITS]), - .frm (sqrt_pe_shared[0+:INST_FRM_BITS]), - .dataa (fp_unbox_fmt(sqrt_pe_data_in[i][0+:`VX_CFG_FLEN], sqrt_pe_is_s)), - .result (sqrt_pe_data_out[i][0+:`VX_CFG_FLEN]), - .fflags (sqrt_pe_data_out[i][`VX_CFG_XLEN+:`FP_FLAGS_BITS]) - ); - end - - assign sqrt_has_fflags = 1; - - fflags_t sqrt_merged_fflags; - `FPU_MERGE_FFLAGS(sqrt_merged_fflags, sqrt_fflags_lanes, sqrt_mask_out, NUM_LANES); - assign path_data_out[1] = {sqrt_result, sqrt_has_fflags, sqrt_merged_fflags, sqrt_tag_out}; - - VX_stream_arb #( - .NUM_INPUTS (2), - .DATAW (PATH_RSP_DATAW), - .ARBITER ("P"), - .OUT_BUF (0) - ) rsp_arb ( - .clk (clk), - .reset (reset), - .valid_in (path_valid_out), - .ready_in (path_ready_out), - .data_in (path_data_out), - .data_out ({per_core_result[FPU_DIVSQRT], per_core_has_fflags[FPU_DIVSQRT], per_core_fflags[FPU_DIVSQRT], per_core_tag_out[FPU_DIVSQRT]}), - .valid_out (per_core_valid_out[FPU_DIVSQRT]), - .ready_out (per_core_ready_out[FPU_DIVSQRT]), - `UNUSED_PIN (sel_out) - ); - - end - // CVT core /////////////////////////////////////////////////////////////// if (1) begin : g_cvt diff --git a/hw/rtl/fpu/VX_fpu_fpnew.sv b/hw/rtl/fpu/VX_fpu_fpnew.sv index 6d24cc9c4c..cb3b45ee1b 100644 --- a/hw/rtl/fpu/VX_fpu_fpnew.sv +++ b/hw/rtl/fpu/VX_fpu_fpnew.sv @@ -20,7 +20,6 @@ module VX_fpu_fpnew import VX_fpu_pkg::*; import fpnew_pkg::*; import cf_math_pkg::*; - import defs_div_sqrt_mvp::*; #( parameter NUM_LANES = 1, parameter TAG_WIDTH = 1, @@ -57,11 +56,9 @@ module VX_fpu_fpnew ); // FPnew instantiates a full lane of every unit; it has no PE serializer. `STATIC_ASSERT((`VX_CFG_FMA_PE_RATIO == 1) && (`VX_CFG_FMA64_PE_RATIO == 1) - && (`VX_CFG_FDIV_PE_RATIO == 1) && (`VX_CFG_FSQRT_PE_RATIO == 1) && (`VX_CFG_FCVT_PE_RATIO == 1) && (`VX_CFG_FNCP_PE_RATIO == 1), ("FPU_TYPE_FPNEW does not support FPU PE ratios other than 1")) - localparam LATENCY_FDIVSQRT = `MAX(`VX_CFG_FDIV_LATENCY, `VX_CFG_FSQRT_LATENCY); localparam RSP_DATAW = (NUM_LANES * `VX_CFG_XLEN) + 1 + $bits(fflags_t) + TAG_WIDTH; `ifdef VX_CFG_EXT_ZFHMIN_ENABLE @@ -88,9 +85,7 @@ module VX_fpu_fpnew `endif }; - // Div/sqrt has operand-dependent latency, so it runs on its own per-lane - // instance; the remaining groups are fixed-latency and stay in lockstep. - localparam fpnew_pkg::fpu_implementation_t FPU_IMPL_LOCKSTEP = '{ + localparam fpnew_pkg::fpu_implementation_t FPU_IMPLEMENTATION = '{ PipeRegs:'{'{`VX_CFG_FMA_LATENCY, 0, 0, 0, 0}, // ADDMUL '{default: 0}, // DIVSQRT '{default: `VX_CFG_FNCP_LATENCY}, // NONCOMP @@ -102,21 +97,7 @@ module VX_fpu_fpnew PipeConfig: fpnew_pkg::DISTRIBUTED }; - localparam fpnew_pkg::fpu_implementation_t FPU_IMPL_DIVSQRT = '{ - PipeRegs:'{'{default: 0}, // ADDMUL - '{default: unsigned'(LATENCY_FDIVSQRT)}, // DIVSQRT - '{default: 0}, // NONCOMP - '{default: 0}}, // CONV - UnitTypes:'{'{default: fpnew_pkg::DISABLED}, // ADDMUL - '{default: fpnew_pkg::MERGED}, // DIVSQRT - '{default: fpnew_pkg::DISABLED}, // NONCOMP - '{default: fpnew_pkg::DISABLED}}, // CONV - PipeConfig: fpnew_pkg::DISTRIBUTED - }; - - localparam LS_TAGW = TAG_WIDTH + 1 + NUM_LANES; // {tag, has_fflags, mask} - localparam DS_TAGW = TAG_WIDTH + NUM_LANES; // {tag, mask} - localparam DS_DATAW = DS_TAGW + $bits(fflags_t) + `VX_CFG_XLEN; + localparam FPU_TAGW = TAG_WIDTH + 1 + NUM_LANES; // {tag, has_fflags, mask} logic [2:0][NUM_LANES-1:0][`VX_CFG_XLEN-1:0] fpu_operands; @@ -161,8 +142,6 @@ module VX_fpu_fpnew INST_FPU_MUL: begin fpu_op = fpnew_pkg::MUL; end INST_FPU_MADD: begin fpu_op = fpnew_pkg::FMADD; fpu_op_mod = op_mod; end INST_FPU_NMADD: begin fpu_op = fpnew_pkg::FNMSUB; fpu_op_mod = ~op_mod; end - INST_FPU_DIV: begin fpu_op = fpnew_pkg::DIV; end - INST_FPU_SQRT: begin fpu_op = fpnew_pkg::SQRT; end INST_FPU_F2F: begin fpu_op = fpnew_pkg::F2F; fpu_src_fmt = to_fpnew_fmt(src_fmt); @@ -202,64 +181,19 @@ module VX_fpu_fpnew endcase end - wire is_divsqrt = (op_type == INST_FPU_DIV) || (op_type == INST_FPU_SQRT); - - wire ls_valid_in = valid_in && ~is_divsqrt; - wire [NUM_LANES-1:0] ls_ready_in; - wire [NUM_LANES-1:0] ls_valid_out; - wire ls_ready_out; - wire [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] ls_result; - fflags_t [NUM_LANES-1:0] ls_status; - wire [NUM_LANES-1:0][LS_TAGW-1:0] ls_tag; - - wire ds_valid_in, ds_ready_in; - wire [NUM_LANES-1:0] ds_lane_valid_in, ds_lane_ready_in; - wire [NUM_LANES-1:0] ds_lane_valid_out, ds_lane_ready_out; - wire [NUM_LANES-1:0][DS_DATAW-1:0] ds_lane_data_out; - wire ds_valid_out, ds_ready_out; - wire [NUM_LANES-1:0][DS_DATAW-1:0] ds_data_out; - - // Each lane's div/sqrt unit is in order and sees every instruction once, so - // the k-th result of every lane belongs to the same instruction. - VX_stream_fork #( - .NUM_OUTPUTS (NUM_LANES), - .DATAW (1), - .EAGER (1) - ) ds_fork ( - .clk (clk), - .reset (reset), - .valid_in (ds_valid_in), - .data_in (1'b0), - .ready_in (ds_ready_in), - .valid_out (ds_lane_valid_in), - `UNUSED_PIN (data_out), - .ready_out (ds_lane_ready_in) - ); + wire [NUM_LANES-1:0] fpu_ready_in; + wire [NUM_LANES-1:0] fpu_valid_out; + wire fpu_ready_out; + wire [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] fpu_result; + fflags_t [NUM_LANES-1:0] fpu_status; + wire [NUM_LANES-1:0][FPU_TAGW-1:0] fpu_tag; for (genvar i = 0; i < NUM_LANES; ++i) begin : g_lanes - wire [`VX_CFG_XLEN-1:0] lane_ds_result; - fflags_t lane_ds_status; - wire [DS_TAGW-1:0] lane_ds_tag; - wire [1:0][`VX_CFG_XLEN-1:0] ds_operands; - - for (genvar j = 0; j < 2; ++j) begin : g_ds_operands - `ifdef VX_CFG_XLEN_64 - // fpnew's div/sqrt ignores NaN-boxing: an improperly boxed single - // operand must read as the canonical NaN. Sqrt has no operand B, - // but the unit still tests it for NaN. - wire is_used = (j == 0) || (fpu_op == fpnew_pkg::DIV); - wire unboxed = is_used && (fpu_dst_fmt == fpnew_pkg::FP32) && ~(& fpu_operands[j][i][63:32]); - assign ds_operands[j] = unboxed ? 64'hFFFFFFFF7FC00000 : fpu_operands[j][i]; - `else - assign ds_operands[j] = fpu_operands[j][i]; - `endif - end - fpnew_top #( .Features (FPU_FEATURES), - .Implementation (FPU_IMPL_LOCKSTEP), - .TagType (logic[LS_TAGW-1:0]) - ) fpnew_lockstep ( + .Implementation (FPU_IMPLEMENTATION), + .TagType (logic[FPU_TAGW-1:0]) + ) fpnew_core ( .clk_i (clk), .rst_ni (~reset), .operands_i ({fpu_operands[2][i], fpu_operands[1][i], fpu_operands[0][i]}), @@ -272,122 +206,48 @@ module VX_fpu_fpnew .vectorial_op_i (1'b0), .simd_mask_i (1'b1), .tag_i ({tag_in, fpu_has_fflags, mask_in}), - .in_valid_i (ls_valid_in), - .in_ready_o (ls_ready_in[i]), - .flush_i (1'b0), - .result_o (ls_result[i]), - .status_o (ls_status[i]), - .tag_o (ls_tag[i]), - .out_valid_o (ls_valid_out[i]), - .out_ready_i (ls_ready_out), - `UNUSED_PIN (busy_o) - ); - - fpnew_top #( - .Features (FPU_FEATURES), - .Implementation (FPU_IMPL_DIVSQRT), - .TagType (logic[DS_TAGW-1:0]) - ) fpnew_divsqrt ( - .clk_i (clk), - .rst_ni (~reset), - .operands_i ({fpu_operands[2][i], ds_operands}), - .rnd_mode_i (fpnew_pkg::roundmode_e'(fpu_rnd)), - .op_i (fpu_op), - .op_mod_i (fpu_op_mod), - .src_fmt_i (fpu_src_fmt), - .dst_fmt_i (fpu_dst_fmt), - .int_fmt_i (fpu_int_fmt), - .vectorial_op_i (1'b0), - .simd_mask_i (1'b1), - .tag_i ({tag_in, mask_in}), - .in_valid_i (ds_lane_valid_in[i]), - .in_ready_o (ds_lane_ready_in[i]), + .in_valid_i (valid_in), + .in_ready_o (fpu_ready_in[i]), .flush_i (1'b0), - .result_o (lane_ds_result), - .status_o (lane_ds_status), - .tag_o (lane_ds_tag), - .out_valid_o (ds_lane_valid_out[i]), - .out_ready_i (ds_lane_ready_out[i]), + .result_o (fpu_result[i]), + .status_o (fpu_status[i]), + .tag_o (fpu_tag[i]), + .out_valid_o (fpu_valid_out[i]), + .out_ready_i (fpu_ready_out), `UNUSED_PIN (busy_o) ); - // The div/sqrt unit also raises DZ on 0/0, which is only invalid. - fflags_t lane_ds_fflags; - always @(*) begin - lane_ds_fflags = lane_ds_status; - lane_ds_fflags.DZ = lane_ds_status.DZ && ~lane_ds_status.NV; - end - - assign ds_lane_data_out[i] = {lane_ds_tag, lane_ds_fflags, lane_ds_result}; - if (i != 0) begin : g_unused_tags - `UNUSED_VAR (ls_tag[i]) + `UNUSED_VAR (fpu_tag[i]) end end - `RUNTIME_ASSERT(((ls_valid_out == '0) || (ls_valid_out == '1)) && ((ls_ready_in == '0) || (ls_ready_in == '1)), - ("%t: fpnew lanes out of lockstep: valid_out=%b, ready_in=%b", $time, ls_valid_out, ls_ready_in)) + `RUNTIME_ASSERT(((fpu_valid_out == '0) || (fpu_valid_out == '1)) && ((fpu_ready_in == '0) || (fpu_ready_in == '1)), + ("%t: fpnew lanes out of lockstep: valid_out=%b, ready_in=%b", $time, fpu_valid_out, fpu_ready_in)) - VX_stream_join #( - .NUM_INPUTS (NUM_LANES), - .DATAW (DS_DATAW) - ) ds_join ( - .clk (clk), - .reset (reset), - .valid_in (ds_lane_valid_out), - .data_in (ds_lane_data_out), - .ready_in (ds_lane_ready_out), - .valid_out (ds_valid_out), - .data_out (ds_data_out), - .ready_out (ds_ready_out) - ); - - assign ds_valid_in = valid_in && is_divsqrt; - assign ready_in = is_divsqrt ? ds_ready_in : ls_ready_in[0]; - - // Lockstep response - wire [TAG_WIDTH-1:0] ls_tag_out; - wire ls_has_fflags; - wire [NUM_LANES-1:0] ls_mask; - fflags_t ls_fflags; - assign {ls_tag_out, ls_has_fflags, ls_mask} = ls_tag[0]; - - `FPU_MERGE_FFLAGS(ls_fflags, ls_status, ls_mask, NUM_LANES); - - // Div/sqrt response - wire [NUM_LANES-1:0][`VX_CFG_XLEN-1:0] ds_result; - fflags_t [NUM_LANES-1:0] ds_status; - wire [NUM_LANES-1:0][DS_TAGW-1:0] ds_tag; - for (genvar i = 0; i < NUM_LANES; ++i) begin : g_ds_unpack - assign {ds_tag[i], ds_status[i], ds_result[i]} = ds_data_out[i]; - if (i != 0) begin : g_unused_tags - `UNUSED_VAR (ds_tag[i]) - end - end + assign ready_in = fpu_ready_in[0]; - wire [TAG_WIDTH-1:0] ds_tag_out; - wire [NUM_LANES-1:0] ds_mask; - fflags_t ds_fflags; - assign {ds_tag_out, ds_mask} = ds_tag[0]; + wire [TAG_WIDTH-1:0] fpu_tag_out; + wire fpu_has_fflags_out; + wire [NUM_LANES-1:0] fpu_mask_out; + fflags_t fpu_fflags; + assign {fpu_tag_out, fpu_has_fflags_out, fpu_mask_out} = fpu_tag[0]; - `FPU_MERGE_FFLAGS(ds_fflags, ds_status, ds_mask, NUM_LANES); + `FPU_MERGE_FFLAGS(fpu_fflags, fpu_status, fpu_mask_out, NUM_LANES); - VX_stream_arb #( - .NUM_INPUTS (2), - .DATAW (RSP_DATAW), - .ARBITER ("P"), - .OUT_BUF (OUT_BUF) - ) rsp_arb ( + VX_elastic_buffer #( + .DATAW (RSP_DATAW), + .SIZE (`TO_OUT_BUF_SIZE(OUT_BUF)), + .OUT_REG (`TO_OUT_BUF_REG(OUT_BUF)) + ) rsp_buf ( .clk (clk), .reset (reset), - .valid_in ({ls_valid_out[0], ds_valid_out}), - .ready_in ({ls_ready_out, ds_ready_out}), - .data_in ({{ls_result, ls_has_fflags, ls_fflags, ls_tag_out}, - {ds_result, 1'b1, ds_fflags, ds_tag_out}}), + .valid_in (fpu_valid_out[0]), + .ready_in (fpu_ready_out), + .data_in ({fpu_result, fpu_has_fflags_out, fpu_fflags, fpu_tag_out}), .data_out ({result, has_fflags, fflags, tag_out}), .valid_out (valid_out), - .ready_out (ready_out), - `UNUSED_PIN (sel_out) + .ready_out (ready_out) ); endmodule diff --git a/hw/rtl/fpu/VX_fpu_std.sv b/hw/rtl/fpu/VX_fpu_std.sv index dfa8dfef88..89c0a89436 100644 --- a/hw/rtl/fpu/VX_fpu_std.sv +++ b/hw/rtl/fpu/VX_fpu_std.sv @@ -51,25 +51,19 @@ module VX_fpu_std import VX_gpu_pkg::*, VX_fpu_pkg::*; #( ); localparam NUM_PES_FMA = `UP(NUM_LANES / `VX_CFG_FMA_PE_RATIO); localparam NUM_PES_FMA64 = `UP(NUM_LANES / `VX_CFG_FMA64_PE_RATIO); - localparam NUM_PES_DIV = `UP(NUM_LANES / `VX_CFG_FDIV_PE_RATIO); localparam NUM_PES_CVT = `UP(NUM_LANES / `VX_CFG_FCVT_PE_RATIO); localparam NUM_PES_NCP = `UP(NUM_LANES / `VX_CFG_FNCP_PE_RATIO); - // Division and square root share one unit and its rate. - `STATIC_ASSERT(`VX_CFG_FSQRT_PE_RATIO == `VX_CFG_FDIV_PE_RATIO, - ("FPU_TYPE_STD: VX_CFG_FSQRT_PE_RATIO must equal VX_CFG_FDIV_PE_RATIO")) - // A narrower F64 FMA rate gets its own pool of F64-only PEs, and the F32 // pool then drops its F64 units. localparam FMA64_SPLIT = (`VX_CFG_FLEN >= 64) && (NUM_PES_FMA64 != NUM_PES_FMA); localparam FMA_HAS_F64 = (`VX_CFG_FLEN >= 64) && !FMA64_SPLIT; localparam FPU_FMA = 0; - localparam FPU_DIVSQRT = 1; - localparam FPU_CVT = 2; - localparam FPU_NCP = 3; - localparam FPU_FMA64 = 4; - localparam NUM_FPCORES = FMA64_SPLIT ? 5 : 4; + localparam FPU_CVT = 1; + localparam FPU_NCP = 2; + localparam FPU_FMA64 = 3; + localparam NUM_FPCORES = FMA64_SPLIT ? 4 : 3; localparam FPCORES_BITS = `LOG2UP(NUM_FPCORES); localparam CVT_LATENCY = (`VX_CFG_XLEN == 64) ? `VX_CFG_FCVT_LATENCY + 1 : `VX_CFG_FCVT_LATENCY; @@ -102,9 +96,13 @@ module VX_fpu_std import VX_gpu_pkg::*, VX_fpu_pkg::*; #( wire [NUM_FPCORES-1:0] per_core_ready_out; // Decode FPU core selector - wire is_fma64 = FMA64_SPLIT && (op_type[3:2] == 2'(FPU_FMA)) && (dst_fmt == INST_FMT_D); - wire [FPCORES_BITS-1:0] core_select = (op_type == INST_FPU_F2F) ? FPCORES_BITS'(FPU_CVT) - : (is_fma64 ? FPCORES_BITS'(FPU_FMA64) : FPCORES_BITS'(op_type[3:2])); + wire is_fma = ~op_type[3]; + wire is_ncp = (op_type[3:2] == 2'b11) && (op_type != INST_FPU_F2F); + wire is_fma64 = FMA64_SPLIT && is_fma && (dst_fmt == INST_FMT_D); + wire [FPCORES_BITS-1:0] core_select = is_fma64 ? FPCORES_BITS'(FPU_FMA64) + : is_fma ? FPCORES_BITS'(FPU_FMA) + : is_ncp ? FPCORES_BITS'(FPU_NCP) + : FPCORES_BITS'(FPU_CVT); VX_stream_switch #( .DATAW (REQ_DATAW), @@ -372,99 +370,6 @@ module VX_fpu_std import VX_gpu_pkg::*, VX_fpu_pkg::*; #( end - /////////////////////////////////////////////////////////////////////////// - // DIVSQRT core - /////////////////////////////////////////////////////////////////////////// - - if (1) begin : g_fdivsqrt - - wire is_sqrt = per_core_op[FPU_DIVSQRT][0]; - - wire [NUM_LANES-1:0] mask_out; - wire [NUM_LANES-1:0][(`FP_FLAGS_BITS+`VX_CFG_XLEN)-1:0] data_out; - wire pe_enable; - wire [NUM_PES_DIV-1:0] pe_mask_out; - wire [NUM_PES_DIV-1:0][(2*`VX_CFG_XLEN)-1:0] pe_data_in; - wire [1+INST_FMT_BITS+INST_FRM_BITS-1:0] pe_shared; - wire [NUM_PES_DIV-1:0][(`FP_FLAGS_BITS+`VX_CFG_XLEN)-1:0] pe_data_out; - wire [NUM_LANES-1:0][(2*`VX_CFG_XLEN)-1:0] lane_data; - - `UNUSED_VAR (per_core_datac[FPU_DIVSQRT]) - - for (genvar i = 0; i < NUM_LANES; ++i) begin : g_lane_data - assign lane_data[i] = {per_core_datab[FPU_DIVSQRT][i], per_core_dataa[FPU_DIVSQRT][i]}; - end - - VX_pe_serializer #( - .NUM_LANES (NUM_LANES), - .NUM_PES (NUM_PES_DIV), - .LATENCY (`VX_CFG_FDIV_LATENCY), - .DATA_IN_WIDTH (2*`VX_CFG_XLEN), - .DATA_OUT_WIDTH (`FP_FLAGS_BITS+`VX_CFG_XLEN), - .SHARED_WIDTH (1+INST_FMT_BITS+INST_FRM_BITS), - .TAG_WIDTH (TAG_WIDTH), - .PE_REG (0), - .OUT_BUF (`OUT_BUF_BYPASS) - ) pe_ser ( - .clk (clk), - .reset (reset), - .valid_in (per_core_valid_in[FPU_DIVSQRT]), - .mask_in (per_core_mask[FPU_DIVSQRT]), - .data_in (lane_data), - .shared_in ({is_sqrt, per_core_dst_fmt[FPU_DIVSQRT], per_core_frm[FPU_DIVSQRT]}), - .tag_in (per_core_tag[FPU_DIVSQRT]), - .ready_in (per_core_ready_in[FPU_DIVSQRT]), - .pe_enable (pe_enable), - .pe_mask_out (pe_mask_out), - .pe_data_out (pe_data_in), - .pe_shared_out (pe_shared), - .pe_data_in (pe_data_out), - .valid_out (per_core_valid_out[FPU_DIVSQRT]), - .mask_out (mask_out), - .data_out (data_out), - .tag_out (per_core_tag_out[FPU_DIVSQRT]), - .ready_out (per_core_ready_out[FPU_DIVSQRT]) - ); - - fflags_t [NUM_LANES-1:0] fflags_lanes; - - // The merged unit already packs/NaN-boxes the result at the active format. - for (genvar i = 0; i < NUM_LANES; ++i) begin : g_result - assign per_core_result[FPU_DIVSQRT][i] = data_out[i][0+:`VX_CFG_XLEN]; - assign fflags_lanes[i] = data_out[i][`VX_CFG_XLEN+:`FP_FLAGS_BITS]; - end - - wire pe_is_s = (pe_shared[INST_FRM_BITS+:INST_FMT_BITS] == INST_FMT_S); - - for (genvar i = 0; i < NUM_PES_DIV; ++i) begin : g_units - if (`VX_CFG_XLEN > `VX_CFG_FLEN) begin : g_pad - assign pe_data_out[i][`VX_CFG_FLEN +: (`VX_CFG_XLEN-`VX_CFG_FLEN)] = '0; - end - VX_fdivsqrt_unit #( - .LATENCY (`VX_CFG_FDIV_LATENCY), - .FLEN (`VX_CFG_FLEN) - ) fdiv_sqrt_unit ( - .clk (clk), - .reset (reset), - .enable (pe_enable), - .mask (pe_mask_out[i]), - .fmt (pe_shared[INST_FRM_BITS+:INST_FMT_BITS]), - .frm (pe_shared[0+:INST_FRM_BITS]), - .dataa (fp_unbox_fmt(pe_data_in[i][0+:`VX_CFG_FLEN], pe_is_s)), - .datab (fp_unbox_fmt(pe_data_in[i][`VX_CFG_XLEN+:`VX_CFG_FLEN], pe_is_s)), - .is_sqrt (pe_shared[INST_FRM_BITS+INST_FMT_BITS]), - .result (pe_data_out[i][0+:`VX_CFG_FLEN]), - .fflags (pe_data_out[i][`VX_CFG_XLEN+:`FP_FLAGS_BITS]) - ); - end - - assign per_core_has_fflags[FPU_DIVSQRT] = 1; - fflags_t merged_fflags; - `FPU_MERGE_FFLAGS(merged_fflags, fflags_lanes, mask_out, NUM_LANES); - assign per_core_fflags[FPU_DIVSQRT] = merged_fflags; - - end - /////////////////////////////////////////////////////////////////////////// // CVT core /////////////////////////////////////////////////////////////////////////// diff --git a/hw/rtl/fpu/VX_fsqrt_unit.sv b/hw/rtl/fpu/VX_fsqrt_unit.sv deleted file mode 100644 index 06cdd39c41..0000000000 --- a/hw/rtl/fpu/VX_fsqrt_unit.sv +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright © 2019-2023 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// FSQRT backend selector. On a Xilinx (VIVADO) / Altera (QUARTUS) FPGA flow with -// USE_DSP and flush-to-zero, the F32 path maps onto the hardened floating-point -// operator IP; otherwise it uses the portable pure-RTL core VX_fsqrt_unit_rtl. The -// vendor IP is flush-to-zero and round-to-nearest-even only (gated on SUBNORM_ENABLE=0). - -`include "VX_fpu_define.vh" - -module VX_fsqrt_unit import VX_gpu_pkg::*, VX_fpu_pkg::*; #( - parameter LATENCY = 17, - parameter FLEN = 32, - // 1: use the FPGA vendor FP IP on Xilinx/Altera (F32). 0: ASIC soft core. - parameter USE_DSP = 0, - // 1: full IEEE subnormals (soft core only). 0: flush-to-zero; required for IP. - parameter SUBNORM_ENABLE = 1, - // 1: produce IEEE special results + fflags. 0: assume finite, tie 0. - parameter EXCEPT_ENABLE = 1, - // soft core only: 1 = one NR step per stage (Fmax), see VX_fsqrt_unit_rtl - parameter SPLIT = 0 -) ( - input wire clk, - input wire reset, - input wire enable, - input wire mask, - - input wire [INST_FMT_BITS-1:0] fmt, - input wire [INST_FRM_BITS-1:0] frm, - - input wire [FLEN-1:0] dataa, // radicand - - output wire [FLEN-1:0] result, - output wire [`FP_FLAGS_BITS-1:0] fflags -); - // Vendor FP IP: Xilinx/Altera FPGA flows only, F32-only, flush-to-zero. -`ifdef VIVADO - localparam VENDOR_OK = 1; -`elsif QUARTUS - localparam VENDOR_OK = 1; -`else - localparam VENDOR_OK = 0; -`endif - // Vendor IP is selected only with SUBNORM_ENABLE=0 (flush-to-zero); SUBNORM_ENABLE=1 - // falls back to the IEEE soft core. - localparam IS_F32 = (FLEN == 32); - localparam USE_VENDOR_IP = (USE_DSP != 0) && (SUBNORM_ENABLE == 0) && IS_F32 && (VENDOR_OK != 0); - - `STATIC_ASSERT(!USE_VENDOR_IP || (LATENCY == 28), - ("vendor xil_fsqrt latency is 28; set VX_CFG_FSQRT_LATENCY=28")) - - if (USE_VENDOR_IP) begin : g_vendor - // The vendor IP rounds round-to-nearest-even only (frm is ignored). - `UNUSED_VAR (reset) - `UNUSED_VAR (mask) - `UNUSED_VAR (fmt) - `UNUSED_VAR (frm) - `ifdef QUARTUS - acl_fsqrt fsqrt ( - .clk (clk), - .areset (1'b0), - .en (enable), - .a (dataa), - .q (result) - ); - assign fflags = '0; // acl_fsqrt does not expose exception flags - `else // VIVADO - wire tuser; - xil_fsqrt fsqrt ( - .aclk (clk), - .aclken (enable), - .s_axis_a_tvalid (1'b1), - .s_axis_a_tdata (dataa), - `UNUSED_PIN (m_axis_result_tvalid), - .m_axis_result_tdata (result), - .m_axis_result_tuser (tuser) - ); - // tuser = invalid -> fflags {NV, DZ, OF, UF, NX}. - assign fflags = EXCEPT_ENABLE ? {tuser, 1'b0, 1'b0, 1'b0, 1'b0} : '0; - `endif - end else begin : g_rtl - VX_fsqrt_unit_rtl #( - .LATENCY (LATENCY), - .FLEN (FLEN), - .USE_DSP (USE_DSP), - .SUBNORM_ENABLE (SUBNORM_ENABLE), - .EXCEPT_ENABLE (EXCEPT_ENABLE), - .SPLIT (SPLIT) - ) core ( - .clk (clk), - .reset (reset), - .enable (enable), - .mask (mask), - .fmt (fmt), - .frm (frm), - .dataa (dataa), - .result (result), - .fflags (fflags) - ); - end - -endmodule diff --git a/hw/rtl/fpu/VX_fsqrt_unit_rtl.sv b/hw/rtl/fpu/VX_fsqrt_unit_rtl.sv deleted file mode 100644 index 11c5ed8e02..0000000000 --- a/hw/rtl/fpu/VX_fsqrt_unit_rtl.sv +++ /dev/null @@ -1,617 +0,0 @@ -// Copyright © 2019-2023 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Single-lane pipelined FSQRT (pure RTL, single-function). -// -// Specialization of VX_fdivsqrt_unit with the DIV path removed: the same -// radix-2 carry-save NR recurrence on the partial root S, sized for the widest -// supported format (SUPER = F64 when FLEN>=64, else F32). Only the front -// (unpack) and back (extract/round/pack) stages are format-aware: -// - the radicand is unpacked at its active format (F32/F64) and the -// normalized significand is LEFT-justified into the SUPER significand, -// - the exponent is tracked in the ACTIVE format's frame (bias/range), so -// an F32 op rounds ONCE at 24-bit precision (no double rounding) and -// under/overflows at the F32 boundary. -// -// Pipeline: 1 PRE + 1 INI + NR_STAGES SRT + 1 CONV + 1 NRM. -// SUPER=F32: NR_STAGES=13 -> LATENCY 17 -// SUPER=F64: NR_STAGES=28 -> LATENCY 32 -// -// SQRT: NR radix-2 with W and S (partial root) scaled x2^SCALE_SQRT. -// SCALE_SQRT is chosen by SUPER_SIG parity so the per-stage ULP schedule -// lands on the same endpoints (step-B ULP last = 2 for NRO=0, 1 for NRO=1). - -`include "VX_fpu_define.vh" - -module VX_fsqrt_unit_rtl import VX_gpu_pkg::*, VX_fpu_pkg::*; #( - parameter LATENCY = 17, - parameter FLEN = 32, - // Reserved for a future vendor/DSP backend select. The SRT datapath has no - // multiplier, so it is a no-op here; accepted for a uniform FPU unit API. - parameter USE_DSP = 0, - // 1: full IEEE subnormal support. 0: flush-to-zero (DAZ subnormal radicand to - // signed zero + FTZ subnormal results) for area. Use 0 for relaxed paths. - parameter SUBNORM_ENABLE = 1, - // 1: detect NaN/inf + produce IEEE special results + fflags. 0: assume finite - // operands; drop the exception cone and tie fflags to 0 (area). - parameter EXCEPT_ENABLE = 1, - // 1: one NR step per pipeline stage, and the rounding in a stage of its own - // (Fmax: LATENCY + NR_STAGES + 1); the same results. 0: two NR steps per stage. - parameter SPLIT = 0 -) ( - input wire clk, - input wire reset, - input wire enable, - input wire mask, - - input wire [INST_FMT_BITS-1:0] fmt, - input wire [INST_FRM_BITS-1:0] frm, - - input wire [FLEN-1:0] dataa, // radicand - - output wire [FLEN-1:0] result, - output wire [`FP_FLAGS_BITS-1:0] fflags -); - localparam HAS_D = (FLEN >= 64); - wire is_d = HAS_D && (fmt == INST_FMT_D); - `UNUSED_VAR (fmt) - `UNUSED_PARAM (USE_DSP) - - // ---- SUPER (widest) format the datapath is built for ---- - localparam SUPER_MAN = HAS_D ? 52 : 23; - localparam SUPER_SIG = SUPER_MAN + 1; // 24 / 53 - - localparam PRE_LATENCY = 1; - localparam INI_LATENCY = 1; - localparam CONV_LATENCY = 1; - localparam NRM_LATENCY = 1; - localparam RND_LATENCY = (SPLIT != 0) ? 1 : 0; - - // carry-save working-width scale: the partial remainder spans SQRT_LEAD + 3 - // bits (sign + 2 S), so one more than the root's scale (F32 5, F64 6). - localparam SCALE_SQRT = (SUPER_SIG % 2 == 1) ? 5 : 4; // even SIG->4 (F32), odd->5 (F64) - localparam SCALE_W = SCALE_SQRT + 1; - - localparam W_BITS = SUPER_SIG + SCALE_W + 1; // 30 / 60 - localparam CS_BITS = W_BITS + 1; // 31 / 61: carry-save component width - localparam NR_BITS = (SUPER_SIG + 2) + ((SUPER_SIG + 2) % 2); // even: 26 / 56 - localparam NR_STAGES = NR_BITS / 2; - localparam NSRT = (SPLIT != 0) ? NR_BITS : NR_STAGES; // SRT pipeline stages // 13 / 28 - localparam EXP_W = HAS_D ? 14 : 10; // signed exponent working width - - // SQRT scaled-S leading-bit position: S in [2^SQRT_LEAD, 2^(SQRT_LEAD+1)) - localparam SQRT_LEAD = SUPER_SIG + SCALE_SQRT - 1; // 27 / 57 - - `STATIC_ASSERT(LATENCY == (PRE_LATENCY + INI_LATENCY + NSRT + CONV_LATENCY + RND_LATENCY + NRM_LATENCY), ("VX_fsqrt_unit: LATENCY must be %0d, got %0d", PRE_LATENCY+INI_LATENCY+NSRT+CONV_LATENCY+RND_LATENCY+NRM_LATENCY, LATENCY)) - - reg [LATENCY-1:0] mask_pipe; - always @(posedge clk) begin - if (reset) begin - mask_pipe <= '0; - end else if (enable) begin - mask_pipe <= {mask_pipe[LATENCY-2:0], mask}; - end - end - wire valid_ini = mask_pipe[PRE_LATENCY-1]; - wire valid_conv = mask_pipe[PRE_LATENCY+INI_LATENCY+NSRT-1]; - wire valid_rnd = mask_pipe[PRE_LATENCY+INI_LATENCY+NSRT+CONV_LATENCY-1]; - wire valid_nrm = mask_pipe[PRE_LATENCY+INI_LATENCY+NSRT+CONV_LATENCY+RND_LATENCY-1]; - - // ---- SRT state vector layout ---- - localparam EXC_LO = 0; - localparam FRM_LO = EXC_LO + 5; - localparam SGN_LO = FRM_LO + INST_FRM_BITS; - localparam EXP_LO = SGN_LO + 1; - localparam DS_LO = EXP_LO + EXP_W; // S (partial root) - localparam W_LO = DS_LO + W_BITS; // Ws (CS_BITS wide) - localparam WC_LO = W_LO + CS_BITS; // Wc (CS_BITS wide) - localparam NRO_LO = WC_LO + CS_BITS; // nr_offset - localparam ISD_LO = NRO_LO + 1; // is_double - localparam STAGE_W = ISD_LO + 1; - - // ========================================================================= - // Active-format unpack: classify, LZC-normalize the active significand, then - // LEFT-justify it into the SUPER significand. Exponent stays in active frame. - // ========================================================================= - wire [EXP_W-1:0] BIAS = is_d ? EXP_W'(1023) : EXP_W'(127); - - // DAZ: flush a subnormal radicand to signed zero when subnormals are disabled - // (the input LZC normalizer then goes dead and is pruned). - localparam DAZ = (SUBNORM_ENABLE == 0); - wire [FLEN-1:0] da; - if (HAS_D) begin : g_daz - wire as = is_d ? ((dataa[62:52]=='0) && (|dataa[51:0])) : ((dataa[30:23]=='0) && (|dataa[22:0])); - assign da = (DAZ & as) ? {dataa[FLEN-1], {(FLEN-1){1'b0}}} : dataa; - end else begin : g_daz_s - wire as = (dataa[30:23]=='0) && (|dataa[22:0]); - assign da = (DAZ & as) ? {dataa[31], 31'b0} : dataa; - end - - // -- raw active field extraction -- - wire s_a = is_d ? da[FLEN-1] : da[31]; - - // active exponent / mantissa selectors and classification - wire ea_allones, ea_zero, ma_nz, ma_q; - wire [SUPER_SIG-1:0] siga_ljn; // normalized, left-justified into SUPER_SIG - wire signed [EXP_W-1:0] exp_a; - - // --- F32 view --- - wire f32a_z = (da[30:23] == 8'd0) && (da[22:0] == 23'd0); - wire f32a_sub= (da[30:23] == 8'd0) && (da[22:0] != 23'd0); - wire [23:0] f32a_sig = {~(f32a_z | f32a_sub), da[22:0]}; - wire [4:0] f32a_lzc; - wire f32a_lvld; - VX_lzc #(.N(24)) lz_f32a (.data_in(f32a_sig), .data_out(f32a_lzc), .valid_out(f32a_lvld)); - wire [23:0] f32a_norm = f32a_sub ? (f32a_sig << f32a_lzc) : f32a_sig; - wire signed [EXP_W-1:0] f32a_exp = f32a_sub ? (EXP_W'(1) - EXP_W'(f32a_lzc)) : f32a_z ? '0 : EXP_W'(da[30:23]); - `UNUSED_VAR (f32a_lvld) - - if (HAS_D) begin : g_unpack_d - wire f64a_z = (da[62:52] == 11'd0) && (da[51:0] == 52'd0); - wire f64a_sub= (da[62:52] == 11'd0) && (da[51:0] != 52'd0); - wire [52:0] f64a_sig = {~(f64a_z | f64a_sub), da[51:0]}; - wire [5:0] f64a_lzc; - wire f64a_lvld; - VX_lzc #(.N(53)) lz_f64a (.data_in(f64a_sig), .data_out(f64a_lzc), .valid_out(f64a_lvld)); - wire [52:0] f64a_norm = f64a_sub ? (f64a_sig << f64a_lzc) : f64a_sig; - wire signed [EXP_W-1:0] f64a_exp = f64a_sub ? (EXP_W'(1) - EXP_W'(f64a_lzc)) : f64a_z ? '0 : EXP_W'(da[62:52]); - `UNUSED_VAR (f64a_lvld) - - assign ea_allones = is_d ? (&da[62:52]) : (&da[30:23]); - assign ea_zero = is_d ? f64a_z : f32a_z; - assign ma_nz = is_d ? (|da[51:0]) : (|da[22:0]); - assign ma_q = is_d ? da[51] : da[22]; // quiet bit (msb of man) - assign siga_ljn = is_d ? f64a_norm : {f32a_norm, {(SUPER_SIG-24){1'b0}}}; - assign exp_a = is_d ? f64a_exp : f32a_exp; - end else begin : g_unpack_s - assign ea_allones = &da[30:23]; - assign ea_zero = f32a_z; - assign ma_nz = |da[22:0]; - assign ma_q = da[22]; - assign siga_ljn = f32a_norm; - assign exp_a = f32a_exp; - end - - // classification flags (active format) - wire nan_a = ea_allones & ma_nz; - wire inf_a = ea_allones & ~ma_nz; - wire zero_a = ea_zero & ~ma_nz; - wire snan_a = nan_a & ~ma_q; - - // ========================================================================= - // PRE: SQRT path - // ========================================================================= - wire signed [EXP_W-1:0] exp_r0_sqrt = ($signed(exp_a) + BIAS) >>> 1; - - wire nv0_sq = snan_a | (s_a & ~nan_a & ~zero_a); - wire rnan_sq = nan_a | nv0_sq; - wire rinf_sq = inf_a & ~rnan_sq; - wire rzro_sq = zero_a & ~rnan_sq; - // EXCEPT_ENABLE=0 assumes finite operands: drop the NaN/inf cone + fflags. - wire [4:0] exc0_sq = EXCEPT_ENABLE ? {rnan_sq, rinf_sq, rzro_sq, 1'b0, nv0_sq} : 5'b0; - wire sign_r0_sq = zero_a & s_a; // sqrt(-0) = -0; other valid: + - - // Scale-by-2 parity must use the NORMALIZED exponent (exp_a = 1-lzc for - // subnormals), not the raw biased field LSB (which is always 0 for subnormals - // and gives the wrong parity -> wrong sqrt of a subnormal radicand). - wire ea_lsb_sq = exp_a[0]; - wire is_scale2_sq = ~ea_lsb_sq; - // Q_0=1.5 pre-commit when scaling and sig >= 1.125 (top 3 mantissa bits nonzero). - wire [2:0] top3_man = siga_ljn[SUPER_SIG-2 -: 3]; - wire nr_offset0_sq = is_scale2_sq & (|top3_man); - - // man (fraction) as integer at SUPER width; the normalized hidden bit - // (siga_ljn[SUPER_SIG-1], always 1) is implicit in the sqrt recurrence. - `UNUSED_VAR (siga_ljn[SUPER_SIG-1]) - wire [SUPER_MAN-1:0] man_a = siga_ljn[SUPER_MAN-1:0]; - - // SQRT W_0 / S_0 (see header; derived symbolically; reduce to the F32 constants at SUPER=F32) - wire [W_BITS-1:0] manSC1 = W_BITS'(man_a) << (SCALE_SQRT + 1); // man * 2^(SC+1) - - wire [W_BITS-1:0] S0_sq = nr_offset0_sq ? W_BITS'(3) << (SQRT_LEAD - 1) // 3*2^(LEAD-1) - : W_BITS'(1) << SQRT_LEAD; // 2^LEAD - - wire [W_BITS-1:0] W0_sq = !is_scale2_sq ? (W_BITS'(man_a) << SCALE_SQRT) // case1: man*2^SC - : !nr_offset0_sq ? ((W_BITS'(1) << SQRT_LEAD) + manSC1) // case2: 2^LEAD + man*2^(SC+1) - : (manSC1 - (W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 3))); // case3 - - // ========================================================================= - // PRE pipeline register (cycle 1): normalize + exc. - // ========================================================================= - localparam INI_EXPS_LO = 0; - localparam INI_SGNS_LO = INI_EXPS_LO + EXP_W; - localparam INI_NRO_LO = INI_SGNS_LO + 1; - localparam INI_W0SQ_LO = INI_NRO_LO + 1; - localparam INI_S0SQ_LO = INI_W0SQ_LO + W_BITS; - localparam INI_EXCSQ_LO = INI_S0SQ_LO + W_BITS; - localparam INI_FRM_LO = INI_EXCSQ_LO + 5; - localparam INI_ISD_LO = INI_FRM_LO + INST_FRM_BITS; - localparam INI_W = INI_ISD_LO + 1; - - wire [INI_W-1:0] ini_in; - assign ini_in[INI_EXPS_LO +: EXP_W] = exp_r0_sqrt; - assign ini_in[INI_SGNS_LO] = sign_r0_sq; - assign ini_in[INI_NRO_LO] = nr_offset0_sq; - assign ini_in[INI_W0SQ_LO +: W_BITS] = W0_sq; - assign ini_in[INI_S0SQ_LO +: W_BITS] = S0_sq; - assign ini_in[INI_EXCSQ_LO +: 5] = exc0_sq; - assign ini_in[INI_FRM_LO +: INST_FRM_BITS] = frm; - assign ini_in[INI_ISD_LO] = is_d; - - wire [INI_W-1:0] ini_out; - VX_pipe_register #(.DATAW (INI_W), .DEPTH (1)) pre_reg ( - .clk (clk), .reset (reset), .enable (enable && mask), - .data_in (ini_in), .data_out (ini_out) - ); - - // ========================================================================= - // INI pipeline register (cycle 2): pack SRT state. - // ========================================================================= - wire [EXP_W-1:0] i_exp_sq = ini_out[INI_EXPS_LO +: EXP_W]; - wire i_sgn_sq = ini_out[INI_SGNS_LO]; - wire i_nro_sq = ini_out[INI_NRO_LO]; - wire [W_BITS-1:0] i_W0_sq = ini_out[INI_W0SQ_LO +: W_BITS]; - wire [W_BITS-1:0] i_S0_sq = ini_out[INI_S0SQ_LO +: W_BITS]; - wire [4:0] i_exc_sq = ini_out[INI_EXCSQ_LO +: 5]; - wire [INST_FRM_BITS-1:0] i_frm = ini_out[INI_FRM_LO +: INST_FRM_BITS]; - wire i_isd = ini_out[INI_ISD_LO]; - - wire [STAGE_W-1:0] srt_stage [0:NSRT]; - wire [STAGE_W-1:0] pre_in; - - assign pre_in[W_LO +: CS_BITS] = {1'b0, i_W0_sq}; - assign pre_in[WC_LO +: CS_BITS] = '0; - assign pre_in[DS_LO +: W_BITS] = i_S0_sq; - assign pre_in[EXP_LO +: EXP_W] = i_exp_sq; - assign pre_in[SGN_LO] = i_sgn_sq; - assign pre_in[FRM_LO +: INST_FRM_BITS] = i_frm; - assign pre_in[EXC_LO +: 5] = i_exc_sq; - assign pre_in[NRO_LO] = i_nro_sq; - assign pre_in[ISD_LO] = i_isd; - - VX_pipe_register #(.DATAW (STAGE_W), .DEPTH (1)) ini_reg ( - .clk (clk), .reset (reset), .enable (enable && valid_ini), - .data_in (pre_in), .data_out (srt_stage[0]) - ); - - // ========================================================================= - // SRT stages 1..NR_STAGES (two NR steps each, carry-save W). Format-independent. - // ========================================================================= - for (genvar k = 0; k < NSRT; k++) begin : g_srt - // NR step j of the stage's first (A) and second (B) step: 2k and 2k + 1, or k alone with SPLIT - localparam JA = (SPLIT != 0) ? k : 2*k; - localparam JB = (SPLIT != 0) ? 0 : 2*k + 1; - localparam [W_BITS-1:0] ULP_A_NRO0 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 2 - JA); - localparam [W_BITS-1:0] ULP_B_NRO0 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 2 - JB); - localparam [W_BITS-1:0] ULP_A_NRO1 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 3 - JA); - localparam [W_BITS-1:0] ULP_B_NRO1 = W_BITS'(1) << (SUPER_SIG + SCALE_SQRT - 3 - JB); - - wire [CS_BITS-1:0] Ws_in = srt_stage[k][W_LO +: CS_BITS]; - wire [CS_BITS-1:0] Wc_in = srt_stage[k][WC_LO +: CS_BITS]; - wire [W_BITS-1:0] DS_in = srt_stage[k][DS_LO +: W_BITS]; - wire [EXP_W-1:0] exp_in = srt_stage[k][EXP_LO +: EXP_W]; - wire sgn_in = srt_stage[k][SGN_LO]; - wire [INST_FRM_BITS-1:0] frm_in = srt_stage[k][FRM_LO +: INST_FRM_BITS]; - wire [4:0] exc_in = srt_stage[k][EXC_LO +: 5]; - wire nro_in = srt_stage[k][NRO_LO]; - wire isd_in = srt_stage[k][ISD_LO]; - - wire [W_BITS-1:0] ulp_a = nro_in ? ULP_A_NRO1 : ULP_A_NRO0; - wire [W_BITS-1:0] ulp_b = nro_in ? ULP_B_NRO1 : ULP_B_NRO0; - - // --- Step A --- - wire [W_BITS-1:0] D_S_a30 = nro_in ? DS_in : {DS_in[W_BITS-2:0], 1'b0}; - wire [W_BITS-1:0] D_ulp_a = nro_in ? (ulp_a >> 1) : ulp_a; - wire [W_BITS-1:0] val_a_add = D_S_a30 - D_ulp_a; - wire [W_BITS-1:0] val_a_neg = D_S_a30 + D_ulp_a; - wire [W_BITS-1:0] DS_a_plus = DS_in + ulp_a; - wire [W_BITS-1:0] DS_a_minus = DS_in - ulp_a; - - wire [CS_BITS:0] W_a_sum = {1'b0, Ws_in} + {1'b0, Wc_in}; - wire q_a = ~W_a_sum[CS_BITS-1]; - - wire [CS_BITS-1:0] X_a = q_a ? {1'b1, ~val_a_neg} : {1'b0, val_a_add}; - wire [CS_BITS-1:0] W2s_a = {Ws_in[CS_BITS-2:0], q_a}; - wire [CS_BITS-1:0] W2c_a = {Wc_in[CS_BITS-2:0], 1'b0}; - wire [CS_BITS-1:0] Ws_a = W2s_a ^ W2c_a ^ X_a; - wire [W_BITS-1:0] Wca_raw = (W2s_a[W_BITS-1:0] & W2c_a[W_BITS-1:0]) | (W2c_a[W_BITS-1:0] & X_a[W_BITS-1:0]) | (W2s_a[W_BITS-1:0] & X_a[W_BITS-1:0]); - wire [CS_BITS-1:0] Wc_a = {Wca_raw, 1'b0}; - - wire [W_BITS-1:0] DS_a = q_a ? DS_a_plus : DS_a_minus; - - // --- Step B --- - wire [W_BITS-1:0] D_S_b30 = nro_in ? DS_a : {DS_a[W_BITS-2:0], 1'b0}; - wire [W_BITS-1:0] D_ulp_b = nro_in ? (ulp_b >> 1) : ulp_b; - wire [W_BITS-1:0] val_b_add = D_S_b30 - D_ulp_b; - wire [W_BITS-1:0] val_b_neg = D_S_b30 + D_ulp_b; - wire [W_BITS-1:0] DS_b_plus = DS_a + ulp_b; - wire [W_BITS-1:0] DS_b_minus = DS_a - ulp_b; - - wire [CS_BITS:0] W_b_sum = {1'b0, Ws_a} + {1'b0, Wc_a}; - wire q_b = ~W_b_sum[CS_BITS-1]; - - wire [CS_BITS-1:0] X_b = q_b ? {1'b1, ~val_b_neg} : {1'b0, val_b_add}; - wire [CS_BITS-1:0] W2s_b = {Ws_a[CS_BITS-2:0], q_b}; - wire [CS_BITS-1:0] W2c_b = {Wc_a[CS_BITS-2:0], 1'b0}; - wire [CS_BITS-1:0] Ws_b = W2s_b ^ W2c_b ^ X_b; - wire [W_BITS-1:0] Wcb_raw = (W2s_b[W_BITS-1:0] & W2c_b[W_BITS-1:0]) | (W2c_b[W_BITS-1:0] & X_b[W_BITS-1:0]) | (W2s_b[W_BITS-1:0] & X_b[W_BITS-1:0]); - wire [CS_BITS-1:0] Wc_b = {Wcb_raw, 1'b0}; - - wire [W_BITS-1:0] DS_b = q_b ? DS_b_plus : DS_b_minus; - - wire [STAGE_W-1:0] s_out; - assign s_out[W_LO +: CS_BITS] = (SPLIT != 0) ? Ws_a : Ws_b; - assign s_out[WC_LO +: CS_BITS] = (SPLIT != 0) ? Wc_a : Wc_b; - assign s_out[DS_LO +: W_BITS] = (SPLIT != 0) ? DS_a : DS_b; - assign s_out[EXP_LO +: EXP_W] = exp_in; - assign s_out[SGN_LO] = sgn_in; - assign s_out[FRM_LO +: INST_FRM_BITS] = frm_in; - assign s_out[EXC_LO +: 5] = exc_in; - assign s_out[NRO_LO] = nro_in; - assign s_out[ISD_LO] = isd_in; - - VX_pipe_register #(.DATAW (STAGE_W), .DEPTH (1)) srt_reg ( - .clk (clk), .reset (reset), - .enable (enable && mask_pipe[PRE_LATENCY+INI_LATENCY-1+k]), - .data_in (s_out), .data_out (srt_stage[k+1]) - ); - end - - // ========================================================================= - // CONV (combinational after srt_stage[NSRT]) - // ========================================================================= - wire [CS_BITS-1:0] Ws_cv = srt_stage[NSRT][W_LO +: CS_BITS]; - wire [CS_BITS-1:0] Wc_cv = srt_stage[NSRT][WC_LO +: CS_BITS]; - wire [W_BITS-1:0] DS_cv = srt_stage[NSRT][DS_LO +: W_BITS]; - wire [EXP_W-1:0] exp_cv = srt_stage[NSRT][EXP_LO +: EXP_W]; - wire sgn_cv = srt_stage[NSRT][SGN_LO]; - wire [INST_FRM_BITS-1:0] frm_cv = srt_stage[NSRT][FRM_LO +: INST_FRM_BITS]; - wire [4:0] exc_cv = srt_stage[NSRT][EXC_LO +: 5]; - wire nro_cv = srt_stage[NSRT][NRO_LO]; - wire isd_cv = srt_stage[NSRT][ISD_LO]; - - wire signed [CS_BITS:0] W_cv_sum = $signed(Ws_cv) + $signed(Wc_cv); - wire [W_BITS-1:0] W_cv = W_cv_sum[W_BITS-1:0]; - `UNUSED_VAR (W_cv_sum[CS_BITS:W_BITS]) - - // ---- SQRT CONV ---- - wire W_neg_sq = W_cv[W_BITS-1]; - wire [W_BITS-1:0] ulp_last = nro_cv ? W_BITS'(1) : W_BITS'(2); - wire [W_BITS-1:0] S_corr = W_neg_sq ? (DS_cv - ulp_last) : DS_cv; - - wire [W_BITS:0] W_cv_sx = {W_cv[W_BITS-1], W_cv}; - wire [W_BITS:0] W_D_sq = nro_cv ? ({1'b0, DS_cv} - {1'b0, ulp_last}) - : ({DS_cv, 1'b0} - {1'b0, ulp_last}); - wire [W_BITS:0] W_corr_sq31 = W_neg_sq ? (W_cv_sx + W_D_sq) : W_cv_sx; - `UNUSED_VAR (W_corr_sq31[W_BITS]) - wire sticky_sq_w = (W_corr_sq31[W_BITS-1:0] != '0); - - // S_corr leading bit at SQRT_LEAD; man=[LEAD -: act_sig], guard=[LEAD-act_sig], etc. - wire [SUPER_SIG-1:0] man_sq_d = S_corr[SQRT_LEAD -: SUPER_SIG]; - wire guard_sq_d = S_corr[SQRT_LEAD - SUPER_SIG]; - wire round_sq_d = S_corr[SQRT_LEAD - SUPER_SIG - 1]; - wire sticky_sq_d= (|S_corr[SQRT_LEAD - SUPER_SIG - 2 : 0]) | sticky_sq_w; - - wire [23:0] man_sq_s = S_corr[SQRT_LEAD -: 24]; - wire guard_sq_s = S_corr[SQRT_LEAD - 24]; - wire round_sq_s = S_corr[SQRT_LEAD - 25]; - wire sticky_sq_s = (|S_corr[SQRT_LEAD - 26 : 0]) | sticky_sq_w; - `UNUSED_VAR (S_corr[W_BITS-1:SQRT_LEAD+1]) - - wire signed [EXP_W-1:0] exp_res_sq = $signed(exp_cv); - - // ---- Unified CONV output (mux format) ---- - wire act_s = (HAS_D && !isd_cv); // active F32 extraction - wire [SUPER_SIG-1:0] man_cv_out = act_s ? SUPER_SIG'(man_sq_s) : man_sq_d; - wire guard_cv_out = act_s ? guard_sq_s : guard_sq_d; - wire round_cv_out = act_s ? round_sq_s : round_sq_d; - wire sticky_cv_out= act_s ? sticky_sq_s : sticky_sq_d; - wire signed [EXP_W-1:0] exp_res = exp_res_sq; - - // ========================================================================= - // CONV pipeline register - // ========================================================================= - // The subnormal shift comes from the exponent and the special cases alone, - // so it is made here and registered with the significand (between CONV - // and the rounding it was the unit's deepest cone: the 1 - exp subtract, - // the range compare, then the shift and the sticky OR; ASAP7 46 levels). - localparam SH_W = `CLOG2(SUPER_SIG + 2) + 1; - wire c_special = exc_cv[4] | exc_cv[3] | exc_cv[2]; // NaN, Inf, zero - wire c_result_sub = ($signed(exp_res) <= 0) & ~c_special; - wire c_is_sub = (SUBNORM_ENABLE != 0) & c_result_sub; - wire signed [EXP_W-1:0] c_damt = c_is_sub ? (EXP_W'(1) - exp_res) : '0; - wire c_huge = c_is_sub & ($signed(c_damt) >= $signed(EXP_W'(SUPER_SIG + 1))); - wire [SH_W-1:0] c_dsh = c_huge ? SH_W'(SUPER_SIG) : SH_W'(c_damt); - - localparam CONV_W = SUPER_SIG + 1 + 1 + 1 + EXP_W + 1 + INST_FRM_BITS + 5 + 1 + 3 + SH_W; - - wire [CONV_W-1:0] conv_in = {man_cv_out, guard_cv_out, round_cv_out, sticky_cv_out, - exp_res, sgn_cv, frm_cv, exc_cv, isd_cv, - c_result_sub, c_is_sub, c_huge, c_dsh}; - wire [CONV_W-1:0] conv_out; - VX_pipe_register #(.DATAW (CONV_W), .DEPTH (1)) conv_reg ( - .clk (clk), .reset (reset), .enable (enable && valid_conv), - .data_in (conv_in), .data_out (conv_out) - ); - - // ========================================================================= - // NRM stage: round, overflow/underflow, pack at active format. - // ========================================================================= - wire [SUPER_SIG-1:0] s_man; - wire s_guard, s_round, s_sticky; - wire [EXP_W-1:0] s_exp_bits; - wire s_sign; - wire [INST_FRM_BITS-1:0] s_frm; - wire [4:0] s_exc; - wire s_isd; - - wire result_sub, is_sub_res, huge_denorm; - wire [SH_W-1:0] dsh; - assign {s_man, s_guard, s_round, s_sticky, s_exp_bits, s_sign, s_frm, s_exc, s_isd, - result_sub, is_sub_res, huge_denorm, dsh} = conv_out; - wire signed [EXP_W-1:0] s_exp = $signed(s_exp_bits); - - wire act_d = HAS_D ? s_isd : 1'b0; // double result - - wire is_nan = s_exc[4]; - wire is_inf = s_exc[3]; - wire is_zero = s_exc[2]; - wire dz_flag = s_exc[1]; - wire nv_flag = s_exc[0]; - - // Subnormal handling (see VX_fdiv_unit): denormalize-then-round-once when - // SUBNORM_ENABLE; flush-to-zero otherwise. - // (result_sub, is_sub_res, huge_denorm and dsh: made ahead of the CONV register) - - // the bits below the new guard: [dsh-2:0] (none for dsh <= 1), as a thermometer - wire [SUPER_SIG-1:0] below_gmsk; - for (genvar i = 0; i < SUPER_SIG; ++i) begin : g_gmsk - assign below_gmsk[i] = (SH_W'(i + 1) < dsh); - end - wire [SUPER_SIG-1:0] sub_man = s_man >> dsh; - // the new guard: s_guard at dsh 0, else s_man[dsh-1] (none when huge) - wire [SUPER_SIG:0] man_g = {s_man, s_guard}; - wire sub_guard = ~huge_denorm & man_g[`CLOG2(SUPER_SIG + 1)'(dsh)]; // dsh <= SUPER_SIG - wire sub_sticky = (dsh == 0) ? (s_round | s_sticky) - : ((huge_denorm ? (|s_man) : (|(s_man & below_gmsk))) | s_guard | s_round | s_sticky); - - // With SPLIT the rounding starts a pipeline stage of its own. - localparam RB_W = SUPER_SIG + 2 + 1 + INST_FRM_BITS + EXP_W + 8; - wire [RB_W-1:0] rb_in = {sub_man, sub_guard, sub_sticky, s_sign, s_frm, s_exp, is_nan, is_inf, is_zero, - dz_flag, nv_flag, act_d, is_sub_res, result_sub}; - wire [RB_W-1:0] rb_out; - if (SPLIT != 0) begin : g_rnd_reg - VX_pipe_register #( - .DATAW (RB_W), - .DEPTH (1) - ) rnd_reg ( - .clk (clk), - .reset (reset), - .enable (enable && valid_rnd), - .data_in (rb_in), - .data_out (rb_out) - ); - end else begin : g_rnd_comb - assign rb_out = rb_in; - `UNUSED_VAR (valid_rnd) - end - wire [SUPER_SIG-1:0] r_sub_man; - wire r_sub_guard, r_sub_sticky, r_s_sign; - wire [INST_FRM_BITS-1:0] r_s_frm; - wire signed [EXP_W-1:0] r_s_exp; - wire r_is_nan, r_is_inf, r_is_zero, r_dz_flag, r_nv_flag, r_act_d, r_is_sub_res, r_result_sub; - assign {r_sub_man, r_sub_guard, r_sub_sticky, r_s_sign, r_s_frm, r_s_exp, r_is_nan, r_is_inf, r_is_zero, - r_dz_flag, r_nv_flag, r_act_d, r_is_sub_res, r_result_sub} = rb_out; - - // Round at the (possibly denormalized) active mantissa width. - wire [SUPER_SIG-1:0] abs_rounded; - wire round_sign, exact_zero, round_up; - VX_fp_rounding #(.DAT_WIDTH(SUPER_SIG)) u_rnd ( - .abs_value_i (r_sub_man), - .sign_i (r_s_sign), - .round_sticky_bits_i ({r_sub_guard, r_sub_sticky}), - .rnd_mode_i (r_s_frm), - .effective_subtraction_i(1'b0), - .abs_rounded_o (abs_rounded), - .sign_o (round_sign), - .exact_zero_o (exact_zero), - .round_up_o (round_up) - ); - - // The increment's carries are round_up AND an all-ones run of r_sub_man, so the - // exponent, the overflow test and the pack select do not wait for its carry chain. - wire sub_carry = r_sub_man[SUPER_MAN] ^ (round_up & (&r_sub_man[SUPER_MAN-1:0])); - wire norm_carry; - if (HAS_D) begin : g_rcarry_d - wire rc_d = round_up & (&r_sub_man); // 53-bit wrap (F64) - wire rc_s = r_sub_man[24] ^ (round_up & (&r_sub_man[23:0])); // carry out of 24-bit man (F32) - assign norm_carry = r_act_d ? rc_d : rc_s; - end else begin : g_rcarry_s - assign norm_carry = round_up & (&r_sub_man); // 24-bit wrap - end - - wire signed [EXP_W-1:0] r_s_exp_p1 = r_s_exp + EXP_W'(1); - wire signed [EXP_W-1:0] fin_exp = r_is_sub_res ? (sub_carry ? EXP_W'(1) : '0) - : (norm_carry ? r_s_exp_p1 : r_s_exp); - `UNUSED_VAR (fin_exp[EXP_W-1:8]) - `UNUSED_VAR (abs_rounded[SUPER_MAN]) - - wire [SUPER_MAN-1:0] fin_man_d = abs_rounded[SUPER_MAN-1:0]; - wire [22:0] fin_man_s = abs_rounded[22:0]; - - // a subnormal's exponent (0 or 1) never overflows - wire [EXP_W-1:0] act_allones = r_act_d ? EXP_W'(2047) : EXP_W'(255); - wire of_exp0 = ($signed(r_s_exp) >= $signed(act_allones)); - wire of_exp1 = ($signed(r_s_exp_p1) >= $signed(act_allones)); - wire of_flag = ~r_is_sub_res & (norm_carry ? of_exp1 : of_exp0) & ~r_is_nan & ~r_is_inf; - wire nx_flag = (r_sub_guard | r_sub_sticky) & ~r_is_nan & ~r_is_inf & ~r_is_zero; - wire uf_flag = r_result_sub & nx_flag; - wire ftz_flush = r_result_sub & (SUBNORM_ENABLE == 0); - - // Overflow result is max-normal vs infinity per rounding mode/sign (IEEE). - wire ovf_to_max = (r_s_frm == INST_FRM_RTZ) - | (r_s_frm == INST_FRM_RDN & ~round_sign) - | (r_s_frm == INST_FRM_RUP & round_sign); - - // F32 pack (always present) - wire [31:0] nan_s = 32'h7FC00000; - wire [31:0] inf_s = {round_sign, 8'hFF, 23'd0}; - wire [31:0] maxnorm_s = {round_sign, 8'hFE, 23'h7FFFFF}; - wire [31:0] zero_s = {round_sign, 31'd0}; - wire [31:0] norm_s = {round_sign, fin_exp[7:0], fin_man_s}; - - reg [31:0] res_s; - always @(*) begin - if (r_is_nan) res_s = nan_s; - else if (r_is_inf) res_s = inf_s; - else if (of_flag) res_s = ovf_to_max ? maxnorm_s : inf_s; - else if (r_is_zero | exact_zero | ftz_flush) res_s = zero_s; - else res_s = norm_s; - end - - // Pack into FLEN: F64 fills the width; F32 is NaN-boxed (upper bits ones). - wire [FLEN-1:0] nrm_result; - if (HAS_D) begin : g_pack_d - wire [63:0] nan_d = 64'h7FF8000000000000; - wire [63:0] inf_d = {round_sign, 11'h7FF, 52'd0}; - wire [63:0] maxnorm_d = {round_sign, 11'h7FE, 52'hFFFFFFFFFFFFF}; - wire [63:0] zero_d = {round_sign, 63'd0}; - wire [63:0] norm_d = {round_sign, fin_exp[10:0], fin_man_d}; - reg [63:0] res_d; - always @(*) begin - if (r_is_nan) res_d = nan_d; - else if (r_is_inf) res_d = inf_d; - else if (of_flag) res_d = ovf_to_max ? maxnorm_d : inf_d; - else if (r_is_zero | exact_zero | ftz_flush) res_d = zero_d; - else res_d = norm_d; - end - assign nrm_result = r_act_d ? FLEN'(res_d) : {{(FLEN-32){1'b1}}, res_s}; - end else begin : g_pack_s - assign nrm_result = FLEN'(res_s); - `UNUSED_VAR (fin_man_d) - end - - fflags_t nrm_fflags; - assign nrm_fflags.NV = EXCEPT_ENABLE & r_nv_flag; - assign nrm_fflags.DZ = EXCEPT_ENABLE & r_dz_flag; - assign nrm_fflags.OF = EXCEPT_ENABLE & of_flag; - assign nrm_fflags.UF = EXCEPT_ENABLE & uf_flag; - assign nrm_fflags.NX = EXCEPT_ENABLE & (nx_flag | of_flag | uf_flag); - - VX_pipe_register #(.DATAW (FLEN + `FP_FLAGS_BITS), .DEPTH (1)) nrm_reg ( - .clk (clk), .reset (reset), .enable (enable && valid_nrm), - .data_in ({nrm_result, nrm_fflags}), - .data_out ({result, fflags}) - ); - -endmodule diff --git a/hw/rtl/rtu/VX_rtu_pkg.sv b/hw/rtl/rtu/VX_rtu_pkg.sv index 872e3df571..c77db8d41f 100644 --- a/hw/rtl/rtu/VX_rtu_pkg.sv +++ b/hw/rtl/rtu/VX_rtu_pkg.sv @@ -93,9 +93,8 @@ package VX_rtu_pkg; // The reciprocals (1/det, inv_d) reuse VX_fdiv_unit through the same USE_DSP // knob as the FMAs. Its latency is a FIXED property of the active backend, so // it uses the BACKEND-keyed VX_CFG_RTU_FDIV_LATENCY (vendor xil_fdiv 28 / altera - // 15 / soft 17) — mirroring VX_CFG_FMA_LATENCY, NOT the FPU-type-keyed - // VX_CFG_FDIV_LATENCY (which would mis-size the RTL divider to the DPI model's - // 15). PE delay lines + the scheduler setup window scale with this. + // 15 / soft 17) — mirroring VX_CFG_FMA_LATENCY. PE delay lines + the scheduler + // setup window scale with this. localparam RTU_FDIV_LAT = `VX_CFG_RTU_FDIV_LATENCY; // ───────────────────────────────────────────────────────────────── diff --git a/hw/scripts/altera_ip_gen.sh b/hw/scripts/altera_ip_gen.sh index 36f3a706c9..90a8e06973 100755 --- a/hw/scripts/altera_ip_gen.sh +++ b/hw/scripts/altera_ip_gen.sh @@ -38,7 +38,6 @@ echo Generating IP cores for $FBITS #$CMD -name acl_fmul FPMul $EXP_BITS $MAN_BITS $CMD -name acl_fmadd FPMultAdd $EXP_BITS $MAN_BITS $CMD -name acl_fdiv FPDiv $EXP_BITS $MAN_BITS 0 - $CMD -name acl_fsqrt FPSqrt $EXP_BITS $MAN_BITS #$CMD -name acl_ftoi FPToFXP $EXP_BITS $MAN_BITS 32 0 1 #$CMD -name acl_ftou FPToFXP $EXP_BITS $MAN_BITS 32 0 0 #$CMD -name acl_itof FXPToFP 32 0 1 $EXP_BITS $MAN_BITS diff --git a/hw/scripts/check_ip_contracts.py b/hw/scripts/check_ip_contracts.py index c20ff7f8c6..0b10a38fac 100755 --- a/hw/scripts/check_ip_contracts.py +++ b/hw/scripts/check_ip_contracts.py @@ -35,7 +35,6 @@ RTL_ASSERTS = { 'xil_fma': ('hw/rtl/fpu/VX_fma_unit.sv', r'USE_VENDOR_IP\s*\|\|\s*\(LATENCY\s*==\s*(\d+)\)'), 'xil_fdiv': ('hw/rtl/fpu/VX_fdiv_unit.sv', r'USE_VENDOR_IP\s*\|\|\s*\(LATENCY\s*==\s*(\d+)\)'), - 'xil_fsqrt': ('hw/rtl/fpu/VX_fsqrt_unit.sv', r'USE_VENDOR_IP\s*\|\|\s*\(LATENCY\s*==\s*(\d+)\)'), 'xil_fmul': ('hw/rtl/tcu/dsp/VX_tcu_fedp_dsp.sv', r'localparam\s+FMUL_LATENCY\s*=\s*(\d+)'), 'xil_fadd': ('hw/rtl/tcu/dsp/VX_tcu_fedp_dsp.sv', r'localparam\s+FADD_LATENCY\s*=\s*(\d+)'), } @@ -43,8 +42,7 @@ # The configuration's latency of each core, when the configuration selects it. CONFIG_LATENCIES = { 'xil_fma': [('VX_CFG_FMA_LATENCY', 'VX_CFG_FPU_TYPE_DSP')], - 'xil_fdiv': [('VX_CFG_FDIV_LATENCY', 'VX_CFG_FPU_TYPE_DSP'), ('VX_CFG_RTU_FDIV_LATENCY', None)], - 'xil_fsqrt': [('VX_CFG_FSQRT_LATENCY', 'VX_CFG_FPU_TYPE_DSP')], + 'xil_fdiv': [('VX_CFG_RTU_FDIV_LATENCY', None)], } diff --git a/hw/scripts/xilinx_ip_gen.tcl b/hw/scripts/xilinx_ip_gen.tcl index 119cd8fec3..988f73ae89 100644 --- a/hw/scripts/xilinx_ip_gen.tcl +++ b/hw/scripts/xilinx_ip_gen.tcl @@ -34,9 +34,6 @@ file mkdir ${ip_dir} create_ip -name floating_point -vendor xilinx.com -library ip -version 7.1 -module_name xil_fdiv -dir ${ip_dir} set_property -dict [list CONFIG.Component_Name {xil_fdiv} CONFIG.Operation_Type {Divide} CONFIG.Flow_Control {NonBlocking} CONFIG.Has_ACLKEN {true} CONFIG.C_Has_UNDERFLOW {true} CONFIG.C_Has_OVERFLOW {true} CONFIG.C_Has_INVALID_OP {true} CONFIG.C_Has_DIVIDE_BY_ZERO {true} CONFIG.A_Precision_Type {Single} CONFIG.C_A_Exponent_Width {8} CONFIG.C_A_Fraction_Width {24} CONFIG.Result_Precision_Type {Single} CONFIG.C_Result_Exponent_Width {8} CONFIG.C_Result_Fraction_Width {24} CONFIG.C_Mult_Usage {No_Usage} CONFIG.Has_RESULT_TREADY {false} CONFIG.C_Latency {28} CONFIG.C_Rate {1}] [get_ips xil_fdiv] -create_ip -name floating_point -vendor xilinx.com -library ip -version 7.1 -module_name xil_fsqrt -dir ${ip_dir} -set_property -dict [list CONFIG.Component_Name {xil_fsqrt} CONFIG.Operation_Type {Square_root} CONFIG.Flow_Control {NonBlocking} CONFIG.Has_ACLKEN {true} CONFIG.C_Has_INVALID_OP {true} CONFIG.A_Precision_Type {Single} CONFIG.C_A_Exponent_Width {8} CONFIG.C_A_Fraction_Width {24} CONFIG.Result_Precision_Type {Single} CONFIG.C_Result_Exponent_Width {8} CONFIG.C_Result_Fraction_Width {24} CONFIG.C_Mult_Usage {No_Usage} CONFIG.Has_RESULT_TREADY {false} CONFIG.C_Latency {28} CONFIG.C_Rate {1}] [get_ips xil_fsqrt] - create_ip -name floating_point -vendor xilinx.com -library ip -version 7.1 -module_name xil_fma -dir ${ip_dir} set_property -dict [list CONFIG.Component_Name {xil_fma} CONFIG.Operation_Type {FMA} CONFIG.Add_Sub_Value {Add} CONFIG.Flow_Control {NonBlocking} CONFIG.Has_ACLKEN {true} CONFIG.C_Has_UNDERFLOW {true} CONFIG.C_Has_OVERFLOW {true} CONFIG.C_Has_INVALID_OP {true} CONFIG.Has_A_TUSER {false} CONFIG.A_Precision_Type {Single} CONFIG.C_A_Exponent_Width {8} CONFIG.C_A_Fraction_Width {24} CONFIG.Result_Precision_Type {Single} CONFIG.C_Result_Exponent_Width {8} CONFIG.C_Result_Fraction_Width {24} CONFIG.C_Mult_Usage {Medium_Usage} CONFIG.Has_RESULT_TREADY {false} CONFIG.C_Latency {16} CONFIG.C_Rate {1} CONFIG.A_TUSER_Width {1}] [get_ips xil_fma] diff --git a/hw/scripts/xilinx_ip_stubs.sv b/hw/scripts/xilinx_ip_stubs.sv index 4b5860da1a..d1966e6963 100644 --- a/hw/scripts/xilinx_ip_stubs.sv +++ b/hw/scripts/xilinx_ip_stubs.sv @@ -42,21 +42,6 @@ module xil_fdiv ( ); endmodule -(* black_box, fixed_latency = 28, clock = "aclk", clock_enable = "aclken", - data_in = "s_axis_a_tdata", - data_out = "m_axis_result_tdata m_axis_result_tuser", - tie = "s_axis_a_tvalid=1", pure_pipeline *) -module xil_fsqrt ( - input wire aclk, - input wire aclken, - input wire s_axis_a_tvalid, - input wire [31:0] s_axis_a_tdata, - output wire m_axis_result_tvalid, - output wire [31:0] m_axis_result_tdata, - output wire [0:0] m_axis_result_tuser // invalid -); -endmodule - (* black_box, fixed_latency = 16, clock = "aclk", clock_enable = "aclken", data_in = "s_axis_a_tdata s_axis_b_tdata s_axis_c_tdata", data_out = "m_axis_result_tdata m_axis_result_tuser", diff --git a/hw/syn/firesim/Makefile b/hw/syn/firesim/Makefile index d093714690..99f7138c85 100644 --- a/hw/syn/firesim/Makefile +++ b/hw/syn/firesim/Makefile @@ -247,7 +247,7 @@ PLATFORM_DEFINES += -DPLATFORM_MEMORY_ID_WIDTH=4 # latency in place of xil_fdiv's. ifeq ($(FIRESIM_PLATFORM), aved) PLATFORM_DEFINES += -DVX_CFG_FPU_TYPE_STD -DVX_CFG_RTU_USE_DSP=0 -DVX_CFG_RTU_FDIV_LATENCY=17 -VENDOR_FP_UNITS := VX_fma_unit.sv VX_fdiv_unit.sv VX_fsqrt_unit.sv +VENDOR_FP_UNITS := VX_fma_unit.sv VX_fdiv_unit.sv endif # Vortex's performance counters are the only view inside the core that does not diff --git a/hw/syn/foldsim/Makefile b/hw/syn/foldsim/Makefile index 24d34d7ec2..922f8c8e5b 100644 --- a/hw/syn/foldsim/Makefile +++ b/hw/syn/foldsim/Makefile @@ -222,7 +222,7 @@ $(IP_DIR)/component.xml: $(KERNEL_SRCS) $(KERNEL_VH) $(OOC_XDC) $(wildcard $(FOL cd $(BUILD_DIR) && TOOL_DIR=$(SCRIPT_DIR) $(VIVADO) -mode batch -nojournal -nolog \ -source $(VORTEX_HOME)/hw/syn/xilinx/aved/package_ip.tcl \ -tclargs foldsim_afu $(KERNEL_SRCS) . $(DEVICE) ooc-xdc=$(OOC_XDC) \ - $$(grep -qE '^ *xil_f(ma|div|sqrt|mul|add) ' $(GEN_SV) || echo no-vendor-ip) + $$(grep -qE '^ *xil_f(ma|div|mul|add) ' $(GEN_SV) || echo no-vendor-ip) # foldsim --slr-groups writes a floorplan that keeps each threaded copy whole # in one SLR; the implementation applies it before opt_design (floorplan.tcl). @@ -238,7 +238,7 @@ ooc: $(KERNEL_SRCS) cd $(OOC_DIR) && TOOL_DIR=$(SCRIPT_DIR) $(FLOORPLAN_ENV) $(VIVADO) -mode batch -nojournal -log vivado.log \ -source $(SRC_DIR)/ooc.tcl -tclargs $(KERNEL_SRCS) $(DEVICE) \ $$(python3 -c 'print(round(1000 / $(FOLDSIM_FREQ), 3))') \ - $$(grep -qE '^ *xil_f(ma|div|sqrt|mul|add) ' $(GEN_SV) || echo no-vendor-ip) + $$(grep -qE '^ *xil_f(ma|div|mul|add) ' $(GEN_SV) || echo no-vendor-ip) @grep -A2 'WNS(ns)' $(OOC_DIR)/routed_timing_summary.rpt | tail -1 $(CFG): FORCE diff --git a/hw/syn/xilinx/aved/package_ip.tcl b/hw/syn/xilinx/aved/package_ip.tcl index ada3047e57..f07f15ab4d 100644 --- a/hw/syn/xilinx/aved/package_ip.tcl +++ b/hw/syn/xilinx/aved/package_ip.tcl @@ -86,7 +86,7 @@ if {$ooc_xdc ne ""} { # alongside the RTL. The set matches the XRT flow's package_kernel.tcl. if {$vendor_ip} { set ip_files [list] - foreach ip {xil_fdiv xil_fma xil_fsqrt xil_fmul xil_fadd} { + foreach ip {xil_fdiv xil_fma xil_fmul xil_fadd} { lappend ip_files [file normalize "${build_dir}/ip/${ip}/${ip}.xci"] } add_files -verbose -norecurse -fileset [get_filesets sources_1] $ip_files diff --git a/hw/syn/xilinx/dut/project.tcl b/hw/syn/xilinx/dut/project.tcl index 7a21f3bd1c..2df113fb94 100644 --- a/hw/syn/xilinx/dut/project.tcl +++ b/hw/syn/xilinx/dut/project.tcl @@ -182,7 +182,6 @@ proc run_setup {} { set ip_dir $::env(FPU_IP) add_files -norecurse -verbose ${ip_dir}/xil_fma/xil_fma.xci add_files -norecurse -verbose ${ip_dir}/xil_fdiv/xil_fdiv.xci - add_files -norecurse -verbose ${ip_dir}/xil_fsqrt/xil_fsqrt.xci add_files -norecurse -verbose ${ip_dir}/xil_fmul/xil_fmul.xci add_files -norecurse -verbose ${ip_dir}/xil_fadd/xil_fadd.xci } diff --git a/hw/syn/xilinx/xrt/package_kernel.tcl b/hw/syn/xilinx/xrt/package_kernel.tcl index d9b9777c72..9d73894251 100644 --- a/hw/syn/xilinx/xrt/package_kernel.tcl +++ b/hw/syn/xilinx/xrt/package_kernel.tcl @@ -67,7 +67,6 @@ set obj [get_filesets sources_1] set ip_files [list \ [file normalize "${build_dir}/ip/xil_fdiv/xil_fdiv.xci"] \ [file normalize "${build_dir}/ip/xil_fma/xil_fma.xci"] \ - [file normalize "${build_dir}/ip/xil_fsqrt/xil_fsqrt.xci"] \ [file normalize "${build_dir}/ip/xil_fmul/xil_fmul.xci"] \ [file normalize "${build_dir}/ip/xil_fadd/xil_fadd.xci"] \ ] diff --git a/hw/unittest/Makefile b/hw/unittest/Makefile index ee934ec44d..42cce04068 100644 --- a/hw/unittest/Makefile +++ b/hw/unittest/Makefile @@ -28,9 +28,7 @@ all: $(MAKE) -C cp_core $(MAKE) -C fma_unit $(MAKE) -C fdiv_unit - $(MAKE) -C fsqrt_unit $(MAKE) -C fcvt_unit - $(MAKE) -C fdivsqrt_unit $(MAKE) -C tex_lerp $(MAKE) -C tfu_unit $(MAKE) -C mem_req_pending @@ -66,9 +64,7 @@ run: $(MAKE) -C cp_core run $(MAKE) -C fma_unit run $(MAKE) -C fdiv_unit run - $(MAKE) -C fsqrt_unit run $(MAKE) -C fcvt_unit run - $(MAKE) -C fdivsqrt_unit run $(MAKE) -C tex_lerp run $(MAKE) -C tfu_unit run $(MAKE) -C mem_req_pending run @@ -90,20 +86,10 @@ run-cp: run-fpu: $(MAKE) -C fma_unit run $(MAKE) -C fdiv_unit run - $(MAKE) -C fsqrt_unit run $(MAKE) -C fdiv_unit clean $(MAKE) -C fdiv_unit run LATENCY=31 SPLIT=1 $(MAKE) -C fdiv_unit clean - $(MAKE) -C fsqrt_unit clean - $(MAKE) -C fsqrt_unit run LATENCY=31 SPLIT=1 - $(MAKE) -C fsqrt_unit clean - $(MAKE) -C fsqrt_unit run FLEN=64 LATENCY=32 - $(MAKE) -C fsqrt_unit clean $(MAKE) -C fcvt_unit run - $(MAKE) -C fdivsqrt_unit run - $(MAKE) -C fdivsqrt_unit clean - $(MAKE) -C fdivsqrt_unit run FLEN=64 LATENCY=32 - $(MAKE) -C fdivsqrt_unit clean # CTA dispatch, its warp lane records checked: compute launches, then compute # and lane-payload launches interleaved and back to back at 16 threads (a @@ -290,9 +276,7 @@ clean: $(MAKE) -C cp_core clean $(MAKE) -C fma_unit clean $(MAKE) -C fdiv_unit clean - $(MAKE) -C fsqrt_unit clean $(MAKE) -C fcvt_unit clean - $(MAKE) -C fdivsqrt_unit clean $(MAKE) -C tex_lerp clean $(MAKE) -C tfu_unit clean $(MAKE) -C mem_req_pending clean diff --git a/hw/unittest/fdivsqrt_unit/Makefile b/hw/unittest/fdivsqrt_unit/Makefile deleted file mode 100644 index 000d15b1fe..0000000000 --- a/hw/unittest/fdivsqrt_unit/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -ROOT_DIR := $(realpath ../../..) -include $(ROOT_DIR)/config.mk - -LATENCY ?= 17 -FLEN ?= 32 - -PROJECT := fdivsqrt_unit - -RTL_DIR := $(VORTEX_HOME)/hw/rtl -SRC_DIR := $(VORTEX_HOME)/hw/unittest/$(PROJECT) - -LDFLAGS += $(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/softfloat.a - -CXXFLAGS := -I$(SRC_DIR) -I$(VORTEX_HOME)/hw/unittest/common -I$(SW_COMMON_DIR) -CXXFLAGS += -I$(THIRD_PARTY_DIR)/softfloat/source/include -CXXFLAGS += -DLATENCY=$(LATENCY) -DFLEN=$(FLEN) - -PARAMS := -GLATENCY=$(LATENCY) -GFLEN=$(FLEN) - -CONFIGS += -DSIMULATION - -SRCS += $(SW_COMMON_DIR)/softfloat_ext.cpp -SRCS += $(SW_COMMON_DIR)/rvfloats.cpp -SRCS += $(SRC_DIR)/main.cpp - -RTL_PKGS += $(RTL_DIR)/VX_gpu_pkg.sv $(RTL_DIR)/fpu/VX_fpu_pkg.sv -RTL_INCLUDE := -I$(ROOT_DIR)/sw -I$(RTL_DIR) -I$(RTL_DIR)/libs -RTL_INCLUDE += -I$(RTL_DIR)/fpu -I$(SRC_DIR) - -# Generated headers (VX_config.vh, VX_types.vh) live in the build tree; add them -# as an include-search path only, not a source-discovery root, so the recursive -# RTL find never descends into hw/syn build artifacts. -VL_FLAGS += -I$(ROOT_DIR)/hw - -TOP := VX_fdivsqrt_unit - -include ../common.mk diff --git a/hw/unittest/fdivsqrt_unit/main.cpp b/hw/unittest/fdivsqrt_unit/main.cpp deleted file mode 100644 index 20aa15af27..0000000000 --- a/hw/unittest/fdivsqrt_unit/main.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright © 2019-2023 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Functional test for the merged VX_fdivsqrt_unit: exercises both FDIV and -// FSQRT through the is_sqrt port and checks bit-exact result/fflags against the -// softfloat (rvfloats) RISC-V golden across all rounding modes. Strict check. -// F32 operands always; F64 operands too when built with FLEN=64. - -#include "VVX_fdivsqrt_unit.h" -#include "vl_simulator.h" -#include "rvfloats.h" - -#include -#include -#include -#include -#include -#include - -#ifndef LATENCY -#define LATENCY 17 -#endif - -#ifndef FLEN -#define FLEN 32 -#endif - -using Device = VVX_fdivsqrt_unit; - -namespace { - -struct TV { uint64_t a, b; uint32_t frm; bool sqrt, dbl; }; -struct Golden { uint64_t res, a, b; uint32_t fflags, frm; bool sqrt, dbl; }; - -const uint32_t kSpecials[] = { - 0x00000000, 0x80000000, 0x3f800000, 0xbf800000, 0x40000000, 0xc0000000, - 0x7f800000, 0xff800000, 0x7fc00000, 0x7fa00000, - 0x00000001, 0x80000001, 0x007fffff, 0x807fffff, 0x00800000, 0x80800000, - 0x7f7fffff, 0xff7fffff, 0x40490fdb, 0x3dcccccd, 0x41200000, 0x42c80000, -}; - -// Exact squares (sqrt sets no NX), both radicand exponent parities and both -// significand ranges of the scaled radicand. -const uint32_t kSquares[] = { - 0x40800000, 0x40100000, 0x3e800000, 0x40c80000, 0x3fc80000, 0x42f20000, - 0x41100000, 0x43800000, 0x4f800000, 0x00000002, -}; - -#if FLEN >= 64 -const uint64_t kSpecialsD[] = { - 0x0000000000000000, 0x8000000000000000, 0x3ff0000000000000, 0xbff0000000000000, - 0x4000000000000000, 0xc000000000000000, 0x7ff0000000000000, 0xfff0000000000000, - 0x7ff8000000000000, 0x7ff4000000000000, 0x0000000000000001, 0x8000000000000001, - 0x000fffffffffffff, 0x800fffffffffffff, 0x0010000000000000, 0x8010000000000000, - 0x7fefffffffffffff, 0xffefffffffffffff, 0x400921fb54442d18, 0x3fb999999999999a, - 0x4024000000000000, 0x4059000000000000, -}; - -const uint64_t kSquaresD[] = { - 0x4010000000000000, 0x4002000000000000, 0x3fd0000000000000, 0x4019000000000000, - 0x3ff9000000000000, 0x405e400000000000, 0x4022000000000000, 0x4070000000000000, - 0x43f0000000000000, 0x0000000000000004, -}; -#endif - -} // namespace - -int main(int argc, char** argv) { - Verilated::commandArgs(argc, argv); - - size_t num_random = 150000; - if (argc > 1) { - long v = std::strtol(argv[1], nullptr, 10); - if (v > 0) num_random = static_cast(v); - } - - std::vector tests; - // directed DIV pairs - for (uint32_t a : kSpecials) { - for (uint32_t b : kSpecials) { - for (uint32_t f = 0; f < 5; ++f) { - tests.push_back({a, b, f, false, false}); - } - } - } - // directed SQRT - for (uint32_t a : kSpecials) { - for (uint32_t f = 0; f < 5; ++f) { - tests.push_back({a, 0, f, true, false}); - } - } - for (uint32_t a : kSquares) { - for (uint32_t f = 0; f < 5; ++f) { - tests.push_back({a, 0, f, true, false}); - } - } - // random: alternate div / sqrt - std::mt19937 rng(0xD1D50Fu); - for (size_t i = 0; i < num_random; ++i) { - bool sq = (i & 1); - tests.push_back({static_cast(rng()), static_cast(rng()), - static_cast(i % 5), sq, false}); - } -#if FLEN >= 64 - for (uint64_t a : kSpecialsD) { - for (uint64_t b : kSpecialsD) { - for (uint32_t f = 0; f < 5; ++f) { - tests.push_back({a, b, f, false, true}); - } - } - } - for (uint64_t a : kSpecialsD) { - for (uint32_t f = 0; f < 5; ++f) { - tests.push_back({a, 0, f, true, true}); - } - } - for (uint64_t a : kSquaresD) { - for (uint32_t f = 0; f < 5; ++f) { - tests.push_back({a, 0, f, true, true}); - } - } - std::mt19937_64 rng64(0xD1D50F64u); - for (size_t i = 0; i < num_random; ++i) { - bool sq = (i & 1); - tests.push_back({rng64(), rng64(), static_cast(i % 5), sq, true}); - } -#endif - - const size_t N = tests.size(); - - vl_simulator sim; - uint64_t ticks = 0; - sim->enable = 1; sim->mask = 0; sim->fmt = 0; sim->frm = 0; - sim->dataa = 0; sim->datab = 0; sim->is_sqrt = 0; - ticks = sim.reset(ticks); - - std::deque fifo; - size_t feed = 0, checked = 0, errors = 0, e_div = 0, e_sqrt = 0; - - for (size_t c = 0; c < N + LATENCY; ++c) { - if (feed < N) { - const TV& t = tests[feed]; - sim->dataa = t.a; sim->datab = t.b; sim->frm = t.frm; sim->fmt = t.dbl ? 1 : 0; - sim->is_sqrt = t.sqrt ? 1 : 0; sim->mask = 1; - uint32_t ff = 0; - uint64_t r; - if (t.dbl) { - r = t.sqrt ? rv_fsqrt_d(t.a, t.frm, &ff) - : rv_fdiv_d(t.a, t.b, t.frm, &ff); - } else { - uint32_t a = static_cast(t.a), b = static_cast(t.b); - r = t.sqrt ? rv_fsqrt_s(a, t.frm, &ff) - : rv_fdiv_s(a, b, t.frm, &ff); - } - fifo.push_back({r, t.a, t.b, ff, t.frm, t.sqrt, t.dbl}); - ++feed; - } else { - sim->mask = 0; - } - sim->enable = 1; - ticks = sim.step(ticks, 2); - - if (c >= (size_t)(LATENCY - 1) && !fifo.empty()) { - Golden g = fifo.front(); fifo.pop_front(); - uint64_t got_r = sim->result; - uint32_t got_f = sim->fflags; - if (!g.dbl) { - got_r &= 0xffffffffull; - } - if (got_r != g.res || got_f != g.fflags) { - if (g.sqrt) ++e_sqrt; else ++e_div; - if (errors < 20) { - printf("MISMATCH %s.%c a=%016llx b=%016llx frm=%u : got res=%016llx ff=%02x exp res=%016llx ff=%02x\n", - g.sqrt ? "fsqrt" : "fdiv ", g.dbl ? 'd' : 's', - (unsigned long long)g.a, (unsigned long long)g.b, g.frm, - (unsigned long long)got_r, got_f, (unsigned long long)g.res, g.fflags); - } - ++errors; - } - ++checked; - } - } - - printf("fdivsqrt: checked=%zu errors=%zu [div=%zu sqrt=%zu]\n", - checked, errors, e_div, e_sqrt); - printf("%s\n", errors ? "FAILED" : "PASSED"); - return errors ? 1 : 0; -} diff --git a/hw/unittest/fsqrt_unit/Makefile b/hw/unittest/fsqrt_unit/Makefile deleted file mode 100644 index 754c5e5b8f..0000000000 --- a/hw/unittest/fsqrt_unit/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -ROOT_DIR := $(realpath ../../..) -include $(ROOT_DIR)/config.mk - -LATENCY ?= 17 -FLEN ?= 32 - -PROJECT := fsqrt_unit - -RTL_DIR := $(VORTEX_HOME)/hw/rtl -SRC_DIR := $(VORTEX_HOME)/hw/unittest/$(PROJECT) - -LDFLAGS += $(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/softfloat.a - -CXXFLAGS := -I$(SRC_DIR) -I$(VORTEX_HOME)/hw/unittest/common -I$(SW_COMMON_DIR) -CXXFLAGS += -I$(THIRD_PARTY_DIR)/softfloat/source/include -CXXFLAGS += -DLATENCY=$(LATENCY) -DFLEN=$(FLEN) - -PARAMS := -GLATENCY=$(LATENCY) -GFLEN=$(FLEN) - -CONFIGS += -DSIMULATION - -ifdef SPLIT -PARAMS += -GSPLIT=$(SPLIT) -endif - -ifdef LEAN -PARAMS += -GSUBNORM_ENABLE=0 -GEXCEPT_ENABLE=0 -CXXFLAGS += -DLEAN -endif - -SRCS += $(SW_COMMON_DIR)/softfloat_ext.cpp -SRCS += $(SW_COMMON_DIR)/rvfloats.cpp -SRCS += $(SRC_DIR)/main.cpp - -RTL_PKGS += $(RTL_DIR)/VX_gpu_pkg.sv $(RTL_DIR)/fpu/VX_fpu_pkg.sv -RTL_INCLUDE := -I$(ROOT_DIR)/sw -I$(RTL_DIR) -I$(RTL_DIR)/libs -RTL_INCLUDE += -I$(RTL_DIR)/fpu -I$(SRC_DIR) - -# Generated headers (VX_config.vh, VX_types.vh) live in the build tree; add them -# as an include-search path only, not a source-discovery root, so the recursive -# RTL find never descends into hw/syn build artifacts. -VL_FLAGS += -I$(ROOT_DIR)/hw - -TOP := VX_fsqrt_unit - -include ../common.mk diff --git a/hw/unittest/fsqrt_unit/main.cpp b/hw/unittest/fsqrt_unit/main.cpp deleted file mode 100644 index fb824149ac..0000000000 --- a/hw/unittest/fsqrt_unit/main.cpp +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright © 2019-2023 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Functional test for VX_fsqrt_unit (F32 ops; F64 ops too when FLEN=64): drives random + directed vectors through -// the fixed-latency pipeline and checks bit-exact result/fflags against the -// softfloat (rvfloats) RISC-V golden FSQRT across all rounding modes. Strict -// check; mismatches bucketed by class for actionability. - -#include "VVX_fsqrt_unit.h" -#include "vl_simulator.h" -#include "rvfloats.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifndef LATENCY -#define LATENCY 17 -#endif - -using Device = VVX_fsqrt_unit; - -namespace { - -struct TV { uint32_t a, frm; }; -struct Golden { uint32_t res, fflags, a, frm; }; - -const uint32_t kSpecials[] = { - 0x00000000, 0x80000000, 0x3f800000, 0xbf800000, 0x40000000, 0x40800000, - 0x40490fdb, 0x7f800000, 0xff800000, 0x7fc00000, 0x7fa00000, - 0x00000001, 0x80000001, 0x007fffff, 0x807fffff, 0x00800000, 0x80800000, - 0x7f7fffff, 0xff7fffff, 0x3dcccccd, 0x41200000, 0x42c80000, -}; - -inline int fclass(uint32_t x) { // 0=zero 1=sub 2=norm 3=inf 4=nan - uint32_t e = (x >> 23) & 0xFF, m = x & 0x7FFFFF; - if (e == 0) return m ? 1 : 0; - if (e == 0xFF) return m ? 4 : 3; - return 2; -} -inline uint32_t flush_sub(uint32_t x) { - return (((x >> 23) & 0xFF) == 0 && (x & 0x7FFFFF)) ? (x & 0x80000000u) : x; -} - -} // namespace - -int main(int argc, char** argv) { - Verilated::commandArgs(argc, argv); - - size_t num_random = 200000; - if (argc > 1) { - long v = std::strtol(argv[1], nullptr, 10); - if (v > 0) num_random = static_cast(v); - } - - std::vector tests; - for (uint32_t a : kSpecials) - for (uint32_t f = 0; f < 5; ++f) - tests.push_back({a, f}); - std::mt19937 rng(0x5EED1234u); - for (size_t i = 0; i < num_random; ++i) - tests.push_back({static_cast(rng()), static_cast(i % 5)}); - -#ifdef LEAN - // lean: finite, non-exceptional radicands with finite result; FTZ + no fflags. - { std::vector f; for (auto& t : tests) { - if (fclass(t.a) != 2) continue; // normal operands only (RTU domain) - uint32_t ff = 0; (void)rv_fsqrt_s(t.a, t.frm, &ff); - if (ff & 0x18) continue; // skip NV (negative radicand) - f.push_back(t); - } tests.swap(f); } -#endif - - const size_t N = tests.size(); - - vl_simulator sim; - uint64_t ticks = 0; - sim->enable = 1; sim->mask = 0; sim->fmt = 0; sim->frm = 0; sim->dataa = 0; - ticks = sim.reset(ticks); - - std::deque fifo; - size_t feed = 0, checked = 0, errors = 0; - size_t e_uf = 0, e_subin = 0, e_special = 0, e_normal = 0; // mismatch buckets - - for (size_t c = 0; c < N + LATENCY; ++c) { - if (feed < N) { - const TV& t = tests[feed]; - sim->dataa = t.a; sim->frm = t.frm; sim->fmt = 0; sim->mask = 1; - uint32_t ff = 0; - uint32_t ga = t.a; -#ifdef LEAN - ga = flush_sub(t.a); -#endif - uint32_t r = rv_fsqrt_s(ga, t.frm, &ff); -#ifdef LEAN - r = flush_sub(r); ff = 0; -#endif - fifo.push_back({r, ff, t.a, t.frm}); - ++feed; - } else { - sim->mask = 0; - } - sim->enable = 1; - ticks = sim.step(ticks, 2); - - if (c >= (size_t)(LATENCY - 1) && !fifo.empty()) { - Golden g = fifo.front(); fifo.pop_front(); - uint32_t got_r = sim->result, got_f = sim->fflags; - if (got_r != g.res || got_f != g.fflags) { - if (g.fflags & 0x2) ++e_uf; - else if (fclass(g.a) == 1) ++e_subin; - else if (fclass(g.a) != 2) ++e_special; - else ++e_normal; - if (errors < 20) - printf("MISMATCH fsqrt a=%08x frm=%u : got res=%08x ff=%02x exp res=%08x ff=%02x\n", - g.a, g.frm, got_r, got_f, g.res, g.fflags); - ++errors; - } - ++checked; - } - } - - printf("fsqrt_unit: checked=%zu errors=%zu [underflow=%zu subnormal-input=%zu special-operand=%zu normal=%zu]\n", - checked, errors, e_uf, e_subin, e_special, e_normal); - -#if (FLEN == 64) && !defined(LEAN) - // F64 operands (fmt D) in an F64-wide unit: directed specials, exact squares - // (k^2 and k^2/4: an exact root must not raise NX nor round up) and random - // patterns, all rounding modes, against the softfloat RISC-V FSQRT.D. - size_t checked_d = 0, errors_d = 0; - { - const uint64_t kSpecialsD[] = { - 0x0000000000000000ull, 0x8000000000000000ull, 0x3ff0000000000000ull, 0xbff0000000000000ull, - 0x4000000000000000ull, 0x4010000000000000ull, 0x4059000000000000ull, 0x400921fb54442d18ull, - 0x7ff0000000000000ull, 0xfff0000000000000ull, 0x7ff8000000000000ull, 0x7ff4000000000000ull, - 0x0000000000000001ull, 0x000fffffffffffffull, 0x0010000000000000ull, 0x7fefffffffffffffull, - 0x3fb999999999999aull, 0x3fd0000000000000ull }; - struct TD { uint64_t a; uint32_t frm; }; - std::vector td; - for (uint64_t a : kSpecialsD) - for (uint32_t f = 0; f < 5; ++f) - td.push_back({a, f}); - for (uint64_t k = 1; k < 4000; ++k) { - double d = double(k) * double(k) * ((k & 1) ? 1.0 : 0.25); - uint64_t b; std::memcpy(&b, &d, sizeof(b)); - td.push_back({b, static_cast(k % 5)}); - } - std::mt19937_64 rng64(0x5EED64ull); - for (size_t i = 0; i < num_random / 2; ++i) - td.push_back({rng64(), static_cast(i % 5)}); - struct GD { uint64_t res; uint32_t ff; uint64_t a; uint32_t frm; }; - std::deque fd; - const size_t ND = td.size(); - for (size_t c = 0; c < ND + LATENCY; ++c) { - if (c < ND) { - sim->dataa = td[c].a; sim->frm = td[c].frm; sim->fmt = 1; sim->mask = 1; // INST_FMT_D - uint32_t ff = 0; - uint64_t r = rv_fsqrt_d(td[c].a, td[c].frm, &ff); - fd.push_back({r, ff, td[c].a, td[c].frm}); - } else { - sim->mask = 0; - } - sim->enable = 1; - ticks = sim.step(ticks, 2); - if (c >= (size_t)(LATENCY - 1) && !fd.empty()) { - GD g = fd.front(); fd.pop_front(); - uint64_t got_r = sim->result; - uint32_t got_f = sim->fflags; - if (got_r != g.res || got_f != g.ff) { - if (errors_d < 20) - printf("MISMATCH fsqrt.d a=%016llx frm=%u : got res=%016llx ff=%02x exp res=%016llx ff=%02x\n", - (unsigned long long)g.a, g.frm, (unsigned long long)got_r, got_f, - (unsigned long long)g.res, g.ff); - ++errors_d; - } - ++checked_d; - } - } - } - printf("fsqrt_unit F64: checked=%zu errors=%zu\n", checked_d, errors_d); - errors += errors_d; -#endif - printf("%s\n", errors ? "FAILED" : "PASSED"); - return errors ? 1 : 0; -} diff --git a/profiles/a100.json b/profiles/a100.json index 4589cf3ca7..71ac2cdaac 100644 --- a/profiles/a100.json +++ b/profiles/a100.json @@ -9,8 +9,6 @@ "VX_CFG_NUM_ALU_LANES": 16, "VX_CFG_NUM_FPU_LANES": 16, "VX_CFG_NUM_LSU_LANES": 8, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_FCVT_PE_RATIO": 4, "VX_CFG_FMA64_PE_RATIO": 2, "VX_CFG_DCACHE_SIZE": 196608, @@ -64,7 +62,7 @@ }, "sources": { "NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH": "108 SMs, 64 resident warps/SM, 4 schedulers x 32 lanes (NVIDIA A100 Tensor Core GPU Architecture whitepaper, Table 3)", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and all type conversions not to or from 8/16-bit integers (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 4", + "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: all type conversions not to or from 8/16-bit integers (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 4", "DCACHE_NUM_BANKS": "128 B per clock of L1 data per SM (A100 whitepaper): 4 banks of the 32 B dcache word. The default (one bank per LSU request channel) gives 8, twice the part", "DCACHE_SIZE": "192 KB combined L1/shared per SM (whitepaper): 6 ways over power-of-two sets", "L2_SIZE, L2_NUM_WAYS, L2_NUM_BANKS": "40 MB L2 in 80 slices (whitepaper): 20 ways over power-of-two sets; 64 banks of 64 B (4 KB/clk), the power of two nearest the 80 slices' 5 KB/clk", @@ -81,7 +79,7 @@ "EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Off: the datacenter part is built for compute (no display outputs; the raster and ROP hardware is reduced or absent), so the profile models its compute machine", "NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GA100 SM (A100 whitepaper, Figure 7): 4 processing blocks, each with 16 FP32, 16 INT32, 8 FP64 cores, 8 LD/ST units, 1 SFU and 1 tensor core. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)", - "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates", + "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 8.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 conversions take the FCVT rate", "LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "164 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 8.0) in a 256 KB window. DCACHE_SIZE is the whole 192 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves", "EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment", "reference": "fp32_lanes is the vendor FP32 core count (FP32 FMA lanes per chip, clock-free); dram_bandwidth_gbs the vendor peak. Checked by ci/profile_check.py. Latencies: Abdelkhalik et al., Demystifying the Nvidia Ampere Architecture through Microbenchmarking and Instruction-level Analysis (HPEC 2022), Table IV: L1 33, L2 200, global memory 290 cycles", diff --git a/profiles/gtx1080.json b/profiles/gtx1080.json index 73a4ae2c28..3cfd3d26a7 100644 --- a/profiles/gtx1080.json +++ b/profiles/gtx1080.json @@ -24,8 +24,6 @@ "VX_CFG_EXT_TEX_ENABLE": true, "VX_CFG_EXT_RASTER_ENABLE": true, "VX_CFG_EXT_OM_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_FMA64_PE_RATIO": 32, "VX_CFG_DCACHE_NUM_WAYS": 6, "VX_CFG_L1_LINK_LATENCY": 26, @@ -71,8 +69,7 @@ "EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Raster engines in every GPC and ROPs in every memory partition (architecture whitepaper)", "NUM_TFU_LANES": "32 special-function results per clock per SM (8 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GP104 SM (GTX 1080 whitepaper): 4 processing blocks, each with 32 CUDA cores (FP32 and INT32 on the same cores), 8 LD/ST units and 8 SFUs; 4 FP64 cores per SM. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PE (FMA64_PE_RATIO)", - "FMA64_PE_RATIO": "FP64 FMA at 1/32 of the FP32 rate: 4 FP64 cores per SM, 1 per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1); 32 FPU lanes / 32 = 1 F64 FMA PE. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates", - "FDIV_PE_RATIO, FSQRT_PE_RATIO": "32 results per clock per SM, 8 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1); 32 FPU lanes / 4", + "FMA64_PE_RATIO": "FP64 FMA at 1/32 of the FP32 rate: 4 FP64 cores per SM, 1 per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 6.1); 32 FPU lanes / 32 = 1 F64 FMA PE. FP64 conversions take the FCVT rate", "LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "96 KB dedicated shared memory per SM, separate from the 48 KB L1/texture (GTX 1080 whitepaper), in a 128 KB window", "EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment", "reference": "fp32_lanes is the vendor FP32 core count (FP32 FMA lanes per chip, clock-free); dram_bandwidth_gbs the vendor peak. Checked by ci/profile_check.py. Latencies: Jia et al., Dissecting the NVIDIA Turing T4 GPU via Microbenchmarking (arXiv 1903.07486), Table 3.1: L1 hit 82 and L2 hit ~216 cycles on the Tesla P4, a GP104 like this card. No DRAM latency is published for GP104, so dram_cycles is unchecked. Accel-Sim correlates the Pascal TITAN X and GTX 1080 Ti (posted hardware runs: pascal-titanx, pascal-1080ti)", diff --git a/profiles/gtx480.json b/profiles/gtx480.json index 9fffb1e665..cd3cf36980 100644 --- a/profiles/gtx480.json +++ b/profiles/gtx480.json @@ -25,8 +25,6 @@ "VX_CFG_EXT_TEX_ENABLE": true, "VX_CFG_EXT_RASTER_ENABLE": true, "VX_CFG_EXT_OM_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 8, - "VX_CFG_FSQRT_PE_RATIO": 8, "VX_CFG_FCVT_PE_RATIO": 2, "VX_CFG_FMA64_PE_RATIO": 8, "VX_CFG_L1_LINK_LATENCY": 34, @@ -61,7 +59,7 @@ "NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "15 SMs (480 CUDA cores), 48 resident warps per SM, 2 warp schedulers per SM (NVIDIA Fermi compute architecture whitepaper; GTX 480 specifications)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES, PLATFORM_CLOCK_RATE": "Fermi SM: 2 groups of 16 CUDA cores (FP32 and INT32), 16 LD/ST units and 4 SFUs, the cores at the 1401 MHz shader (hot) clock, twice the 700 MHz core clock (Fermi whitepaper). Each scheduler sends a warp to a 16-core group for two hot clocks, one core clock, so the profile runs at the core clock with 32 lanes per scheduler's block: the same FLOPS (15 x 2 x 32 x 2 x 700 MHz = 1344 GFLOPS) at 960 core-clock lanes against the 480 hot-clock cores, so fp32_lanes is not checked. 16 LD/ST units at the hot clock give 16 lanes per block. 700 MHz is the clock of Accel-Sim's SM2_GTX480 configuration", "FMA64_PE_RATIO": "FP64 FMA at 1/8 of the FP32 rate on the GeForce part (the Tesla Fermi parts run it at 1/2): 32 FPU lanes / 8 = 4 F64 FMA PEs per block", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "4 SFU results per hot clock per SM, 4 per block per core clock, for the FP32 reciprocal and reciprocal square root on which division and square root are built: 32 / 8; 16 type conversions per hot clock per SM, 16 per block per core clock: 32 / 2 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 2.0)", + "FCVT_PE_RATIO": "16 type conversions per hot clock per SM, 16 per block per core clock: 32 / 2 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 2.0)", "NUM_TFU_LANES": "4 SFUs per SM at the hot clock: 4 results per block per core clock", "DCACHE_SIZE, DCACHE_NUM_WAYS": "16 KB L1 with 48 KB shared memory, the default split of the 64 KB L1/shared per SM (Fermi whitepaper): 4 ways", "LMEM_SIZE, LMEM_LOG_SIZE, LMEM_NUM_BANKS": "48 KB shared memory per SM; 32 banks of 4 B (16 Vortex banks of 8 B carry the same bytes per clock)", diff --git a/profiles/h100.json b/profiles/h100.json index 9c3a98b68d..36b0432128 100644 --- a/profiles/h100.json +++ b/profiles/h100.json @@ -29,8 +29,6 @@ "VX_CFG_EXT_DXA_ENABLE": true, "VX_CFG_NUM_BARRIERS": 16, "VX_CFG_EXT_TEX_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 8, - "VX_CFG_FSQRT_PE_RATIO": 8, "VX_CFG_FCVT_PE_RATIO": 8, "VX_CFG_FMA64_PE_RATIO": 2, "VX_CFG_DCACHE_NUM_BANKS": 4, @@ -79,8 +77,8 @@ "EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Off: the datacenter part is built for compute (no display outputs; the raster and ROP hardware is reduced or absent), so the profile models its compute machine", "NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 9.0)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GH100 SM (H100 whitepaper, Figure 7): 4 processing blocks, each with 32 FP32, 16 INT32, 16 FP64 cores, 8 LD/ST units, 1 SFU and 1 tensor core. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)", - "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 16 FP64 against 32 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 9.0); 32 FPU lanes / 2 = 16 F64 FMA PEs. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 9.0", + "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 16 FP64 against 32 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 9.0); 32 FPU lanes / 2 = 16 F64 FMA PEs. FP64 conversions take the FCVT rate", + "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 9.0", "DCACHE_NUM_BANKS": "128 B per clock of L1 data per SM: 4 banks of the 32 B dcache word. The default (one bank per LSU request channel) gives 8, twice the part", "LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "228 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 9.0) in a 256 KB window. DCACHE_SIZE keeps the whole 256 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves", "EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment", diff --git a/profiles/keplertitan.json b/profiles/keplertitan.json index e738ddef1c..15a91e3097 100644 --- a/profiles/keplertitan.json +++ b/profiles/keplertitan.json @@ -25,8 +25,6 @@ "VX_CFG_EXT_TEX_ENABLE": true, "VX_CFG_EXT_RASTER_ENABLE": true, "VX_CFG_EXT_OM_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_FCVT_PE_RATIO": 4, "VX_CFG_FMA64_PE_RATIO": 2, "VX_CFG_L1_LINK_LATENCY": 4, @@ -61,7 +59,7 @@ "NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "14 SMX (2688 CUDA cores), 64 resident warps per SMX, 4 warp schedulers each with 2 dispatch units (NVIDIA Kepler GK110 whitepaper)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GK110 SMX: 192 FP32/INT32 cores, 64 FP64 units, 32 LD/ST units and 32 SFUs over 4 schedulers (GK110 whitepaper). Vortex lanes divide the warp, so each scheduler's block gets 32 lanes (128 per SMX): the other 64 cores are reached on the part only by dual-issuing independent instructions, which Vortex does not model. fp32_lanes (2688) is therefore not checked", "FMA64_PE_RATIO": "64 FP64 units per SMX, 16 per scheduler (GK110 whitepaper; the TITAN runs FP64 at the full 1/3 rate with its double-precision mode on): 32 FPU lanes / 2 = 16 F64 FMA PEs per block, the part's FP64 lanes", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "32 results per clock per SMX, 8 per scheduler: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 3.5); 32 FPU lanes / 4", + "FCVT_PE_RATIO": "32 results per clock per SMX, 8 per scheduler: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 3.5); 32 FPU lanes / 4", "NUM_TFU_LANES": "32 SFUs per SMX, 8 per scheduler (GK110 whitepaper)", "DCACHE_SIZE, DCACHE_NUM_WAYS": "16 KB L1 with 48 KB shared memory, the default split of the 64 KB L1/shared per SMX (GK110 whitepaper): 4 ways", "LMEM_SIZE, LMEM_LOG_SIZE, LMEM_NUM_BANKS": "48 KB shared memory per SMX; 32 banks of 8 B (GK110 shared memory runs in an 8-byte bank mode, 256 B per clock)", diff --git a/profiles/mi300x.json b/profiles/mi300x.json index b1ad26d2a7..f5a83a6600 100644 --- a/profiles/mi300x.json +++ b/profiles/mi300x.json @@ -28,8 +28,6 @@ "VX_CFG_TCU_INT8_ENABLE": true, "VX_CFG_TCU_SPARSE_ENABLE": true, "VX_CFG_NUM_BARRIERS": 16, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_L1_LINK_LATENCY": 19, "VX_CFG_EXT_LDST_WIDE_ENABLE": true }, @@ -82,7 +80,6 @@ "PLATFORM_CLOCK_RATE": "2100 MHz peak engine clock", "EXT_TCU_ENABLE, TCU_*": "4 matrix cores per CU, one per SIMD as NUM_TCU_BLOCKS=ISSUE_WIDTH: FP16/BF16, TF32, FP8, INT8, with structured sparsity. Matrix FP64/FP32 are not modelled", "TCU_PE_RATIO": "1024 dense FP16 FMA per clock per CU: 1307 TFLOPS at 2100 MHz over 304 CUs (AMD CDNA 3 white paper). A TCU block at NUM_THREADS=64 computes an 8x8x8-word tile, 1024 FP16 FMA per clock, so the 4 blocks give 4096: ratio 4", - "FDIV_PE_RATIO, FSQRT_PE_RATIO": "Transcendentals (reciprocal, reciprocal square root, on which division and square root are built) run at a quarter of the FP32 rate on GCN, RDNA and CDNA: FPU lanes / 4", "EXT_LDST_WIDE_ENABLE": "128-bit LDS and global loads and stores: DS_READ_B128 / DS_WRITE_B128 and GLOBAL_LOAD_DWORDX4 / GLOBAL_STORE_DWORDX4 (AMD Instinct MI300 CDNA3 Instruction Set Architecture reference guide, LDS and FLAT/global memory instructions). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as DS_READ_B128, needs 16-byte alignment", "reference": "fp32_lanes is the vendor FP32 core count (FP32 FMA lanes per chip, clock-free); dram_bandwidth_gbs the vendor peak. Checked by ci/profile_check.py. Latencies: MGPUSim's measured MI300X ground truth (sarchlab/mgpusim gpu_perf_scripts/calibration/mi300x_ground_truth.csv, cache_latency: a one-thread pointer chase over 64 B lines, 4 laps with at least 131072 and at most 16M timed loads, amd/benchmarks/microbench/cachelatency): 32.4 ns per load up to 16 KB (L1, 68 cycles at 2100 MHz), 85.2 ns from 32 KB to 4 MB (L2, 179 cycles), about 198 ns from 8 to 64 MB (Infinity Cache, the L3: not checked, no chase metric) and 343 ns from 512 MB up (HBM3, 720 cycles)", "L1_LINK_LATENCY": "19 core cycles each way between a core and its dcache, the L1/texture load pipeline, which the dcache bank pipeline (DCACHE_LATENCY) does not model: calibrated with ci/profile_check.py so the SimX pointer chase gives the 68-cycle L1 hit latency in 'reference'", diff --git a/profiles/p100.json b/profiles/p100.json index 6e9b33f604..3395a40ac9 100644 --- a/profiles/p100.json +++ b/profiles/p100.json @@ -23,8 +23,6 @@ "VX_CFG_NUM_TFU_LANES": 16, "VX_CFG_NUM_BARRIERS": 16, "VX_CFG_EXT_TEX_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_FCVT_PE_RATIO": 4, "VX_CFG_FMA64_PE_RATIO": 2, "VX_CFG_L1_LINK_LATENCY": 27, @@ -57,7 +55,7 @@ "NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "56 SMs (3584 CUDA cores), 64 resident warps per SM, 2 processing blocks each with its own warp scheduler and instruction buffer (NVIDIA Tesla P100 whitepaper)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GP100 SM processing block: 32 FP32 cores (FP32 and INT32), 16 FP64 cores, 8 LD/ST units and 8 SFUs (P100 whitepaper, Figure 8). One Vortex ALU/FPU/LSU block per processing block with the part's lanes. FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)", "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 16 FP64 against 32 FP32 cores per processing block (P100 whitepaper; CUDA C++ Programming Guide, compute capability 6.0); 32 FPU lanes / 2", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 8 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 6.0); 32 FPU lanes / 4", + "FCVT_PE_RATIO": "16 results per clock per SM, 8 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 6.0); 32 FPU lanes / 4", "NUM_TFU_LANES": "16 special-function results per clock per SM, 8 SFUs per processing block (P100 whitepaper)", "DCACHE_SIZE, DCACHE_NUM_WAYS": "24 KB unified L1/texture per SM (Jia et al., Table 3.1), separate from shared memory: 6 ways over power-of-two sets", "LMEM_SIZE, LMEM_LOG_SIZE": "64 KB shared memory per SM (P100 whitepaper; CUDA Programming Guide, compute capability 6.0)", diff --git a/profiles/rtx2060.json b/profiles/rtx2060.json index 466c9d572b..5b39651f0b 100644 --- a/profiles/rtx2060.json +++ b/profiles/rtx2060.json @@ -30,8 +30,6 @@ "VX_CFG_EXT_TEX_ENABLE": true, "VX_CFG_EXT_RASTER_ENABLE": true, "VX_CFG_EXT_OM_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_FCVT_PE_RATIO": 4, "VX_CFG_FMA64_PE_RATIO": 16, "VX_CFG_EXT_LDST_WIDE_ENABLE": true @@ -66,7 +64,7 @@ "NUM_CORES, NUM_WARPS, NUM_THREADS, ISSUE_WIDTH, FETCH_WIDTH": "30 SMs (1920 CUDA cores), 32 resident warps per SM (1024 threads, compute capability 7.5), 4 processing blocks each with its own scheduler and L0 instruction cache (NVIDIA Turing architecture whitepaper)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "TU10x SM processing block: 16 FP32 cores, 16 INT32 cores, 4 LD/ST units, 4 SFUs and 2 tensor cores (Turing whitepaper, Figure 4). One Vortex ALU/FPU/LSU block per processing block with the part's INT32, FP32 and LD/ST lanes. FP64 FMAs run on their own F64 FMA PE (FMA64_PE_RATIO)", "FMA64_PE_RATIO": "FP64 FMA at 1/32 of the FP32 rate: 2 FP64 cores per SM (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.5). A block keeps at least one PE, so 16 FPU lanes / 16 = 1 F64 FMA PE per block: 1/16 of FP32, twice the part's FP64 rate", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 7.5); 16 FPU lanes / 4", + "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, compute capability 7.5); 16 FPU lanes / 4", "DCACHE_SIZE, DCACHE_NUM_WAYS, DCACHE_NUM_BANKS": "96 KB L1/shared per SM (Turing whitepaper): 6 ways over power-of-two sets, the whole pool as in the other profiles (the driver gives a kernel the L1 its shared memory leaves). 64 B per clock of L1 data per SM, 16 LD/ST units x 4 B (Jia et al., T4, Table 3.2: 58.8 B/cycle/SM measured): 2 banks of the 32 B dcache word", "LMEM_SIZE, LMEM_LOG_SIZE": "64 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 7.5)", "LMEM_NUM_BANKS": "128 B per clock per SM: 32 banks of 4 B on the part (CUDA C++ Programming Guide, shared memory). Vortex banks are XLEN wide (8 B), so 16 banks carry the same bytes per clock", diff --git a/profiles/rtx5080.json b/profiles/rtx5080.json index 91cbe27df5..93cfd3dba9 100644 --- a/profiles/rtx5080.json +++ b/profiles/rtx5080.json @@ -38,8 +38,6 @@ "VX_CFG_EXT_RASTER_ENABLE": true, "VX_CFG_EXT_OM_ENABLE": true, "VX_CFG_RTU_TLAS_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 8, - "VX_CFG_FSQRT_PE_RATIO": 8, "VX_CFG_FCVT_PE_RATIO": 8, "VX_CFG_FMA64_PE_RATIO": 64, "VX_CFG_L1_LINK_LATENCY": 2, @@ -115,8 +113,8 @@ "RTU_TLAS_ENABLE": "RT cores traverse two-level acceleration structures (instance TLAS over BLAS), as DXR/Vulkan ray tracing requires", "NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 12.0)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GB203 SM (RTX Blackwell whitepaper, Figure 5 and App. B): 4 processing blocks, each with 32 unified FP32/INT32 CUDA cores (INT32 TOPS = FP32 TFLOPS, Table 4), 4 LD/ST units and 1 SFU, 1 tensor core; 2 FP64 cores per SM. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PE (FMA64_PE_RATIO)", - "FMA64_PE_RATIO": "FP64 FMA at 1/64 of the FP32 rate: 2 FP64 results per clock per SM against 128 FP32 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 12.0; arXiv 2507.10789 Table I: 2 FP64 units per SM on GB203). How those units map onto the 4 processing blocks is not documented. A Vortex block keeps at least one full-rate PE, so 32 FPU lanes / 64 rounds up to 1 F64 FMA PE: 1/32 of FP32, twice the part's FP64 rate. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 12.0", + "FMA64_PE_RATIO": "FP64 FMA at 1/64 of the FP32 rate: 2 FP64 results per clock per SM against 128 FP32 (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 12.0; arXiv 2507.10789 Table I: 2 FP64 units per SM on GB203). How those units map onto the 4 processing blocks is not documented. A Vortex block keeps at least one full-rate PE, so 32 FPU lanes / 64 rounds up to 1 F64 FMA PE: 1/32 of FP32, twice the part's FP64 rate. FP64 conversions take the FCVT rate", + "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 32 FPU lanes / 8, compute capability 12.0", "LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "100 KB maximum shared memory per SM (compute capability 12.0 device query: 102400 B per SM) in a 128 KB window. DCACHE_SIZE keeps the whole 128 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves", "L1_LINK_LATENCY": "2 core cycles each way between a core and its dcache, the L1 load pipeline, which the dcache bank pipeline (DCACHE_LATENCY) does not model: calibrated with ci/profile_check.py so the SimX pointer chase gives the 35-cycle L1 hit latency in 'reference'" } diff --git a/profiles/v100.json b/profiles/v100.json index fab5eea818..ca7e19ad98 100644 --- a/profiles/v100.json +++ b/profiles/v100.json @@ -26,8 +26,6 @@ "VX_CFG_EXT_TEX_ENABLE": true, "VX_CFG_EXT_RASTER_ENABLE": true, "VX_CFG_EXT_OM_ENABLE": true, - "VX_CFG_FDIV_PE_RATIO": 4, - "VX_CFG_FSQRT_PE_RATIO": 4, "VX_CFG_FCVT_PE_RATIO": 4, "VX_CFG_FMA64_PE_RATIO": 2, "VX_CFG_DCACHE_NUM_BANKS": 4, @@ -77,8 +75,8 @@ "EXT_RASTER_ENABLE, EXT_OM_ENABLE": "Raster engines in every GPC and ROPs in every memory partition (architecture whitepaper)", "NUM_TFU_LANES": "16 special-function results per clock per SM (4 SFUs in each of the 4 processing blocks) for the reciprocal, reciprocal square root, log2, exp2, sine and cosine (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.0)", "NUM_ALU_LANES, NUM_FPU_LANES, NUM_LSU_LANES": "GV100 SM (Volta whitepaper, Figure 5): 4 processing blocks, each with 16 FP32, 16 INT32, 8 FP64 cores, 8 LD/ST units, 1 SFU and 2 tensor cores. One Vortex ALU/FPU/LSU block per processing block (ISSUE_WIDTH=4) with the part's INT32, FP32 and LD/ST lanes; a 32-thread warp instruction issues over NUM_THREADS/lanes cycles, as on the part. The TCU stays full-warp (NUM_TCU_LANES == NUM_THREADS). FP64 FMAs run on their own F64 FMA PEs (FMA64_PE_RATIO)", - "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 division, square root and conversions take the FDIV/FSQRT/FCVT rates", - "FDIV_PE_RATIO, FSQRT_PE_RATIO, FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: FP32 reciprocal and reciprocal square root, on which division and square root are built, and the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 16 FPU lanes / 4, compute capability 7.0", + "FMA64_PE_RATIO": "FP64 FMA at half the FP32 rate: 8 FP64 against 16 FP32 cores per processing block (CUDA C++ Programming Guide, arithmetic instruction throughput, compute capability 7.0); 16 FPU lanes / 2 = 8 F64 FMA PEs. FP64 conversions take the FCVT rate", + "FCVT_PE_RATIO": "16 results per clock per SM, 4 per processing block: the 32-bit type conversions (CUDA C++ Programming Guide, arithmetic instruction throughput); 16 FPU lanes / 4, compute capability 7.0", "DCACHE_NUM_BANKS": "128 B per clock of L1 data per SM: 4 banks of the 32 B dcache word. The default (one bank per LSU request channel) gives 8, twice the part (Volta whitepaper: 128 B/clk L1)", "LMEM_SIZE, LMEM_LOG_SIZE, DCACHE_SIZE": "96 KB maximum shared memory per SM (CUDA Programming Guide, compute capability 7.0) in a 128 KB window. DCACHE_SIZE keeps the whole 128 KB L1/shared pool: the driver gives a kernel the L1 its shared-memory use leaves, so a kernel without shared memory sees the full pool", "EXT_LDST_WIDE_ENABLE": "128-bit vector loads and stores: SASS LDS.128, LDG.128 and STS.128, present since Fermi; PTX ld/st with a .v4 vector of .f32/.b32 elements, up to 128 bits per access (PTX ISA, ld and st instructions; CUDA C++ Programming Guide, device memory accesses: a naturally aligned 16-byte float4 load or store compiles to one 128-bit instruction). vx_flw.q and vx_fsw.q move four FP32 words per lane; on the 64-bit core a wide load is one 16-byte access per lane and, as LDS.128, needs 16-byte alignment", diff --git a/sim/foldsim/xilinx_fp_models.sv b/sim/foldsim/xilinx_fp_models.sv index 096678222a..8f67cffb7f 100644 --- a/sim/foldsim/xilinx_fp_models.sv +++ b/sim/foldsim/xilinx_fp_models.sv @@ -122,27 +122,6 @@ module xil_fdiv ( .q({m_axis_result_tvalid, m_axis_result_tdata, m_axis_result_tuser})); endmodule -module xil_fsqrt ( - input wire aclk, - input wire aclken, - input wire s_axis_a_tvalid, - input wire [31:0] s_axis_a_tdata, - output wire m_axis_result_tvalid, - output wire [31:0] m_axis_result_tdata, - output wire [0:0] m_axis_result_tuser // invalid -); - import xilinx_fp_model_pkg::*; - logic [63:0] r; - logic [4:0] f; - always @(*) begin - dpi_fsqrt(1'b1, 0, box(ftz_in(s_axis_a_tdata)), 3'b000, r, f); - end - xilinx_fp_model_pipe #(.LATENCY(28), .D(1 + 32 + 1)) pipe ( - .aclk(aclk), .aclken(aclken), - .d({s_axis_a_tvalid, ftz_out(r[31:0]), f[4]}), - .q({m_axis_result_tvalid, m_axis_result_tdata, m_axis_result_tuser})); -endmodule - module xil_fmul ( input wire aclk, input wire aclken, diff --git a/sim/simx/decode.cpp b/sim/simx/decode.cpp index e11670c56b..3b98fd86a2 100644 --- a/sim/simx/decode.cpp +++ b/sim/simx/decode.cpp @@ -992,6 +992,7 @@ Instr::Ptr Decoder::decode(uint32_t code, uint64_t uuid, bool fs_off) { instr->set_src_reg(0, rs1, RegType::Float); instr->set_src_reg(1, rs2, RegType::Float); instr->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS); + instr->set_macro_op(); // TFU micro-ops (FdivUopGen) break; case 0x20: // FCVT.S.D, FCVT.S.H case 0x21: // FCVT.D.S, FCVT.D.H @@ -1032,6 +1033,7 @@ Instr::Ptr Decoder::decode(uint32_t code, uint64_t uuid, bool fs_off) { instr->set_dest_reg(rd, RegType::Float); instr->set_src_reg(0, rs1, RegType::Float); instr->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS); + instr->set_macro_op(); // TFU micro-ops (FdivUopGen) break; case 0x50: // FLE.S, FLT.S, FEQ.S case 0x51: // FLE.D, FLT.D, FEQ.D diff --git a/sim/simx/fpu_unit.cpp b/sim/simx/fpu_unit.cpp index 6535236204..b6eae5dab7 100644 --- a/sim/simx/fpu_unit.cpp +++ b/sim/simx/fpu_unit.cpp @@ -70,10 +70,6 @@ uint32_t FpuUnit::latency_of(const instr_trace_t* trace) const { case FpuType::FNMADD: case FpuType::FNMSUB: return VX_CFG_FMA_LATENCY; - case FpuType::FDIV: - return VX_CFG_FDIV_LATENCY; - case FpuType::FSQRT: - return VX_CFG_FSQRT_LATENCY; case FpuType::F2I: case FpuType::I2F: case FpuType::F2F: @@ -93,7 +89,7 @@ constexpr uint32_t pe_batches(uint32_t pe_ratio) { // pipeline and response arbiter input. constexpr bool kFma64Split = (VX_CFG_FLEN >= 64) && (pe_batches(VX_CFG_FMA64_PE_RATIO) != pe_batches(VX_CFG_FMA_PE_RATIO)); -constexpr uint32_t kRspInputs = kFma64Split ? 5 : 4; +constexpr uint32_t kRspInputs = kFma64Split ? 4 : 3; } uint32_t FpuUnit::pipe_of(const instr_trace_t* trace) const { @@ -108,10 +104,6 @@ uint32_t FpuUnit::pipe_of(const instr_trace_t* trace) const { const auto& fpu_args = std::get(trace->instr_ptr->get_args()); return (kFma64Split && fpu_args.is_f64) ? kPipeFma64 : kPipeFma; } - case FpuType::FDIV: - return kPipeDiv; - case FpuType::FSQRT: - return kPipeSqrt; case FpuType::F2I: case FpuType::I2F: case FpuType::F2F: @@ -148,10 +140,6 @@ uint32_t FpuUnit::batches_of(const instr_trace_t* trace) const { auto fpuArgs = std::get(trace->instr_ptr->get_args()); return fpuArgs.is_f64 ? pe_batches(VX_CFG_FMA64_PE_RATIO) : pe_batches(VX_CFG_FMA_PE_RATIO); } - case FpuType::FDIV: - return pe_batches(VX_CFG_FDIV_PE_RATIO); - case FpuType::FSQRT: - return pe_batches(VX_CFG_FSQRT_PE_RATIO); case FpuType::F2I: case FpuType::I2F: case FpuType::F2F: @@ -222,32 +210,6 @@ uint32_t FpuUnit::execute(instr_trace_t *trace) { rd_data[t].u64 = nan_box(rv_fmul_s(check_boxing(rs1_data[t].u64), check_boxing(rs2_data[t].u64), frm, &fflags)); } result_fflags |= fflags; - } - } break; - case FpuType::FDIV: { - for (uint32_t t = thread_start; t < num_threads; ++t) { - if (!tmask.test(t)) continue; - uint32_t frm = csr_unit_->fpu_rm(fpuArgs.frm, wid); - uint32_t fflags = 0; - if (fpuArgs.is_f64) { - rd_data[t].u64 = rv_fdiv_d(rs1_data[t].u64, rs2_data[t].u64, frm, &fflags); - } else { - rd_data[t].u64 = nan_box(rv_fdiv_s(check_boxing(rs1_data[t].u64), check_boxing(rs2_data[t].u64), frm, &fflags)); - } - result_fflags |= fflags; - } - } break; - case FpuType::FSQRT: { - for (uint32_t t = thread_start; t < num_threads; ++t) { - if (!tmask.test(t)) continue; - uint32_t frm = csr_unit_->fpu_rm(fpuArgs.frm, wid); - uint32_t fflags = 0; - if (fpuArgs.is_f64) { - rd_data[t].u64 = rv_fsqrt_d(rs1_data[t].u64, frm, &fflags); - } else { - rd_data[t].u64 = nan_box(rv_fsqrt_s(check_boxing(rs1_data[t].u64), frm, &fflags)); - } - result_fflags |= fflags; } } break; case FpuType::FSGNJ: { @@ -497,9 +459,6 @@ void FpuUnit::respond(uint32_t b) { for (uint32_t i = 1; i <= kRspInputs; ++i) { uint32_t input = (rsp_grant_.at(b) + i) % kRspInputs; uint32_t p = input; - if (input == kPipeDiv && !ready(kPipeDiv)) { - p = kPipeSqrt; - } if (!ready(p)) { continue; } @@ -559,3 +518,125 @@ bool FpuUnit::busy() const { } return false; } + +namespace { +enum class FdivStep { TFU, FMUL, FSUB, FABS, CVT_S, CVT_D }; +enum Sel : uint8_t { SEL_NONE, SEL_RS1, SEL_RS2, SEL_RD }; + +struct FdivUop { + FdivStep step; + TfuType fn; + Sel a, b; +}; + +// The macro sequence before a double's TFU steps are wrapped in conversions. +uint32_t fdiv_macro_steps(const Instr& instr, FdivUop steps[4]) { + bool is_sqrt = (std::get(instr.get_op_type()) == FpuType::FSQRT); + auto rd = instr.get_dest_reg().idx; + bool rd_is_rs1 = (rd == instr.get_src_reg(0).idx); + bool rd_is_rs2 = !is_sqrt && (rd == instr.get_src_reg(1).idx); + if (is_sqrt) { + steps[0] = {FdivStep::TFU, TfuType::RSQRT, SEL_RS1, SEL_NONE}; + steps[1] = {FdivStep::TFU, TfuType::RCP, SEL_RD, SEL_NONE}; + return 2; + } + if (!rd_is_rs1) { + steps[0] = {FdivStep::TFU, TfuType::RCP, SEL_RS2, SEL_NONE}; + steps[1] = {FdivStep::FMUL, TfuType::RCP, SEL_RS1, SEL_RD}; + return 2; + } + if (!rd_is_rs2) { + steps[0] = {FdivStep::TFU, TfuType::RCP, SEL_RD, SEL_NONE}; + steps[1] = {FdivStep::FMUL, TfuType::RCP, SEL_RD, SEL_RS2}; + steps[2] = {FdivStep::TFU, TfuType::RCP, SEL_RD, SEL_NONE}; + return 3; + } + steps[0] = {FdivStep::FABS, TfuType::RCP, SEL_RD, SEL_RD}; + steps[1] = {FdivStep::TFU, TfuType::LG2, SEL_RD, SEL_NONE}; + steps[2] = {FdivStep::FSUB, TfuType::RCP, SEL_RD, SEL_RD}; + steps[3] = {FdivStep::TFU, TfuType::EX2, SEL_RD, SEL_NONE}; + return 4; +} + +// The sequence's uop count; with out set, also uop uop_index's fields. +uint32_t fdiv_uop(const Instr& instr, uint32_t uop_index, FdivUop* out) { + FdivUop steps[4]; + uint32_t n = fdiv_macro_steps(instr, steps); + bool is_d = std::get(instr.get_args()).is_f64; + uint32_t pos = 0; + for (uint32_t k = 0; k < n; ++k) { + if (is_d && steps[k].step == FdivStep::TFU) { + if (out && uop_index == pos) *out = {FdivStep::CVT_S, steps[k].fn, steps[k].a, SEL_NONE}; + if (out && uop_index == pos + 1) *out = {FdivStep::TFU, steps[k].fn, SEL_RD, SEL_NONE}; + if (out && uop_index == pos + 2) *out = {FdivStep::CVT_D, steps[k].fn, SEL_RD, SEL_NONE}; + pos += 3; + } else { + if (out && uop_index == pos) *out = steps[k]; + pos += 1; + } + } + return pos; +} + +uint32_t fdiv_sel_reg(const Instr& instr, Sel sel) { + switch (sel) { + case SEL_RS1: return instr.get_src_reg(0).idx; + case SEL_RS2: return instr.get_src_reg(1).idx; + default: return instr.get_dest_reg().idx; + } +} +} + +uint32_t FdivUopGen::uop_count(const Instr& instr) { + return fdiv_uop(instr, 0, nullptr); +} + +Instr::Ptr FdivUopGen::get(const Instr& macro_instr, uint32_t uop_index) { + uint64_t parent_uuid = macro_instr.get_uuid(); + uint64_t uop_uuid = make_uop_uuid(parent_uuid, uop_index); + FdivUop u{FdivStep::TFU, TfuType::RCP, SEL_NONE, SEL_NONE}; + fdiv_uop(macro_instr, uop_index, &u); + auto margs = std::get(macro_instr.get_args()); + auto rd = macro_instr.get_dest_reg().idx; + Instr::Ptr uop; + if (u.step == FdivStep::TFU) { + uop = std::allocate_shared(pool_, uop_uuid, FUType::SFU); + uop->set_op_type(u.fn); + } else { + uop = std::allocate_shared(pool_, uop_uuid, FUType::FPU); + uint8_t frm_rd = (margs.frm == 0x7) ? Instr::FCSR_FRM : 0; + switch (u.step) { + case FdivStep::FMUL: + uop->set_op_type(FpuType::FMUL); + uop->set_args(IntrFpuArgs{margs.frm, 0, margs.is_f64, 0}); + uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS); + break; + case FdivStep::FSUB: + uop->set_op_type(FpuType::FSUB); + uop->set_args(IntrFpuArgs{margs.frm, 0, margs.is_f64, 0}); + uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS); + break; + case FdivStep::FABS: + uop->set_op_type(FpuType::FSGNJ); + uop->set_args(IntrFpuArgs{2, 0, margs.is_f64, 0}); // FSGNJX + break; + case FdivStep::CVT_S: + uop->set_op_type(FpuType::F2F); + uop->set_args(IntrFpuArgs{margs.frm, 1, 0, 0}); + uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS); + break; + default: // CVT_D + uop->set_op_type(FpuType::F2F); + uop->set_args(IntrFpuArgs{margs.frm, 0, 1, 0}); + uop->set_fcsr_use(frm_rd, Instr::FCSR_FFLAGS); + break; + } + } + uop->set_parent_uuid(parent_uuid); + uop->set_dest_reg(rd, RegType::Float); + uop->set_src_reg(0, fdiv_sel_reg(macro_instr, u.a), RegType::Float); + if (u.b != SEL_NONE) { + uop->set_src_reg(1, fdiv_sel_reg(macro_instr, u.b), RegType::Float); + } + return uop; +} diff --git a/sim/simx/fpu_unit.h b/sim/simx/fpu_unit.h index e9ebbcce6c..344a36d0f3 100644 --- a/sim/simx/fpu_unit.h +++ b/sim/simx/fpu_unit.h @@ -14,12 +14,28 @@ #pragma once #include +#include #include "func_unit.h" +#include "instr.h" namespace vortex { class CsrUnit; +// Micro-op generator for FDIV/FSQRT: TFU reciprocal/rsqrt plus FPU ops, +// mirroring VX_uop_fdiv. +class FdivUopGen { +public: + FdivUopGen(PoolAllocator& pool) : pool_(pool) {} + + static uint32_t uop_count(const Instr& instr); + + Instr::Ptr get(const Instr& macro_instr, uint32_t uop_index); + +private: + PoolAllocator& pool_; +}; + class FpuUnit : public FuncUnit { public: FpuUnit(const SimContext& ctx, const char* name, Core*); @@ -57,11 +73,8 @@ class FpuUnit : public FuncUnit { std::array batch_idx_{}; - // Result pipelines, in the order of the block's response arbiter inputs; - // the divider and the square root share one input, the divider first. - enum : uint32_t { kPipeFma, kPipeDiv, kPipeCvt, kPipeNcp, kPipeFma64, kPipeSqrt, kNumPipes }; - // respond() indexes arbiter inputs 0..4 directly as pipes; sqrt shares div's input. - static_assert(kPipeFma64 == 4 && kPipeSqrt == kNumPipes - 1, "arbiter input order"); + // Result pipelines, in the order of the block's response arbiter inputs. + enum : uint32_t { kPipeFma, kPipeCvt, kPipeNcp, kPipeFma64, kNumPipes }; uint32_t pipe_of(const instr_trace_t* trace) const; // Hands the block one result per cycle, round-robin over the classes whose diff --git a/sim/simx/sequencer.cpp b/sim/simx/sequencer.cpp index 2763303546..8e2fee23c9 100644 --- a/sim/simx/sequencer.cpp +++ b/sim/simx/sequencer.cpp @@ -25,6 +25,7 @@ Sequencer::Sequencer(const SimContext& ctx, const char* name, Core* core, PoolAl : SimObject(ctx, name) , core_(core) , lsu_uop_gen_(instr_pool) + , fdiv_uop_gen_(instr_pool) #ifdef VX_CFG_EXT_TCU_ENABLE , tcu_uop_gen_(instr_pool) #endif @@ -58,6 +59,12 @@ instr_trace_t* Sequencer::get(instr_trace_t* trace) { return lsu_uop_gen_.get(m, i); }; break; + case FUType::FPU: + state_.uop_count = FdivUopGen::uop_count(*trace->instr_ptr); + state_.gen_fn = [this](const Instr& m, uint32_t i) { + return fdiv_uop_gen_.get(m, i); + }; + break; #ifdef VX_CFG_EXT_TCU_ENABLE case FUType::TCU: state_.uop_count = TcuUopGen::uop_count(*trace->instr_ptr); diff --git a/sim/simx/sequencer.h b/sim/simx/sequencer.h index 56f346470b..267a2b74b2 100644 --- a/sim/simx/sequencer.h +++ b/sim/simx/sequencer.h @@ -18,6 +18,7 @@ #include "types.h" #include "instr.h" #include "lsu_unit.h" +#include "fpu_unit.h" #ifdef VX_CFG_EXT_TCU_ENABLE #include "tcu_unit.h" #endif @@ -83,6 +84,7 @@ class Sequencer : public SimObject { Core* core_; State state_; LsuUopGen lsu_uop_gen_; + FdivUopGen fdiv_uop_gen_; #ifdef VX_CFG_EXT_TCU_ENABLE TcuUopGen tcu_uop_gen_; #endif diff --git a/tests/regression/Makefile b/tests/regression/Makefile index c1f7abbf95..77551ebaea 100644 --- a/tests/regression/Makefile +++ b/tests/regression/Makefile @@ -10,7 +10,7 @@ TESTS := \ fence_mp ldst_order \ vecadd vecadd_v1 sgemm sgemmx sgemm_v1 conv3 relu sgemv \ sgemm2 sgemm2_v1 madmax mixfu stencil3d raycast bfs jacobi pathfinder \ - softmax uniform_ld lmem_access ldst_wide ldst_matrix tfu zfhmin fp_flags \ + softmax uniform_ld lmem_access ldst_wide ldst_matrix tfu fdiv_tfu zfhmin fp_flags \ flash_attn flash_attn_tcu_wg \ sgemm_tcu sgemm_tcu_mx sgemm_tcu_sp_mx sgemm_tcu_wg sgemm_tcu_wg_mx sgemm_tcu_sp sgemm_tcu_wg_sp \ sgemm2_dxa sgemm2_tcu sgemm_tcu_wg_dxa sgemm_tcu_wg_sp_dxa \ diff --git a/tests/regression/dogfood/testcases.h b/tests/regression/dogfood/testcases.h index bf274d1d16..37425e4645 100644 --- a/tests/regression/dogfood/testcases.h +++ b/tests/regression/dogfood/testcases.h @@ -674,15 +674,17 @@ class Test_FFLAGS_LANES : public ITestCase { public: Test_FFLAGS_LANES(TestSuite* suite) : ITestCase(suite, "fflags-lanes") {} - enum { FL_NX = 0x01, FL_OF = 0x04, FL_DZ = 0x08, FL_NV = 0x10 }; + enum { FL_NX = 0x01, FL_OF = 0x04, FL_NV = 0x10 }; enum { K_NONE, K_NX, K_X1, K_X2 }; // A warp divides or adds by the parity of its iteration plus its index, so - // warps running side by side mix the two; X1 is DZ or OF, X2 is NV. + // warps running side by side mix the two; X1 is OF, X2 is NV. FDIV is a TFU + // reciprocal and an FMUL, and the reciprocal raises no flags: 1/3 and 1/0 + // raise nothing, and 0/0 raises NV in the multiply (0 * inf). static uint32_t recipe(bool is_add, int kind, float* a, float* b) { static const float div_a[] = {1.0f, 1.0f, 1.0f, 0.0f}; static const float div_b[] = {2.0f, 3.0f, 0.0f, 0.0f}; - static const uint32_t div_f[] = {0, FL_NX, FL_DZ, FL_NV}; + static const uint32_t div_f[] = {0, 0, 0, FL_NV}; static const float add_a[] = {1.0f, 1.0f, std::numeric_limits::max(), INFINITY}; static const float add_b[] = {2.0f, 0x1p-30f, std::numeric_limits::max(), -INFINITY}; static const uint32_t add_f[] = {0, FL_NX, FL_OF | FL_NX, FL_NV}; diff --git a/tests/regression/fdiv_tfu/Makefile b/tests/regression/fdiv_tfu/Makefile new file mode 100644 index 0000000000..a6ac27cedf --- /dev/null +++ b/tests/regression/fdiv_tfu/Makefile @@ -0,0 +1,18 @@ +ROOT_DIR := $(realpath ../../..) +include $(ROOT_DIR)/config.mk + +PROJECT := fdiv_tfu + +SRC_DIR := $(VORTEX_HOME)/tests/regression/$(PROJECT) + +SRCS := $(SRC_DIR)/main.cpp + +VX_SRCS := $(SRC_DIR)/kernel.cpp + +VX_HDRS := $(SRC_DIR)/common.h + +OPTS ?= -n1024 + +KERNEL_LIB := vortex2 + +include ../common.mk diff --git a/tests/regression/fdiv_tfu/common.h b/tests/regression/fdiv_tfu/common.h new file mode 100644 index 0000000000..ff0ebfce25 --- /dev/null +++ b/tests/regression/fdiv_tfu/common.h @@ -0,0 +1,26 @@ +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#include + +// Register aliasings of FDIV.S / FSQRT.S, each a different micro-op sequence. +enum { + OP_DIV, // rd, rs1, rs2 distinct + OP_DIV_RD_RS1, // rd == rs1 + OP_DIV_RD_RS2, // rd == rs2 + OP_DIV_SELF, // rd == rs1 == rs2 + OP_DIV_SRC_EQ, // rs1 == rs2, rd distinct + OP_SQRT, // rd, rs1 distinct + OP_SQRT_SELF, // rd == rs1 + OP_COUNT +}; + +typedef struct { + uint32_t op; + uint32_t num_points; + uint64_t a_addr; + uint64_t b_addr; + uint64_t dst_addr; +} kernel_arg_t; + +#endif diff --git a/tests/regression/fdiv_tfu/kernel.cpp b/tests/regression/fdiv_tfu/kernel.cpp new file mode 100644 index 0000000000..df438277e6 --- /dev/null +++ b/tests/regression/fdiv_tfu/kernel.cpp @@ -0,0 +1,40 @@ +#include +#include "common.h" + +__kernel void kernel_main(kernel_arg_t* __UNIFORM__ arg) { + uint32_t i = blockIdx.x * blockDim.x + threadIdx.x; + if (i >= arg->num_points) { + return; + } + float a = reinterpret_cast(arg->a_addr)[i]; + float b = reinterpret_cast(arg->b_addr)[i]; + float r; + switch (arg->op) { + case OP_DIV: + __asm__ volatile ("fdiv.s %0, %1, %2" : "=&f"(r) : "f"(a), "f"(b)); + break; + case OP_DIV_RD_RS1: + __asm__ volatile ("fdiv.s %0, %0, %1" : "+f"(a) : "f"(b)); + r = a; + break; + case OP_DIV_RD_RS2: + __asm__ volatile ("fdiv.s %0, %1, %0" : "+f"(b) : "f"(a)); + r = b; + break; + case OP_DIV_SELF: + __asm__ volatile ("fdiv.s %0, %0, %0" : "+f"(a)); + r = a; + break; + case OP_DIV_SRC_EQ: + __asm__ volatile ("fdiv.s %0, %1, %1" : "=&f"(r) : "f"(a)); + break; + case OP_SQRT: + __asm__ volatile ("fsqrt.s %0, %1" : "=&f"(r) : "f"(a)); + break; + default: + __asm__ volatile ("fsqrt.s %0, %0" : "+f"(a)); + r = a; + break; + } + reinterpret_cast(arg->dst_addr)[i] = r; +} diff --git a/tests/regression/fdiv_tfu/main.cpp b/tests/regression/fdiv_tfu/main.cpp new file mode 100644 index 0000000000..5b049acd47 --- /dev/null +++ b/tests/regression/fdiv_tfu/main.cpp @@ -0,0 +1,224 @@ +#include +#include +#include +#include +#include +#include +#include +#include "common.h" + +#define RT_CHECK(_expr) \ + do { \ + int _ret = _expr; \ + if (0 == _ret) \ + break; \ + printf("Error: '%s' returned %d!\n", #_expr, (int)_ret); \ + cleanup(); \ + exit(-1); \ + } while (false) + +// FDIV/FSQRT run as TFU micro-ops and are not correctly rounded. These are the +// bounds the sequences meet for normal inputs whose results stay normal. +static const double kMaxUlp[OP_COUNT] = {2.0, 3.0, 2.0, 0.0, 2.0, 2.0, 2.0}; + +static const char* kOpNames[OP_COUNT] = { + "div", "div_rd_rs1", "div_rd_rs2", "div_self", "div_src_eq", "sqrt", "sqrt_self" +}; + +// (a, b) special pairs; b is ignored by sqrt +static const uint32_t kSpecials[][2] = { + {0x3f800000, 0x00000000}, {0xbf800000, 0x00000000}, {0x00000000, 0x00000000}, + {0x7f800000, 0x7f800000}, {0x40400000, 0x7f800000}, {0x7f800000, 0x40400000}, + {0x00000000, 0x40400000}, {0x7fc00000, 0x3f800000}, {0x3f800000, 0x7fc00000}, + {0xbf800000, 0x3f800000}, {0x80000000, 0x3f800000}, +}; + +const char* kernel_file = "kernel.vxbin"; +uint32_t num_points = 1024; +int selected_op = -1; + +vx_device_h device = nullptr; +vx_buffer_h a_buffer = nullptr; +vx_buffer_h b_buffer = nullptr; +vx_buffer_h dst_buffer = nullptr; +vx_queue_h queue = nullptr; +vx_module_h module_ = nullptr; +vx_kernel_h kernel = nullptr; + +static float as_float(uint32_t u) { float f; memcpy(&f, &u, 4); return f; } +static uint32_t as_bits(float f) { uint32_t u; memcpy(&u, &f, 4); return u; } + +static void show_usage() { + std::cout << "Usage: [-k: kernel] [-n points] [-t op] [-h: help]" << std::endl; +} + +static void parse_args(int argc, char **argv) { + int c; + while ((c = getopt(argc, argv, "n:t:k:h")) != -1) { + switch (c) { + case 'n': + num_points = atoi(optarg); + break; + case 't': + for (int i = 0; i < OP_COUNT; ++i) { + if (strcmp(optarg, kOpNames[i]) == 0) { + selected_op = i; + } + } + if (selected_op < 0) { + show_usage(); + exit(-1); + } + break; + case 'k': + kernel_file = optarg; + break; + default: + show_usage(); + exit(-1); + } + } +} + +void cleanup() { + if (device) { + if (a_buffer) vx_buffer_release(a_buffer); + if (b_buffer) vx_buffer_release(b_buffer); + if (dst_buffer) vx_buffer_release(dst_buffer); + if (kernel) vx_kernel_release(kernel); + if (module_) vx_module_release(module_); + if (queue) vx_queue_release(queue); + vx_device_dump_perf(device, stdout); + vx_device_release(device); + } +} + +static bool is_sqrt(int op) { return op == OP_SQRT || op == OP_SQRT_SELF; } + +static double reference(int op, float a, float b) { + if (is_sqrt(op)) return std::sqrt((double)a); + if (op == OP_DIV_SELF || op == OP_DIV_SRC_EQ) return (double)a / (double)a; + return (double)a / (double)b; +} + +static double ulp_error(float got, double exact) { + if (std::isnan(exact)) return std::isnan(got) ? 0 : INFINITY; + if (std::isinf(exact) || std::isinf(got) || exact == 0) { + return (got == (float)exact && std::signbit(got) == std::signbit(exact)) ? 0 : INFINITY; + } + float ref = (float)exact; + double ulp = std::nextafter(std::fabs(ref), INFINITY) - std::fabs(ref); + return std::fabs((double)got - exact) / ulp; +} + +static float gen_normal(std::mt19937& rng, int exp_range) { + std::uniform_int_distribution man(0, (1u << 23) - 1), sign(0, 1); + std::uniform_int_distribution ex(127 - exp_range, 127 + exp_range); + return as_float((sign(rng) << 31) | (uint32_t(ex(rng)) << 23) | man(rng)); +} + +static int run_op(int op, std::mt19937& rng, uint64_t a_addr, uint64_t b_addr, uint64_t dst_addr) { + std::vector h_a(num_points), h_b(num_points), h_dst(num_points); + uint32_t ns = std::min(num_points, sizeof(kSpecials) / sizeof(kSpecials[0])); + for (uint32_t i = 0; i < num_points; ++i) { + if (i < ns) { + h_a[i] = as_float(kSpecials[i][0]); + h_b[i] = as_float(kSpecials[i][1]); + } else { + h_a[i] = gen_normal(rng, 60); + h_b[i] = gen_normal(rng, 60); + if (is_sqrt(op)) h_a[i] = std::fabs(h_a[i]); + } + } + + kernel_arg_t arg = {}; + arg.op = op; + arg.num_points = num_points; + arg.a_addr = a_addr; + arg.b_addr = b_addr; + arg.dst_addr = dst_addr; + + uint32_t buf_size = num_points * sizeof(float); + RT_CHECK(vx_enqueue_write(queue, a_buffer, 0, h_a.data(), buf_size, 0, nullptr, nullptr)); + RT_CHECK(vx_enqueue_write(queue, b_buffer, 0, h_b.data(), buf_size, 0, nullptr, nullptr)); + + vx_event_h launch_ev = nullptr, read_ev = nullptr; + { + uint32_t grid_dim[1], block_dim[1]; + RT_CHECK(vx_device_max_occupancy_grid(device, 1, &num_points, grid_dim, block_dim)); + vx_launch_info_t li = {}; + li.struct_size = sizeof(li); + li.kernel = kernel; + li.args_host = &arg; + li.args_size = sizeof(arg); + li.ndim = 1; + li.grid_dim[0] = grid_dim[0]; + li.block_dim[0] = block_dim[0]; + RT_CHECK(vx_enqueue_launch(queue, &li, 0, nullptr, &launch_ev)); + } + RT_CHECK(vx_enqueue_read(queue, h_dst.data(), dst_buffer, 0, buf_size, 1, &launch_ev, &read_ev)); + RT_CHECK(vx_event_wait_value(read_ev, 1, VX_TIMEOUT_INFINITE)); + vx_event_release(read_ev); + vx_event_release(launch_ev); + + int errors = 0; + double max_err = 0; + for (uint32_t i = 0; i < num_points; ++i) { + double exact = reference(op, h_a[i], h_b[i]); + double err = ulp_error(h_dst[i], exact); + if (err > kMaxUlp[op]) { + if (errors < 20) { + printf("*** error: %s[%u] a=%a b=%a: actual=%a (0x%08x) expected=%a (%.2f ulp)\n", + kOpNames[op], i, h_a[i], h_b[i], h_dst[i], as_bits(h_dst[i]), exact, err); + } + ++errors; + } else if (err > max_err) { + max_err = err; + } + } + printf("%s: max %.2f ulp, %d errors\n", kOpNames[op], max_err, errors); + return errors; +} + +int main(int argc, char *argv[]) { + parse_args(argc, argv); + + std::cout << "open device connection" << std::endl; + RT_CHECK(vx_device_open(0, &device)); + + vx_queue_info_t qi = { sizeof(qi), nullptr, VX_QUEUE_PRIORITY_NORMAL, 0 }; + RT_CHECK(vx_queue_create(device, &qi, &queue)); + + uint32_t buf_size = num_points * sizeof(float); + uint64_t a_addr, b_addr, dst_addr; + RT_CHECK(vx_buffer_create(device, buf_size, VX_MEM_READ, &a_buffer)); + RT_CHECK(vx_buffer_address(a_buffer, &a_addr)); + RT_CHECK(vx_buffer_create(device, buf_size, VX_MEM_READ, &b_buffer)); + RT_CHECK(vx_buffer_address(b_buffer, &b_addr)); + RT_CHECK(vx_buffer_create(device, buf_size, VX_MEM_WRITE, &dst_buffer)); + RT_CHECK(vx_buffer_address(dst_buffer, &dst_addr)); + + RT_CHECK(vx_module_load_file(device, kernel_file, &module_)); + RT_CHECK(vx_module_get_kernel(module_, "main", &kernel)); + + std::mt19937 rng(0x66646976); + int errors = 0; + for (int op = 0; op < OP_COUNT; ++op) { + if (selected_op >= 0 && op != selected_op) { + continue; + } + errors += run_op(op, rng, a_addr, b_addr, dst_addr); + } + + std::cout << "cleanup" << std::endl; + cleanup(); + + if (errors != 0) { + std::cout << "Found " << std::dec << errors << " errors!" << std::endl; + std::cout << "FAILED!" << std::endl; + return 1; + } + + std::cout << "PASSED!" << std::endl; + return 0; +} diff --git a/tests/riscv/isa/Makefile b/tests/riscv/isa/Makefile index 95e471b1e1..b779d5f0df 100644 --- a/tests/riscv/isa/Makefile +++ b/tests/riscv/isa/Makefile @@ -51,7 +51,9 @@ endif # Known-unsupported tests, skipped by run_isa: fence_i (no instruction-cache # coherence), ma_data (no misaligned-access trap), rv64uc-p-rvc (misaligned # C.FLD the upstream test expects to trap on). -ISA_SKIP := *-fence_i|*-ma_data|rv64uc-p-rvc +# fdiv checks correctly rounded FDIV/FSQRT results and their flags; Vortex +# computes them with TFU micro-ops (VX_uop_fdiv), within 3 ulp. +ISA_SKIP := *-fence_i|*-ma_data|rv64uc-p-rvc|*-fdiv # The machine-mode suites run mcsr, scall, sbreak, illegal, shamt and # ma_fetch. The tests that need a trap source or a CSR Vortex does not model # are skipped: From 3869802382f275a57ace14601a288a679b91c5c4 Mon Sep 17 00:00:00 2001 From: jel221 Date: Thu, 3 Dec 2026 21:12:39 -0800 Subject: [PATCH 2/2] ci: re-record the baselines the FDIV/FSQRT change moves Removing the FDIV/FSQRT knobs changes the resolved config, so every perf entry's config_hash moves; the synthesis entries move with the smaller FPU and the 2-lane TFU at 16 threads. Re-recorded with: pytest ci -m perf_gate --update-baselines (all 51 cases) ci/logic_gate.py --update-baseline (core, core_ldst, top_vortex) ci/logic_gate.py --tool beacon_asic --update-baseline (core, top, tfu) ci/asic_gate.py --update-baseline (core, top, tfu) ci/fpga_gate.py --update-baseline (core, top, tfu) gfx, gfxvm and tensor were re-run too; they contain no FPU and their metrics did not move, so they are not re-recorded. Tools: TOOLCHAIN_REV v3.0.4, beacon 134d03b9e, CIRCT 90c5fd313, Yosys 0.69, OpenSTA 3.1.0 (asap7 rvt tt), Vivado 2024.2 (xcu55c). Re-recorded by: agent, authorized by jel221 2026-12-03. --- ci/baselines/perf/core.json | 58 +-- ci/baselines/perf/dxa.json | 22 +- ci/baselines/perf/graphics.json | 30 +- ci/baselines/perf/raytracing.json | 18 +- ci/baselines/perf/tensor.json | 12 +- ci/baselines/perf/tensor_mx.json | 2 +- ci/baselines/perf/tensor_sp.json | 2 +- ci/baselines/perf/tensor_wg.json | 6 +- ci/baselines/synthesis/beacon/core.json | 91 ++-- ci/baselines/synthesis/beacon_asic/core.json | 22 +- ci/baselines/synthesis/beacon_asic/tfu.json | 6 +- ci/baselines/synthesis/xilinx/core.json | 426 +++++++++---------- ci/baselines/synthesis/xilinx/tfu.json | 188 ++++---- ci/baselines/synthesis/yosys/core.json | 32 +- ci/baselines/synthesis/yosys/tfu.json | 14 +- 15 files changed, 478 insertions(+), 451 deletions(-) diff --git a/ci/baselines/perf/core.json b/ci/baselines/perf/core.json index a4fed9d6c6..0bf907e5dd 100644 --- a/ci/baselines/perf/core.json +++ b/ci/baselines/perf/core.json @@ -1,23 +1,23 @@ { "core:raycast-nt16:rtlsim": { "32": { - "cycles": 7499743, - "instrs": 2234919 + "cycles": 7575004, + "instrs": 2258191 }, "app": "raycast", "args": "", - "config_hash": "6a8db2da81885bd3", + "config_hash": "57363097e97b43e0", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "core:raycast-nt4:rtlsim": { "32": { - "cycles": 18396204, - "instrs": 5636759 + "cycles": 18552450, + "instrs": 5698339 }, "app": "raycast", "args": "", - "config_hash": "a7365739bd29ae7f", + "config_hash": "9245d48e06c98ced", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "a94d5512bae0d0c4", + "config_hash": "36f8a3823290652c", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=16 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "ed82856d2fbdb4fa", + "config_hash": "984b01e8101cfc47", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "207c97cf1edf224d", + "config_hash": "cde9952ab2b97bd9", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm", "args": "-n128", - "config_hash": "ddaf766d29f0c9e2", + "config_hash": "322a72e62381f276", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "sgemm2", "args": "-n64 -t4", - "config_hash": "e3a289024245088f", + "config_hash": "ff8c45e67d6cc15b", "configs": "-DVX_CFG_EXT_LDST_WIDE_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "sgemmx", "args": "-n128", - "config_hash": "b33624dacfde5ab3", + "config_hash": "161b4f819b26531a", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "sgemmx", "args": "-n128", - "config_hash": "c2faf5453d1010f0", + "config_hash": "202a63f8eb007416", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -105,7 +105,7 @@ }, "app": "sgemv", "args": "-m512 -n512", - "config_hash": "ba5846fb3e38ff61", + "config_hash": "51a66e6894500a43", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -116,51 +116,51 @@ }, "app": "sgemv", "args": "-m512 -n512", - "config_hash": "ff7c79ffef364ae9", + "config_hash": "ff5fd64440c02266", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, "core:softmax-nt16:rtlsim": { "32": { - "cycles": 1271704, - "instrs": 462553 + "cycles": 1274253, + "instrs": 463065 }, "app": "softmax", "args": "-n64", - "config_hash": "5c38536ce941bce9", + "config_hash": "147969a83745f11a", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "core:softmax-nt4:rtlsim": { "32": { - "cycles": 4850762, - "instrs": 1783653 + "cycles": 4859055, + "instrs": 1785701 }, "app": "softmax", "args": "-n64", - "config_hash": "647c47cbc33e0b1e", + "config_hash": "4107408b3546b287", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, "core:stencil3d-nt16:rtlsim": { "32": { - "cycles": 2090794, - "instrs": 888848 + "cycles": 2137750, + "instrs": 897040 }, "app": "stencil3d", "args": "-n32", - "config_hash": "e962be6c4a705bd0", + "config_hash": "56c620b8af62d61f", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "core:stencil3d-nt4:rtlsim": { "32": { - "cycles": 4145399, - "instrs": 1777680 + "cycles": 4210252, + "instrs": 1794064 }, "app": "stencil3d", "args": "-n32", - "config_hash": "44671bcb89d71094", + "config_hash": "5cb0f49ff28434f8", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -171,7 +171,7 @@ }, "app": "vecadd", "args": "-n16384", - "config_hash": "3c46a73d97d7dde8", + "config_hash": "6c8e84402d768f8c", "configs": "-DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -182,7 +182,7 @@ }, "app": "vecadd", "args": "-n16384", - "config_hash": "67f76328e947f037", + "config_hash": "c7cdda870b2f2369", "configs": "-DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/dxa.json b/ci/baselines/perf/dxa.json index 9c42109c5f..e959d6d108 100644 --- a/ci/baselines/perf/dxa.json +++ b/ci/baselines/perf/dxa.json @@ -6,7 +6,7 @@ }, "app": "dxa_copy_mcast", "args": "", - "config_hash": "a98f143d348178b8", + "config_hash": "7256353ed29b8be3", "configs": "-DVX_CFG_EXT_DXA_ENABLE", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "dxa_copy", "args": "-d1", - "config_hash": "55c5155d6ab46f83", + "config_hash": "fb1f2e9ec30fda50", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "dxa_copy", "args": "-d1", - "config_hash": "ee5d9d68a6bee766", + "config_hash": "7f9fbf8169361c7d", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm2_dxa_mcast", "args": "-n128", - "config_hash": "82c50e47ea6ea51c", + "config_hash": "9936082f7f64c31c", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm2_dxa_mcast", "args": "-n128", - "config_hash": "8f2e3ded05181df5", + "config_hash": "42207bd5a2540914", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm2_dxa", "args": "-n128 -t4 -m1", - "config_hash": "a94548f6a341be69", + "config_hash": "182e784c92df69ec", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "sgemm2_dxa", "args": "-n128 -t4 -m1", - "config_hash": "b647693500d03cdb", + "config_hash": "502dd7dc09e817df", "configs": "-DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "sgemm_tcu_wg_dxa_mcast", "args": "-m 128 -n 128 -k 64", - "config_hash": "7506c2b313ddfb40", + "config_hash": "6e9bafbc4d311719", "configs": "-DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "sgemm_tcu_wg_dxa_mcast", "args": "-m 128 -n 128 -k 64", - "config_hash": "a7d7a7c19cc97d7f", + "config_hash": "d65701a0bff5e490", "configs": "-DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -105,7 +105,7 @@ }, "app": "sgemm_tcu_wg_dxa", "args": "-m 128 -n 128 -k 64", - "config_hash": "0dfd4e6b3f65442b", + "config_hash": "95baccf7110a4641", "configs": "-DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DWGMMA_NRC=16 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_THREADS=32", "driver": "rtlsim" }, @@ -116,7 +116,7 @@ }, "app": "sgemm_tcu_wg_sp_dxa", "args": "-m 128 -n 128 -k 128", - "config_hash": "30f77e58ea21b51b", + "config_hash": "f9b2facc7c7a1318", "configs": "-DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE -DVX_CFG_EXT_DXA_ENABLE -DWGMMA_NRC=32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_NUM_THREADS=32", "driver": "rtlsim" } diff --git a/ci/baselines/perf/graphics.json b/ci/baselines/perf/graphics.json index d52d41eda8..b7f4de98bd 100644 --- a/ci/baselines/perf/graphics.json +++ b/ci/baselines/perf/graphics.json @@ -1,34 +1,34 @@ { "graphics:perf_gate-draw3d-mc:rtlsim": { "32": { - "cycles": 517374, - "instrs": 200254 + "cycles": 521658, + "instrs": 203152 }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "c548118c41bcef23", + "config_hash": "09492f6735fbac27", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, "graphics:perf_gate-draw3d-nt16:rtlsim": { "32": { - "cycles": 139104, - "instrs": 50941 + "cycles": 140681, + "instrs": 51676 }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "48890b8c1ad7fe04", + "config_hash": "8f0382a0b7056f3d", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "graphics:perf_gate-draw3d-nt4:rtlsim": { "32": { - "cycles": 520510, - "instrs": 200254 + "cycles": 524338, + "instrs": 203152 }, "app": "gfx_draw3d", "args": "-w 128 -h 128 -t box.cgltrace -r box_ref_128.png", - "config_hash": "b08776e5f96f6b97", + "config_hash": "1785c8f909e10fbb", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "gfx_om", "args": "-w 128 -h 128 -r whitebox_128.png", - "config_hash": "32307cceb33dc7a6", + "config_hash": "10290b564f67a369", "configs": "-DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "gfx_om", "args": "-w 128 -h 128 -r whitebox_128.png", - "config_hash": "ce07b69d9a182c02", + "config_hash": "5b725c6d9b52b618", "configs": "-DVX_CFG_EXT_OM_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "gfx_raster", "args": "-w 128 -h 128 -t triangle.cgltrace -r triangle_ref_128.png", - "config_hash": "366fbc3590ee481f", + "config_hash": "164a3e5b1bef237f", "configs": "-DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -72,7 +72,7 @@ }, "app": "gfx_raster", "args": "-w 128 -h 128 -t triangle.cgltrace -r triangle_ref_128.png", - "config_hash": "8c3f6ea5a04a0d52", + "config_hash": "ede979980ccc1b41", "configs": "-DVX_CFG_EXT_RASTER_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" }, @@ -83,7 +83,7 @@ }, "app": "gfx_tex", "args": "-i toad.png -r toad_ref_f0.png -f 0 -g 0", - "config_hash": "370db7ba23efdbb2", + "config_hash": "41b6b3b3aa31211c", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, @@ -94,7 +94,7 @@ }, "app": "gfx_tex", "args": "-i toad.png -r toad_ref_f0.png -f 0 -g 0", - "config_hash": "a680ecaa56a2c2fd", + "config_hash": "95eb26e3419bb63c", "configs": "-DVX_CFG_EXT_TEX_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/raytracing.json b/ci/baselines/perf/raytracing.json index db66430680..97db01663d 100644 --- a/ci/baselines/perf/raytracing.json +++ b/ci/baselines/perf/raytracing.json @@ -1,34 +1,34 @@ { "raytracing:perf_gate-rt_raycast-mc:rtlsim": { "32": { - "cycles": 75940, - "instrs": 39346 + "cycles": 76398, + "instrs": 40823 }, "app": "rt_raycast", "args": "", - "config_hash": "9fa9d930efb7a892", + "config_hash": "5890229c4cfb0f70", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, "raytracing:perf_gate-rt_raycast-nt16:rtlsim": { "32": { - "cycles": 50976, - "instrs": 11372 + "cycles": 51640, + "instrs": 11815 }, "app": "rt_raycast", "args": "", - "config_hash": "bf5c79f92d7a2d0b", + "config_hash": "8e711be399e5a018", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_THREADS=16", "driver": "rtlsim" }, "raytracing:perf_gate-rt_raycast-nt4:rtlsim": { "32": { - "cycles": 147985, - "instrs": 39330 + "cycles": 150258, + "instrs": 40807 }, "app": "rt_raycast", "args": "", - "config_hash": "6eca2ad296cbc4c8", + "config_hash": "6699102628f13e70", "configs": "-DVX_CFG_EXT_RTU_ENABLE -DVX_CFG_NUM_THREADS=4", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor.json b/ci/baselines/perf/tensor.json index 660bb540f9..950e9722a3 100644 --- a/ci/baselines/perf/tensor.json +++ b/ci/baselines/perf/tensor.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "395b9f89b1613b5f", + "config_hash": "314617be97a05a39", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "14c25c4ef390468d", + "config_hash": "c0c3a1313a958feb", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=16 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "3a5afbca2316def1", + "config_hash": "fad5f60932d21beb", "configs": "-DVX_CFG_NUM_WARPS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_CORES=2 -DVX_CFG_NUM_THREADS=4 -DVX_CFG_L2_ENABLE", "driver": "rtlsim" }, @@ -39,7 +39,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "fd128828360dcf27", + "config_hash": "ebdab55848e286a9", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32", "driver": "rtlsim" }, @@ -50,7 +50,7 @@ }, "app": "sgemm2_tcu", "args": "-m 128 -n 128 -k 64", - "config_hash": "9934ecd51fa79038", + "config_hash": "0c44c36fec7dc56d", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -61,7 +61,7 @@ }, "app": "sgemm_tcu", "args": "-m 128 -n 128 -k 128", - "config_hash": "328c614d0141deb8", + "config_hash": "571171e137abb418", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DVX_CFG_EXT_LDST_MATRIX_ENABLE", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_mx.json b/ci/baselines/perf/tensor_mx.json index e8acc30a31..d23208d0f1 100644 --- a/ci/baselines/perf/tensor_mx.json +++ b/ci/baselines/perf/tensor_mx.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_mx", "args": "-m 128 -n 128 -k32", - "config_hash": "af77d4a5f0a8576f", + "config_hash": "5614ebd44a8b65a7", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_MX_ENABLE -DVX_CFG_TCU_FP8_ENABLE -DITYPE=mxfp8 -DOTYPE=fp32 -DVX_CFG_TCU_TYPE_DPI", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_sp.json b/ci/baselines/perf/tensor_sp.json index 7e3e05593e..d751033cdb 100644 --- a/ci/baselines/perf/tensor_sp.json +++ b/ci/baselines/perf/tensor_sp.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_sp", "args": "-m 128 -n 128 -k 128", - "config_hash": "e7354a7a2bc00238", + "config_hash": "69f9bc91c2215b0b", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE", "driver": "rtlsim" } diff --git a/ci/baselines/perf/tensor_wg.json b/ci/baselines/perf/tensor_wg.json index 1c5354893e..0db2111d06 100644 --- a/ci/baselines/perf/tensor_wg.json +++ b/ci/baselines/perf/tensor_wg.json @@ -6,7 +6,7 @@ }, "app": "sgemm_tcu_wg", "args": "-m64 -n64 -k64", - "config_hash": "4d4bf375520e05f4", + "config_hash": "dbb50d1304fd1913", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1 -DVX_CFG_TCU_FEDP2K -DITYPE=fp16 -DOTYPE=fp32 -DWGMMA_NRC=8 -DWGMMA_RS", "driver": "rtlsim" }, @@ -17,7 +17,7 @@ }, "app": "sgemm_tcu_wg", "args": "-m 128 -n 128 -k 128", - "config_hash": "9eda8c6f5a4af670", + "config_hash": "0a292df097c70763", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DITYPE=fp16 -DOTYPE=fp32 -DWGMMA_NRC=32 -DWGMMA_SS -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" }, @@ -28,7 +28,7 @@ }, "app": "sgemm_tcu_wg_sp", "args": "-m 128 -n 128 -k 128", - "config_hash": "279fd043db54e2d1", + "config_hash": "623d902ce52c341d", "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8 -DVX_CFG_ISSUE_WIDTH=4 -DVX_CFG_EXT_TCU_ENABLE -DVX_CFG_TCU_WGMMA_ENABLE -DVX_CFG_TCU_SPARSE_ENABLE -DWGMMA_NRC=32 -DVX_CFG_NUM_ALU_BLOCKS=1 -DVX_CFG_NUM_LSU_BLOCKS=1 -DVX_CFG_NUM_FPU_BLOCKS=1", "driver": "rtlsim" } diff --git a/ci/baselines/synthesis/beacon/core.json b/ci/baselines/synthesis/beacon/core.json index 3f207c971a..15108d7ccc 100644 --- a/ci/baselines/synthesis/beacon/core.json +++ b/ci/baselines/synthesis/beacon/core.json @@ -71,8 +71,8 @@ "dut": "core", "result": { "bram": 39.0, - "build_time_s": 65, - "deep_endpoints": 1508, + "build_time_s": 105, + "deep_endpoints": 1610, "deepest_paths": [ "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[822]", "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[823]", @@ -85,15 +85,15 @@ "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[830]", "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[831]" ], - "dsp": 97, - "endpoints": 92855, + "dsp": 107, + "endpoints": 91216, "env": { "beacon": "beacon 134d03b9e", "circt": "CIRCT 90c5fd313", "device": "xcu55c-fsvh2892-2L-e", "xlen": 32 }, - "ff": 140277, + "ff": 103820, "fix_levels": 12, "interfaces": { "core.dcache_bus_if_0_rsp_ready": 1, @@ -103,7 +103,7 @@ "core.icache_bus_if_0_rsp_ready": 1, "core.kmu_bus_if_ready": 1 }, - "lut": 127132, + "lut": 116403, "lutram": 6860, "max_levels": 15, "pred_fmax_mhz": 284.3, @@ -135,15 +135,25 @@ "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw_req_queue/g_ebN_fifo_queue": 15, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw_req_queue/g_ebN_fifo_queue/g_depth_n_dp_ram": 12, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/req_ibuf/allocator": 10, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/mul1/pipe_reg": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/mul2/pipe_reg": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/rom/rom": 8, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s1_reg": 13, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s2_reg": 8, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s3_reg": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s5_reg": 14, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s6_reg": 11, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s7_reg": 13, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit": 8, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit/rsp_buf/g_eb2_stream_buffer": 8, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit/wctl_reg": 13, - "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue": 10, - "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/g_depth_n_dp_ram": 9, - "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/pending_size": 8, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_g_uop_uop_sequencer": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue": 11, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/g_depth_n_dp_ram": 10, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/pending_size": 9, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard": 8, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard/g_fu_goingfull_*_fu_pending": 10, - "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/decode": 8, + "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/decode": 9, "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/fetch": 9, "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/fetch/decompressor": 14, "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/fetch/decompressor/buffer_ram": 8, @@ -157,7 +167,7 @@ "core/scheduler/warp_shared_unit/bar_unit": 8 }, "uram": 0, - "watch_endpoints": 8548, + "watch_endpoints": 9292, "watch_levels": 8 } }, @@ -168,8 +178,8 @@ "dut": "core", "result": { "bram": 39.0, - "build_time_s": 60, - "deep_endpoints": 1508, + "build_time_s": 100, + "deep_endpoints": 1610, "deepest_paths": [ "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[822]", "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[823]", @@ -182,15 +192,15 @@ "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[830]", "15 core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks_0.buf_out/g_eb2.stream_buffer/g_buffer.data_out_r[1551] -> core/g_compute_slices.g_slices_0.compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r.d[831]" ], - "dsp": 97, - "endpoints": 92887, + "dsp": 107, + "endpoints": 91248, "env": { "beacon": "beacon 134d03b9e", "circt": "CIRCT 90c5fd313", "device": "xcu55c-fsvh2892-2L-e", "xlen": 32 }, - "ff": 140293, + "ff": 103836, "fix_levels": 12, "interfaces": { "core.dcache_bus_if_0_rsp_ready": 1, @@ -200,7 +210,7 @@ "core.icache_bus_if_0_rsp_ready": 1, "core.kmu_bus_if_ready": 1 }, - "lut": 127514, + "lut": 116782, "lutram": 6860, "max_levels": 15, "pred_fmax_mhz": 284.3, @@ -232,16 +242,25 @@ "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw_req_queue/g_ebN_fifo_queue": 15, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw_req_queue/g_ebN_fifo_queue/g_depth_n_dp_ram": 12, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/req_ibuf/allocator": 10, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/mul1/pipe_reg": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/mul2/pipe_reg": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/rom/rom": 8, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s1_reg": 13, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s2_reg": 8, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s3_reg": 9, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s5_reg": 14, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s6_reg": 11, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s7_reg": 13, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit": 8, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit/rsp_buf/g_eb2_stream_buffer": 8, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit/wctl_reg": 13, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_g_uop_uop_sequencer": 9, - "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue": 10, - "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/g_depth_n_dp_ram": 9, - "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/pending_size": 8, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue": 11, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/g_depth_n_dp_ram": 10, + "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/pending_size": 9, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard": 8, "core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard/g_fu_goingfull_*_fu_pending": 10, - "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/decode": 8, + "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/decode": 9, "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/fetch": 9, "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/fetch/decompressor": 14, "core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/fetch/decompressor/buffer_ram": 8, @@ -255,7 +274,7 @@ "core/scheduler/warp_shared_unit/bar_unit": 8 }, "uram": 0, - "watch_endpoints": 8789, + "watch_endpoints": 9532, "watch_levels": 8 } }, @@ -319,8 +338,8 @@ "dut": "vortex", "result": { "bram": 81.0, - "build_time_s": 25, - "deep_endpoints": 2205, + "build_time_s": 40, + "deep_endpoints": 2301, "deepest_paths": [ "15 g_clusters_0.cluster/g_sockets_0.socket/g_cores_0.core/mem_unit/g_dcache_bus_if_0.g_flush_lane.dcr_flush/dcache_flush_arb/req_arb/g_input_select.g_arbiter.g_out_buf_0.out_buf/g_eb2.stream_buffer/g_buffer.data_out_r[120] -> g_clusters_0.cluster/g_sockets_0.socket/dmmu/tlb/cam/mru_r.d[0]", "15 g_clusters_0.cluster/g_sockets_0.socket/g_cores_0.core/mem_unit/g_dcache_bus_if_0.g_flush_lane.dcr_flush/dcache_flush_arb/req_arb/g_input_select.g_arbiter.g_out_buf_0.out_buf/g_eb2.stream_buffer/g_buffer.data_out_r[120] -> g_clusters_0.cluster/g_sockets_0.socket/dmmu/tlb/cam/mru_r.d[1]", @@ -333,15 +352,15 @@ "15 g_clusters_0.cluster/g_sockets_0.socket/g_cores_0.core/mem_unit/g_dcache_bus_if_0.g_flush_lane.dcr_flush/dcache_flush_arb/req_arb/g_input_select.g_arbiter.g_out_buf_0.out_buf/g_eb2.stream_buffer/g_buffer.data_out_r[120] -> g_clusters_0.cluster/g_sockets_0.socket/dmmu/tlb/cam/mru_r.d[8]", "15 g_clusters_0.cluster/g_sockets_0.socket/g_cores_0.core/mem_unit/g_dcache_bus_if_0.g_flush_lane.dcr_flush/dcache_flush_arb/req_arb/g_input_select.g_arbiter.g_out_buf_0.out_buf/g_eb2.stream_buffer/g_buffer.data_out_r[120] -> g_clusters_0.cluster/g_sockets_0.socket/dmmu/tlb/cam/mru_r.d[9]" ], - "dsp": 50, - "endpoints": 126462, + "dsp": 60, + "endpoints": 126360, "env": { "beacon": "beacon 134d03b9e", "circt": "CIRCT 90c5fd313", "device": "xcu55c-fsvh2892-2L-e", "xlen": 32 }, - "ff": 142344, + "ff": 125254, "fix_levels": 12, "interfaces": { "g_clusters_*_cluster.busy": 1, @@ -357,11 +376,11 @@ "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core.icache_bus_if_0_rsp_ready": 1, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core.kmu_bus_if_ready": 1 }, - "lut": 126581, + "lut": 126185, "lutram": 10110, "max_levels": 15, "pred_fmax_mhz": 286.6, - "risk_endpoints": 122, + "risk_endpoints": 126, "tied_bits": 2, "tied_ports": [ { @@ -406,16 +425,24 @@ "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lmem_switch/rsp_arb/g_input_select_g_arbiter_g_out_buf_*_out_buf/g_eb1_pipe_buffer/g_register_g_pipe_regs_*_pipe_register": 8, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw_req_queue/g_ebN_fifo_queue": 15, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw_req_queue/g_ebN_fifo_queue/g_depth_n_dp_ram": 12, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/mul1/pipe_reg": 9, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/mul2/pipe_reg": 9, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/rom/rom": 8, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s1_reg": 11, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s2_reg": 8, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s3_reg": 9, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s5_reg": 14, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s6_reg": 11, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/tfu_unit/g_pes_*_pe/s7_reg": 13, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit": 8, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/execute_slice/sfu_block/wctl_unit/rsp_buf/g_eb2_stream_buffer": 8, - "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_g_uop_uop_sequencer": 8, + "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_g_uop_uop_sequencer": 10, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue": 10, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/g_depth_n_dp_ram": 9, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/ibuffer/g_bufs_*_instr_buf/g_ebN_fifo_queue/pending_size": 10, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard": 11, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard/g_fu_goingfull_*_fu_pending": 11, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard/g_scoreboard_*_inuse_table": 10, - "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard/g_stanging_bufs_*_stanging_buf/g_register_g_pipe_regs_*_pipe_register": 8, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/backend_slice/issue_slice/scoreboard/out_buf/g_eb2_stream_buffer": 9, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/g_compute_slices_g_slices_*_compute_slice/frontend_slice/warp_sched/g_warps_*_warp_ctx": 9, "g_clusters_*_cluster/g_sockets_*_socket/g_cores_*_core/mem_unit/lmem_unit/engine_a/rsp_queue/pending_size": 8, @@ -444,7 +471,7 @@ "kmu": 9 }, "uram": 0, - "watch_endpoints": 8957, + "watch_endpoints": 9587, "watch_levels": 8 } } diff --git a/ci/baselines/synthesis/beacon_asic/core.json b/ci/baselines/synthesis/beacon_asic/core.json index ccb2e346c8..d6d1eb17d1 100644 --- a/ci/baselines/synthesis/beacon_asic/core.json +++ b/ci/baselines/synthesis/beacon_asic/core.json @@ -31,21 +31,21 @@ "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", "dut": "core", "result": { - "build_time_s": 50, - "cells": 743174, - "endpoints": 66090, + "build_time_s": 65, + "cells": 429305, + "endpoints": 50584, "env": { "beacon": "beacon 134d03b9e", "circt": "CIRCT 90c5fd313", "pdk": "asap7", "xlen": 32 }, - "ff": 93652, - "fmax_mhz": 1078.7, + "ff": 76744, + "fmax_mhz": 1107.4, "macros": 13, - "max_stages": 29, + "max_stages": 28, "overhead_ps": 231, - "period_ps": 927, + "period_ps": 903, "stage_ps": 24, "tied_bits": 2, "tied_ports": [ @@ -100,16 +100,16 @@ "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4", "dut": "top", "result": { - "build_time_s": 100, - "cells": 1341436, - "endpoints": 170681, + "build_time_s": 130, + "cells": 1039532, + "endpoints": 155971, "env": { "beacon": "beacon 134d03b9e", "circt": "CIRCT 90c5fd313", "pdk": "asap7", "xlen": 32 }, - "ff": 241658, + "ff": 225836, "fmax_mhz": 777.0, "macros": 88, "max_stages": 44, diff --git a/ci/baselines/synthesis/beacon_asic/tfu.json b/ci/baselines/synthesis/beacon_asic/tfu.json index a518233f6a..9f40a3b398 100644 --- a/ci/baselines/synthesis/beacon_asic/tfu.json +++ b/ci/baselines/synthesis/beacon_asic/tfu.json @@ -6,15 +6,15 @@ "dut": "tfu", "result": { "build_time_s": 10, - "cells": 14074, - "endpoints": 2343, + "cells": 27431, + "endpoints": 3065, "env": { "beacon": "beacon 134d03b9e", "circt": "CIRCT 90c5fd313", "pdk": "asap7", "xlen": 32 }, - "ff": 1816, + "ff": 2581, "fmax_mhz": 1239.2, "macros": 0, "max_stages": 24, diff --git a/ci/baselines/synthesis/xilinx/core.json b/ci/baselines/synthesis/xilinx/core.json index eb95731165..1a4efc9e74 100644 --- a/ci/baselines/synthesis/xilinx/core.json +++ b/ci/baselines/synthesis/xilinx/core.json @@ -182,175 +182,175 @@ "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_NUM_WARPS=16 -DVX_CFG_EXT_C_ENABLE -DVX_CFG_EXT_A_ENABLE", "dut": "core", "result": { - "bram": 137, - "build_time_s": 7528, + "bram": 43, + "build_time_s": 4605, "critical_paths": [ { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_cvt.g_units[10].fcvt_unit/pipe_reg2/g_pipe.g_no_reset.pipe_reg[0][17]/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_1148_1161/RAME_D1/I", "group": "core_clock", - "levels": 2, - "logic_ns": 0.193, - "route_ns": 3.285, - "route_pct": 94.45, - "slack_ns": -0.163, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r_reg[1346]/C" + "levels": 7, + "logic_ns": 0.86, + "route_ns": 2.521, + "route_pct": 74.566, + "slack_ns": -0.15, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1551]_rep_replica/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/frontend_slice/warp_sched/g_csr_cta[0].csr_cta/cta_warp_ram/g_no_asic.g_sync.g_auto.g_read_first.g_no_wren.rdata_r_reg[188]/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_1204_1217/RAMF_D1/I", "group": "core_clock", - "levels": 1, - "logic_ns": 0.215, - "route_ns": 3.26, - "route_pct": 93.813, - "slack_ns": -0.162, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/sfu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1635]/C" + "levels": 9, + "logic_ns": 0.929, + "route_ns": 2.447, + "route_pct": 72.484, + "slack_ns": -0.147, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/sfu_block/csr_unit/csr_data/wr_data_r_reg[20]/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_1204_1217/RAMF_D1/I", "group": "core_clock", - "levels": 5, - "logic_ns": 0.465, - "route_ns": 3.011, - "route_pct": 86.621, - "slack_ns": -0.162, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/sfu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1635]/C" + "levels": 9, + "logic_ns": 0.987, + "route_ns": 2.386, + "route_pct": 70.737, + "slack_ns": -0.143, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_644_657/RAMA_D1/I", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_784_797/RAMA_D1/I", "group": "core_clock", - "levels": 0, - "logic_ns": 0.078, - "route_ns": 3.315, - "route_pct": 97.701, - "slack_ns": -0.161, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/output_arb/g_input_select.g_arbiter.g_out_buf[0].out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[645]/C" + "levels": 9, + "logic_ns": 1.127, + "route_ns": 2.246, + "route_pct": 66.589, + "slack_ns": -0.142, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/alu_block/alu_int/rsp_buf/g_eb1.pipe_buffer/g_register.g_pipe_regs[0].pipe_register/g_pipe.g_partial_reset.pipe_free_reg[0][49]_bret/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_882_895/RAMA_D1/I", "group": "core_clock", - "levels": 7, - "logic_ns": 0.472, - "route_ns": 3.005, - "route_pct": 86.424, - "slack_ns": -0.161, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r_reg[1541]/C" + "levels": 10, + "logic_ns": 0.927, + "route_ns": 2.445, + "route_pct": 72.51, + "slack_ns": -0.141, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_168_181/RAMF/I", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_784_797/RAMA_D1/I", "group": "core_clock", - "levels": 0, - "logic_ns": 0.079, - "route_ns": 3.335, - "route_pct": 97.686, - "slack_ns": -0.158, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/output_arb/g_input_select.g_arbiter.g_out_buf[0].out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[178]/C" + "levels": 9, + "logic_ns": 1.07, + "route_ns": 2.301, + "route_pct": 68.26, + "slack_ns": -0.14, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/alu_block/alu_int/rsp_buf/g_eb1.pipe_buffer/g_register.g_pipe_regs[0].pipe_register/g_pipe.g_partial_reset.pipe_free_reg[0][291]_bret__2/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_882_895/RAMB/I", "group": "core_clock", - "levels": 7, - "logic_ns": 0.607, - "route_ns": 2.865, - "route_pct": 82.516, - "slack_ns": -0.156, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r_reg[1541]/C" + "levels": 10, + "logic_ns": 0.863, + "route_ns": 2.528, + "route_pct": 74.552, + "slack_ns": -0.137, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_658_671/RAMD/I", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_882_895/RAMG/I", "group": "core_clock", - "levels": 0, - "logic_ns": 0.079, - "route_ns": 3.33, - "route_pct": 97.683, - "slack_ns": -0.155, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/output_arb/g_input_select.g_arbiter.g_out_buf[0].out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[664]/C" + "levels": 10, + "logic_ns": 0.863, + "route_ns": 2.525, + "route_pct": 74.531, + "slack_ns": -0.134, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/alu_block/alu_int/rsp_buf/g_eb1.pipe_buffer/g_register.g_pipe_regs[0].pipe_register/g_pipe.g_partial_reset.pipe_free_reg[0][53]_bret__0/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_1190_1203/RAMC/I", "group": "core_clock", - "levels": 7, - "logic_ns": 0.651, - "route_ns": 2.819, - "route_pct": 81.241, - "slack_ns": -0.155, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r_reg[1542]/C" + "levels": 11, + "logic_ns": 1.017, + "route_ns": 2.371, + "route_pct": 69.983, + "slack_ns": -0.133, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" }, { - "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/alu_block/alu_int/rsp_buf/g_eb1.pipe_buffer/g_register.g_pipe_regs[0].pipe_register/g_pipe.g_partial_reset.pipe_free_reg[0][230]_bret__0/D", + "endpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/lsu_scheduler/mem_scheduler/g_req_queue_rw.req_queue/g_ebN.fifo_queue/g_depth_n.dp_ram/g_no_asic.g_sync.g_auto.g_write_first.g_no_wren.ram_reg_0_3_882_895/RAMA_D1/I", "group": "core_clock", - "levels": 7, - "logic_ns": 0.754, - "route_ns": 2.715, - "route_pct": 78.267, - "slack_ns": -0.154, - "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/g_depth_n.g_out_reg.data_out_r_reg[1541]/C" + "levels": 9, + "logic_ns": 0.957, + "route_ns": 2.408, + "route_pct": 71.558, + "slack_ns": -0.133, + "startpoint": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_dispatch/g_blocks[0].buf_out/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[1565]/C" } ], - "dsp": 96, + "dsp": 102, "env": { "device": "xcu55c-fsvh2892-2L-e", "opt_level": 3, "vivado": "2024.2", "xlen": 32 }, - "ff": 144158, - "fmax_mhz": 286.0, + "ff": 86336, + "fmax_mhz": 287.1, "high_fanout_nets": [ { - "driver": "LUT2", - "fanout": 22478, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fdivsqrt.div_pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "driver": "PORT", + "fanout": 6598, + "net": "reset" }, { - "driver": "BUFGCE", - "fanout": 12570, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fdivsqrt.sqrt_pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "driver": "FDRE", + "fanout": 1877, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/g_depth_n.wr_ptr_r_reg[0]_0[0]" }, { - "driver": "LUT2", - "fanout": 9573, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fma.pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0_bufg_place" + "driver": "FDRE", + "fanout": 1876, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/g_depth_n.wr_ptr_r[1]" }, { - "driver": "BUFGCE", - "fanout": 9263, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fma.pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "driver": "LUT4", + "fanout": 1874, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/g_collectors[0].opc_unit/out_buf/g_eb2.stream_buffer/g_ebN.push_0" }, { - "driver": "PORT", - "fanout": 7537, - "net": "reset" + "driver": "FDRE", + "fanout": 1864, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/g_depth_n.wr_ptr_r_reg[0]_0[0]" }, { - "driver": "LUT6", - "fanout": 2060, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/output_arb/g_input_select.g_arbiter.g_out_buf[0].out_buf/g_eb2.stream_buffer/g_size_gt1.g_single_step.g_size_gt2.empty_r_reg_rep" + "driver": "FDRE", + "fanout": 1863, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/g_depth_n.wr_ptr_r[1]" }, { - "driver": "FDRE", - "fanout": 1874, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/Q[0]" + "driver": "LUT4", + "fanout": 1860, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/g_collectors[0].opc_unit/out_buf/g_eb2.stream_buffer/g_ebN.push_1" }, { - "driver": "FDRE", - "fanout": 1873, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[0].buffer/g_ebN.fifo_queue/Q[1]" + "driver": "LUT6", + "fanout": 1798, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/operands/g_collectors[0].opc_unit/out_buf/g_eb2.stream_buffer/g_size_gt1.g_single_step.g_size_gt2.empty_r_reg_rep" }, { - "driver": "LUT4", - "fanout": 1872, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_ebN.push_0" + "driver": "LUT2", + "fanout": 1641, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[2].buffer/g_ebN.fifo_queue/pending_size/E[0]" }, { - "driver": "FDRE", - "fanout": 1858, - "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/Q[0]" + "driver": "LUT6", + "fanout": 1617, + "net": "core/g_compute_slices.g_slices[0].compute_slice/backend_slice/issue_slice/dispatcher/g_buffers[3].buffer/g_ebN.fifo_queue/pending_size/g_size_gt1.g_single_step.g_size_gt2.empty_r_reg_1" } ], - "lut": 168414, - "lutram": 8528, + "lut": 123981, + "lutram": 7439, "uram": 0, - "wns_ns": -0.163 + "wns_ns": -0.15 } }, "lmem": { @@ -536,175 +536,175 @@ "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4 -DVX_CFG_NUM_CORES=2 -DVX_CFG_EXT_A_ENABLE -DVX_CFG_VM_ENABLE -DVX_CFG_DCACHE_LATENCY=3", "dut": "top", "result": { - "bram": 76, - "build_time_s": 6254, + "bram": 85, + "build_time_s": 5491, "critical_paths": [ { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/probe_amo_hit_r_reg/D", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.wbq_data_reg[3][48]/D", "group": "core_clock", - "levels": 13, - "logic_ns": 1.173, - "route_ns": 2.794, - "route_pct": 70.427, - "slack_ns": 0.015, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_read_merge.g_realign.g_port[1].head_line_r_reg[23]/C" + "levels": 8, + "logic_ns": 0.79, + "route_ns": 3.146, + "route_pct": 79.928, + "slack_ns": 0.044, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.cmp_rhs_reg[17]/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/probe_amo_hit_r_reg/D", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_pipe[1].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[104]/D", "group": "core_clock", - "levels": 13, - "logic_ns": 1.148, - "route_ns": 2.811, - "route_pct": 71.001, - "slack_ns": 0.023, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_read_merge.g_realign.g_port[1].head_line_r_reg[1]/C" + "levels": 10, + "logic_ns": 1.108, + "route_ns": 2.817, + "route_pct": 71.768, + "slack_ns": 0.055, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_block/mem_path/dcache_adapter/stream_unpack/g_unpack.g_outbuf[1].out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[111]/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/probe_amo_hit_r_reg/D", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.wbq_data_reg[3][48]/D", "group": "core_clock", - "levels": 13, - "logic_ns": 1.147, - "route_ns": 2.782, - "route_pct": 70.81, - "slack_ns": 0.051, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dmmu/g_pipe[0].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[108]/C" + "levels": 9, + "logic_ns": 0.855, + "route_ns": 3.069, + "route_pct": 78.211, + "slack_ns": 0.058, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.cmp_rhs_reg[4]/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/probe_amo_hit_r_reg/D", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_pipe[1].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[104]/D", "group": "core_clock", - "levels": 13, - "logic_ns": 1.346, - "route_ns": 2.584, - "route_pct": 65.748, - "slack_ns": 0.053, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dmmu/g_pipe[1].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[99]/C" + "levels": 10, + "logic_ns": 1.124, + "route_ns": 2.795, + "route_pct": 71.32, + "slack_ns": 0.061, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_lane_bus[1].req_skid/g_buffer.buffer_reg[112]/C" }, { - "endpoint": "vx_reset_shift_r_reg[7]_replica_4/S", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_gather/g_out_bufs[0].out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[129]/D", "group": "core_clock", "levels": 1, - "logic_ns": 0.168, - "route_ns": 3.654, - "route_pct": 95.605, - "slack_ns": 0.061, - "startpoint": "reset_seq/FSM_onehot_state_reg[3]/C" + "logic_ns": 0.178, + "route_ns": 3.737, + "route_pct": 95.453, + "slack_ns": 0.066, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_gather/g_out_bufs[0].out_buf/g_eb2.stream_buffer/g_buffer.valid_in_r_reg/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/probe_amo_hit_r_reg/D", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_gather/g_out_bufs[0].out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.buffer_r_reg[140]/CE", "group": "core_clock", - "levels": 13, - "logic_ns": 1.206, - "route_ns": 2.707, - "route_pct": 69.178, - "slack_ns": 0.068, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dmmu/g_pipe[0].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[104]/C" + "levels": 0, + "logic_ns": 0.081, + "route_ns": 3.749, + "route_pct": 97.885, + "slack_ns": 0.067, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/lsu_gather/g_out_bufs[0].out_buf/g_eb2.stream_buffer/g_buffer.valid_in_r_reg/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/probe_amo_hit_r_reg/D", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_pipe[1].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[104]/D", "group": "core_clock", - "levels": 13, - "logic_ns": 1.278, - "route_ns": 2.637, - "route_pct": 67.354, - "slack_ns": 0.068, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dmmu/g_pipe[1].out_pipe/g_eb2.stream_buffer/g_buffer.valid_out_r_reg/C" + "levels": 10, + "logic_ns": 1.171, + "route_ns": 2.739, + "route_pct": 70.05, + "slack_ns": 0.07, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_lane_bus[1].req_skid/g_buffer.has_data_reg_inv/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/cache_tags/tag_store/g_no_asic.g_sync.g_auto.g_read_first.g_wren.rdata_r_reg[10]/CE", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.wbq_data_reg[3][48]/D", "group": "core_clock", - "levels": 2, - "logic_ns": 0.26, - "route_ns": 3.564, - "route_pct": 93.201, - "slack_ns": 0.07, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/reg_cmt/g_pipe.g_partial_reset.pipe_free_reg[0][106]/C" + "levels": 9, + "logic_ns": 0.853, + "route_ns": 3.052, + "route_pct": 78.156, + "slack_ns": 0.076, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.cmp_rhs_reg[1]/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/cache_tags/tag_store/g_no_asic.g_sync.g_auto.g_read_first.g_wren.rdata_r_reg[12]/CE", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.wbq_data_reg[3][48]/D", "group": "core_clock", - "levels": 2, - "logic_ns": 0.26, - "route_ns": 3.564, - "route_pct": 93.201, - "slack_ns": 0.07, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/reg_cmt/g_pipe.g_partial_reset.pipe_free_reg[0][106]/C" + "levels": 8, + "logic_ns": 0.903, + "route_ns": 2.998, + "route_pct": 76.852, + "slack_ns": 0.079, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/g_amo.amo/g_commit.cmp_rhs_reg[17]/C" }, { - "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/cache_tags/tag_store/g_no_asic.g_sync.g_auto.g_read_first.g_wren.rdata_r_reg[14]/CE", + "endpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_pipe[0].out_pipe/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[110]/D", "group": "core_clock", - "levels": 2, - "logic_ns": 0.26, - "route_ns": 3.564, - "route_pct": 93.201, - "slack_ns": 0.07, - "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/dcache/g_cache_wrap[0].cache_wrap/g_cache.cache/g_banks[1].bank/reg_cmt/g_pipe.g_partial_reset.pipe_free_reg[0][106]/C" + "levels": 9, + "logic_ns": 0.857, + "route_ns": 3.043, + "route_pct": 78.028, + "slack_ns": 0.08, + "startpoint": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/dmmu/g_lane_bus[0].req_skid/g_buffer.has_data_reg_inv/C" } ], - "dsp": 48, + "dsp": 54, "env": { "device": "xcu55c-fsvh2892-2L-e", "opt_level": 3, "vivado": "2024.2", "xlen": 32 }, - "ff": 153132, - "fmax_mhz": 250.9, + "ff": 136068, + "fmax_mhz": 252.8, "high_fanout_nets": [ { "driver": "LUT2", - "fanout": 5643, - "net": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fdivsqrt.div_pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "fanout": 2558, + "net": "cp_core/u_dma/chunk_buf/reset_0" }, { - "driver": "BUFGCE", - "fanout": 5638, - "net": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fdivsqrt.div_pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "driver": "LUT4", + "fanout": 1851, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2cache/g_bypass.cache_bypass/mem_bus_out_arb/req_arb/g_passthru.g_out_buf[0].out_buf/g_eb2.stream_buffer/g_buffer.valid_out_r_reg_1" }, { - "driver": "BUFGCE", - "fanout": 4510, - "net": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fma.pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_1" + "driver": "MUXF7", + "fanout": 1625, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/fill_set[5]" }, { - "driver": "BUFGCE", - "fanout": 3626, - "net": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fma.pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_1" + "driver": "MUXF7", + "fanout": 1620, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/fill_set[3]" }, { - "driver": "LUT2", - "fanout": 3323, - "net": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[0].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fdivsqrt.sqrt_pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "driver": "MUXF7", + "fanout": 1600, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/fill_set[4]" }, { - "driver": "BUFGCE", - "fanout": 3306, - "net": "g_multi_port.vortex/g_clusters[0].cluster/g_sockets[1].socket/g_cores[0].core/g_compute_slices.g_slices[0].compute_slice/backend_slice/execute_slice/fpu_block/fpu_dsp/g_fdivsqrt.sqrt_pe_ser/g_out_skid.out_buf/g_buffer.has_data_reg_inv_0" + "driver": "MUXF7", + "fanout": 1596, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/fill_set[2]" }, { - "driver": "BUFGCE", - "fanout": 2134, - "net": "cp_core/u_regfile/reset_0[0]" + "driver": "MUXF7", + "fanout": 1537, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/fill_set[1]" }, { - "driver": "LUT4", - "fanout": 1851, - "net": "g_multi_port.vortex/g_clusters[0].cluster/l2cache/g_bypass.cache_bypass/mem_bus_out_arb/req_arb/g_passthru.g_out_buf[0].out_buf/g_eb2.stream_buffer/g_buffer.valid_out_r_reg_1" + "driver": "MUXF7", + "fanout": 1456, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/fill_set[0]" }, { "driver": "MUXF7", - "fanout": 1815, - "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/g_buffer.g_no_out_reg.data_out_r_reg[32]_4" + "fanout": 1437, + "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/g_buffer.g_no_out_reg.data_out_r_reg[33]" }, { - "driver": "MUXF7", - "fanout": 1691, - "net": "g_multi_port.vortex/g_clusters[0].cluster/l2tlb/mshr/g_buffer.g_no_out_reg.data_out_r_reg[32]_3" + "driver": "LUT6", + "fanout": 1234, + "net": "g_multi_port.g_vx_mem_adapter[1].mem_data_adapter/req_out_buf/g_eb2.stream_buffer/g_buffer.g_out_reg.data_out_r_reg[524]_2[0]" } ], - "lut": 138369, - "lutram": 9896, + "lut": 132571, + "lutram": 8326, "uram": 0, - "wns_ns": 0.015 + "wns_ns": 0.044 } } } diff --git a/ci/baselines/synthesis/xilinx/tfu.json b/ci/baselines/synthesis/xilinx/tfu.json index 830fe83018..1e1136e3fa 100644 --- a/ci/baselines/synthesis/xilinx/tfu.json +++ b/ci/baselines/synthesis/xilinx/tfu.json @@ -1,179 +1,179 @@ { "tfu": { "clock_mhz": 300, - "config_hash": "5d5eb85429e40b51", + "config_hash": "75ae5ac6627b2276", "configs": "-DVX_CFG_NUM_THREADS=16 -DVX_CFG_NUM_WARPS=16", "dut": "tfu", "result": { - "bram": 1, - "build_time_s": 2418, + "bram": 2, + "build_time_s": 890, "critical_paths": [ { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][77]/S", "group": "core_clock", - "levels": 12, - "logic_ns": 1.33, - "route_ns": 1.795, - "route_pct": 57.443, - "slack_ns": 0.187, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][77]/S", "group": "core_clock", - "levels": 12, - "logic_ns": 1.33, - "route_ns": 1.792, - "route_pct": 57.397, - "slack_ns": 0.191, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][80]/S", "group": "core_clock", - "levels": 12, - "logic_ns": 1.328, - "route_ns": 1.793, - "route_pct": 57.452, - "slack_ns": 0.191, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][80]/S", "group": "core_clock", - "levels": 12, - "logic_ns": 1.329, - "route_ns": 1.791, - "route_pct": 57.402, - "slack_ns": 0.193, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][81]/S", "group": "core_clock", - "levels": 11, - "logic_ns": 1.225, - "route_ns": 1.879, - "route_pct": 60.54, - "slack_ns": 0.209, - "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[3]/C" + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, + "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][81]/S", "group": "core_clock", - "levels": 13, - "logic_ns": 1.333, - "route_ns": 1.739, - "route_pct": 56.615, - "slack_ns": 0.24, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][82]/S", "group": "core_clock", - "levels": 13, - "logic_ns": 1.335, - "route_ns": 1.737, - "route_pct": 56.545, - "slack_ns": 0.24, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][82]/S", "group": "core_clock", - "levels": 13, - "logic_ns": 1.334, - "route_ns": 1.737, - "route_pct": 56.568, - "slack_ns": 0.241, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.068, + "route_pct": 76.535, + "slack_ns": 0.513, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][78]/S", "group": "core_clock", - "levels": 13, - "logic_ns": 1.332, - "route_ns": 1.733, - "route_pct": 56.544, - "slack_ns": 0.247, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.05, + "route_pct": 76.377, + "slack_ns": 0.532, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" }, { - "endpoint": "tfu_unit/g_pes[0].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][16]/D", + "endpoint": "tfu_unit/g_pes[1].pe/s1_reg/g_pipe.g_no_reset.pipe_reg[0][78]/S", "group": "core_clock", - "levels": 13, - "logic_ns": 1.31, - "route_ns": 1.752, - "route_pct": 57.215, - "slack_ns": 0.251, + "levels": 7, + "logic_ns": 0.634, + "route_ns": 2.05, + "route_pct": 76.377, + "slack_ns": 0.532, "startpoint": "tfu_unit/pe_serializer/g_serialize.batch_in_idx_reg[1]/C" } ], - "dsp": 3, + "dsp": 6, "env": { "device": "xcu55c-fsvh2892-2L-e", "opt_level": 3, "vivado": "2024.2", "xlen": 32 }, - "ff": 1105, - "fmax_mhz": 317.9, + "ff": 1745, + "fmax_mhz": 354.6, "high_fanout_nets": [ - { - "driver": "FDRE", - "fanout": 1044, - "net": "tfu_unit/pe_serializer/shift_reg/pe_valid_in" - }, { "driver": "LUT2", - "fanout": 718, + "fanout": 1348, "net": "tfu_unit/pe_serializer/pe_enable" }, { - "driver": "FDRE", - "fanout": 165, - "net": "tfu_unit/pe_serializer/g_serialize.batch_out_idx_reg[3]_rep_n_0" + "driver": "PORT", + "fanout": 212, + "net": "execute_data[1536]" }, { - "driver": "MUXF8", - "fanout": 164, - "net": "tfu_unit/pe_serializer/pe_data_in[0]_39[24]" + "driver": "PORT", + "fanout": 195, + "net": "execute_data[1537]" }, { - "driver": "MUXF8", - "fanout": 162, - "net": "tfu_unit/pe_serializer/pe_data_in[0]_39[23]" + "driver": "FDRE", + "fanout": 168, + "net": "tfu_unit/pe_serializer/g_serialize.batch_out_idx_reg[0]_rep__0_n_0" }, { "driver": "FDRE", - "fanout": 154, - "net": "tfu_unit/pe_serializer/g_serialize.batch_out_idx[3]" + "fanout": 166, + "net": "tfu_unit/pe_serializer/g_serialize.batch_out_idx_reg[1]_rep__0_n_0" }, { - "driver": "MUXF8", - "fanout": 148, - "net": "tfu_unit/pe_serializer/pe_data_in[0]_39[25]" + "driver": "FDRE", + "fanout": 166, + "net": "tfu_unit/pe_serializer/g_serialize.batch_out_idx_reg[2]_rep__2_n_0" }, { "driver": "FDRE", - "fanout": 133, - "net": "tfu_unit/pe_serializer/g_serialize.batch_in_idx[0]" + "fanout": 166, + "net": "tfu_unit/pe_serializer/shift_reg/g_shift.g_partial_reset.pipe_rst_reg[6][0]_rep__2_n_0" + }, + { + "driver": "PORT", + "fanout": 140, + "net": "execute_data[1538]" }, { "driver": "FDRE", "fanout": 132, - "net": "tfu_unit/pe_serializer/g_serialize.batch_in_idx[1]" + "net": "tfu_unit/pe_serializer/g_serialize.batch_in_idx[0]" }, { "driver": "FDRE", "fanout": 131, - "net": "tfu_unit/pe_serializer/g_serialize.batch_out_idx[1]" + "net": "tfu_unit/pe_serializer/g_serialize.batch_in_idx[1]" } ], - "lut": 2030, - "lutram": 64, + "lut": 2052, + "lutram": 42, "uram": 0, - "wns_ns": 0.187 + "wns_ns": 0.513 } } } diff --git a/ci/baselines/synthesis/yosys/core.json b/ci/baselines/synthesis/yosys/core.json index 4637d220b5..e1e76f81d9 100644 --- a/ci/baselines/synthesis/yosys/core.json +++ b/ci/baselines/synthesis/yosys/core.json @@ -30,9 +30,9 @@ "configs": "-DVX_CFG_NUM_THREADS=8 -DVX_CFG_NUM_WARPS=8", "dut": "core", "result": { - "build_time_s": 1045, - "cell_area_um2": 71902.189, - "cell_count": 690400, + "build_time_s": 575, + "cell_area_um2": 54699.801, + "cell_count": 523300, "env": { "corner": "tt", "pdk": "asap7", @@ -41,12 +41,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1044.386, - "power_mw": 1160.0, - "seq_area_um2": 24075.954, - "sram_area_um2": 27414.4, + "fmax_mhz": 1045.697, + "power_mw": 906.0, + "seq_area_um2": 19442.43, + "sram_area_um2": 27770.4, "tns_ns": 0.0, - "wns_ns": 0.043 + "wns_ns": 0.044 } }, "lmem": { @@ -80,9 +80,9 @@ "configs": "-DVX_CFG_NUM_THREADS=4 -DVX_CFG_NUM_WARPS=4", "dut": "top", "result": { - "build_time_s": 1628, - "cell_area_um2": 155558.511, - "cell_count": 1436932, + "build_time_s": 1020, + "cell_area_um2": 124052.516, + "cell_count": 1144564, "env": { "corner": "tt", "pdk": "asap7", @@ -91,12 +91,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1044.168, - "power_mw": 276.0, - "seq_area_um2": 64611.562, - "sram_area_um2": 97797.6, + "fmax_mhz": 1039.501, + "power_mw": 224.0, + "seq_area_um2": 52577.813, + "sram_area_um2": 101472.0, "tns_ns": 0.0, - "wns_ns": 0.042 + "wns_ns": 0.038 } } } diff --git a/ci/baselines/synthesis/yosys/tfu.json b/ci/baselines/synthesis/yosys/tfu.json index 6bf4fcc7e8..088d338485 100644 --- a/ci/baselines/synthesis/yosys/tfu.json +++ b/ci/baselines/synthesis/yosys/tfu.json @@ -5,9 +5,9 @@ "configs": "", "dut": "tfu", "result": { - "build_time_s": 65, - "cell_area_um2": 2014.329, - "cell_count": 19943, + "build_time_s": 50, + "cell_area_um2": 3488.207, + "cell_count": 35044, "env": { "corner": "tt", "pdk": "asap7", @@ -16,12 +16,12 @@ "xlen": 32, "yosys": "Yosys 0.69" }, - "fmax_mhz": 1054.852, - "power_mw": 19.3, - "seq_area_um2": 509.425, + "fmax_mhz": 1235.483, + "power_mw": 40.9, + "seq_area_um2": 716.753, "sram_area_um2": 0.0, "tns_ns": 0.0, - "wns_ns": 0.052 + "wns_ns": 0.191 } } }