Skip to content

feat: add t_iq type for In-phase and Quadrature signals

Lukasz Butkowski requested to merge math_iq into main

This MR adds the math_iq type and t_iq package. t_iq holds two signed signals. In math_iq various functions are defined to use this type.

  • Initialize an IQ vector
  • Modify either the I or Q components of the vector
  • Resize vector components
  • Shift components
  • Extract the I and Q components
  • Check for equality/inequality of two vectors
  • Sum/difference/multiplications of two vectors
  • Shift left/right of the components of a vector
  • Swap components
  • Conjugate (I, -Q)
  • Cross product
  • Dot product
  • Complex product

Example usage:

  prs_test_iq : process                                                           
    constant C_COMP_LENGTH : natural := 18 -- IQ component length                 
    variable var_a           : t_iq(C_COMP_LENGTH-1 downto 0);                    
    variable var_a_ex        : t_iq(C_COMP_LENGTH-1 downto 0);                    
    variable var_b           : t_iq(C_COMP_LENGTH-1 downto 0);                    
    variable var_sum         : t_iq(C_COMP_LENGTH-1 downto 0);                    
    variable var_prod        : t_iq(C_COMP_LENGTH*2-1 downto 0);                  
    variable var_sumq        : signed(C_COMP_LENGTH-1 downto 0);                  
    variable var_prod_matrix : t_prod_matrix(C_COMP_LENGTH-1 downto 0);           
    variable var_dot_prod    : signed(C_COMP_LENGTH-1 downto 0);                  
  begin                                                                           
    var_a := f_new(-4, 9, C_COMP_LENGTH);                                      -- initialize with (I,   Q) = (-4, 9)
    var_b := f_new(to_signed(5, C_COMP_LENGTH), to_signed(-1, C_COMP_LENGTH)); -- initialize with (I,   Q) = (5, -1)
    var_sum := var_a + var_b;                                                  -- (I, Q) = (-4+5, 9-1  ) = (1, 8)
    var_prod := var_a * var_b;                                                 -- (I, Q) = (-4*5, 9*-  1) = (-20, -9)
    var_a_ex := f_set_i(var_a, 6);                                             -- new I, (I, Q) = (6,   9)
    var_sumq := f_get_q(var_a);                                                -- extract Q. var_sumq   = 9
    var_prod_matrix := f_prod_matrix(var_a, var_b);                            -- product matrix
    var_dot_prod := f_dot_prod(var_prod_matrix);                               -- dot product
  end;

Documentation: https://gitlab.msktools.desy.de/fpgafw/lib/desy_vhdl/-/blob/math_iq/doc/modules/ROOT/pages/math/math.adoc#user-content-package-math_iq

Issue: https://redmine.msktools.desy.de/issues/10232

Edited by Lukasz Butkowski

Merge request reports