@@ -404,78 +404,7 @@ Performance target: at least two quotient bits per cycle.
404404
405405---
406406
407- ## 8. Divider With Residual Remainder
408-
409- Combined quotient/residual divider, streamed, zero-bubble:
410-
411- ``` verilog
412- zkf_divrem #(parameter int WEXP = 6, parameter int WMAN = 18)(
413- input wire clk,
414- input wire rst,
415-
416- input wire in_valid,
417- input wire [WFULL-1:0] a,
418- input wire [WFULL-1:0] b,
419-
420- output wire out_valid,
421- output wire [WFULL-1:0] q,
422- output wire [WFULL-1:0] r,
423- output wire div0
424- );
425- ```
426-
427- The ` q ` and ` div0 ` outputs are bit-for-bit identical to ` zkf_div ` with the same parameters and inputs.
428-
429- Residual semantics:
430-
431- ``` text
432- This is a division residual, not C fmod and not IEEE remainder.
433-
434- if a == 0:
435- r = +0
436-
437- else if b == 0:
438- r = +0
439-
440- else if q is infinity:
441- r = +0
442-
443- else:
444- r = pack(a - b * q)
445- ```
446-
447- The residual expression above uses the decoded, rounded value of output ` q ` and is evaluated using the same
448- deterministic no-NaN infinity arithmetic as the rest of this format. Notable consequences:
449-
450- ``` text
451- finite / infinity:
452- q = +0
453- r = canonicalized a
454-
455- infinity / infinity:
456- q = +0
457- r = signed infinity with sign = sign(a)
458-
459- infinity / finite nonzero:
460- q = signed infinity with sign = sign(a) XOR sign(b)
461- r = +0
462- ```
463-
464- Implementation guidance:
465-
466- ``` text
467- Share the quotient generation path with zkf_div.
468- Use the final partial remainder instead of directly evaluating a - b * q with a separate multiplier.
469- After quotient rounding, adjust the residual if the quotient was incremented.
470- Pack the residual alongside the quotient so both outputs are aligned under out_valid.
471- ```
472-
473- Reusable logic shared by ` zkf_div ` and ` zkf_divrem ` should be extracted into nonpublic, underscore-prefixed helper
474- modules, consistent with the internal helper module convention above.
475-
476- ---
477-
478- ## 9. Cast From Signed Integer
407+ ## 8. Cast From Signed Integer
479408
480409``` verilog
481410zkf_from_int #(
@@ -513,7 +442,7 @@ zero input maps to canonical +0
513442
514443---
515444
516- ## 10 . Cast To Signed Integer
445+ ## 9 . Cast To Signed Integer
517446
518447``` verilog
519448zkf_to_int #(
@@ -556,7 +485,7 @@ Zero maps to integer zero.
556485
557486---
558487
559- ## 11 . Cast Between Two Format Sizes
488+ ## 10 . Cast Between Two Format Sizes
560489
561490``` verilog
562491zkf_resize #(
@@ -597,7 +526,7 @@ target overflow maps to signed infinity
597526
598527---
599528
600- ## 12 . Sqrt/log2/exp2, integer detection
529+ ## 11 . Sqrt/log2/exp2, integer detection
601530
602531Specifically ` zkf_log2 ` and ` zkf_exp2 ` can be used later to build arbitrary log/exp.
603532
@@ -670,7 +599,7 @@ module zkf_exp2 #(parameter WEXP = 6, parameter WMAN = 18,
670599
671600---
672601
673- ## 13 . Compare and Sort
602+ ## 12 . Compare and Sort
674603
675604Registered floating-point comparison and min/max sort. Comparison requires canonicalization
676605(exponent-zero inputs are treated as +0, exponent-all-ones inputs as signed infinity, fraction ignored for both classes),
@@ -749,7 +678,6 @@ division by zero asserts div0
749678add/sub module implements both operations exactly per spec
750679mul uses the same pack semantics as add/sub
751680div quotient matches exact a/b rounded per spec
752- div residual matches the documented a - b*q rule rounded per spec
753681resize equals decode-then-pack into target format
754682```
755683
0 commit comments