# doc-cache created by Octave 11.1.0
# name: cache
# type: cell
# rows: 3
# columns: 1
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 3
fxp


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 4840
 -------------------------------------------------------------------
 Copyright (C) 2025 Ahmed Shahein
 -------------------------------------------------------------------
 GNU Octave Fixed-Point (fxp) Library
 This library introduces and fixed-point (fxp) data-type.
 Moreover, it provides a full support for standard arithemtic
 operands to handle the new fxp data-type.
 -------------------------------------------------------------------
 Author: Ahmed Shahein
 Email: ahmed.shahein@vlsi-design.org
 -------------------------------------------------------------------
 FXP  Fixed-point arithmetic data type for GNU Octave.

   FXP models hardware fixed-point quantization as found in FPGA, ASIC,
   and DSP designs.  It supports configurable word length, fraction
   length, signedness, overflow handling, and rounding.

 CONSTRUCTOR SYNTAX
   obj = fxp(data)
       Quantize DATA using default settings:
         S=1 (signed), WL=16 (bits), FL=8 (fraction bits),
         ovf_action='wrap', rnd_method='round'.

   obj = fxp(data, S, WL, FL)
       Quantize DATA with explicit format parameters.
         data - Scalar or array of double values to quantize.
         S    - Sign bit: 1 = signed two's complement, 0 = unsigned.
         WL   - Word length in bits (total, including sign bit).
         FL   - Fraction length in bits (bits right of the binary
                point).  Integer length IL = WL - FL - S.
       Default ovf_action='wrap' and rnd_method='round' are used.

   obj = fxp(data, S, WL, FL, 'ovf_action', OVF, 'rnd_method', RND)
   obj = fxp('data', data, 'S', S, 'WL', WL, 'FL', FL, ...)
       Any combination of keyword/value pairs may follow the positional
       arguments (or replace them entirely using 'data','S','WL','FL').
         OVF  - Overflow action (string):
                  'wrap' - modular wrap-around (default)
                  'sat'  - saturate to [min, max]
         RND  - Rounding method (string):
                  'round' - round half away from zero (default)
                  'floor' - round toward negative infinity
                  'ceil'  - round toward positive infinity
                  'fix' - round toward zero (truncation)

 PROPERTIES
   S          - Sign bit (0 = unsigned, 1 = signed two's complement)
   WL         - Word length in bits
   IL         - Integer length (WL - FL - S)
   FL         - Fraction length in bits
   ovf_action - Overflow action: 'wrap' or 'sat'
   rnd_method - Rounding method: 'round', 'floor', 'ceil', or 'fix'
   max        - Maximum representable value  ( 2^IL - 2^-FL )
   min        - Minimum representable value  (-2^IL * S    )
   res        - Resolution, i.e. LSB weight  ( 2^-FL       )
   DR_dB      - Dynamic range in dB          ( 6.02*(WL-FL))
   vfxp       - Quantized fixed-point value (real-valued double)
   dec        - Two's-complement integer representation
   int        - Integer part of vfxp
   frac       - Fractional part of vfxp
   float      - Original floating-point input
   bin        - Binary row vector (MSB first)
   bin_str    - Binary string with decimal-point marker (e.g. '0111.1100')
   err        - Absolute quantization error |float - vfxp|
   ovf        - Overflow flag (1 if overflow occurred, 0 otherwise)

 ARITHMETIC OPERATORS  (both operands must be fxp with same ovf/rnd settings)
   a + b      - Addition        (WL+1 bits, FL = max(FL_a, FL_b))
   a - b      - Subtraction     (WL+1 bits, FL = max(FL_a, FL_b))
   a * b      - Matrix multiply (WL = WL_a+WL_b, FL = FL_a+FL_b)
   a .* b     - Element-wise multiply (same format as *)
   a / b      - Matrix right divide
   a ./ b     - Element-wise right divide
   mod(a,b)   - Modulo

 COMPARISON OPERATORS  (return logical scalar or array)
   ==  ~=  <  <=  >  >=

 CONVERSION METHODS
   double(obj)  - Return vfxp as a double
   int32(obj)   - Return two's-complement integer as int32
   uint32(obj)  - Return magnitude of dec as uint32
   bin2dec(obj) - Reconstruct real value from binary representation
   struct(obj)  - Convert to struct containing all properties

 EXAMPLES
   % Basic quantization (signed 16-bit Q8)
   x = fxp(3.14, 1, 16, 8)

   % Unsigned 8-bit with 4 integer bits and 4 fraction bits
   x = fxp(7.3, 0, 8, 4)

   % Saturation overflow with floor rounding
   x = fxp(200.0, 0, 8, 4, 'ovf_action', 'sat', 'rnd_method', 'floor')

   % Array quantization and overflow flags
   x = fxp([0.1, 0.5, -0.5, 9.9], 1, 8, 4, 'ovf_action', 'sat')

   % Arithmetic operators
   a = fxp(1.5,  1, 8, 4);
   b = fxp(0.25, 1, 8, 4);
   c = a + b;    % c.vfxp == 1.75
   d = a * b;    % d.vfxp == 0.375
   e = a / b;    % e.vfxp == 6.0

   % Named-parameter form
   x = fxp('data', pi, 'S', 1, 'WL', 16, 'FL', 12, ...
            'ovf_action', 'sat', 'rnd_method', 'round')

 SEE ALSO
   double, int32, uint32, round, floor, ceil, fix



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
 -------------------------------------------------------------------
 Copyrig...





