Ejemplo n.º 1
0
    def __init__(self, taps):
        self.DELAY = 2
        self.TAPS = np.array(taps).tolist()

        # registers
        self.acc = [Sfix(left=1, right=-23)] * len(taps)
        self.out = Sfix(left=0, right=-17, overflow_style='saturate')
Ejemplo n.º 2
0
    def __init__(self,
                 iterations=17,
                 mode=CordicMode.VECTORING,
                 precision=-17):
        self.MODE = mode
        self.ITERATIONS = iterations + 1  # + 1 is for initial step registers it also helps pipeline code
        self.DELAY = self.ITERATIONS
        self.PHASE_LUT = [
            Sfix(np.arctan(2**-i) / np.pi, 0, precision, round_style='round')
            for i in range(self.ITERATIONS)
        ]

        # pipeline registers
        # give 1 extra bit, as there is stuff like CORDIC gain.. in some cases 2 bits may be needed!
        # there will be CORDIC gain + abs value held by x can be > 1
        self.x = [Sfix(0, 1, precision)] * self.ITERATIONS
        self.y = [Sfix(0, 1, precision)] * self.ITERATIONS
        self.phase = [Sfix(0, 1, precision)] * self.ITERATIONS
Ejemplo n.º 3
0
    def __init__(self, cordic_iterations=14):
        """

        :param cordic_iterations:
        """
        self.cordic = Cordic(cordic_iterations, CordicMode.ROTATION)
        self.phase_acc = Sfix(0, 0, -17, wrap_is_ok=True)
        self.out = Complex(0, 0, -17, overflow_style='saturate')
        self.DELAY = self.cordic.ITERATIONS + 1 + 1
        self.INIT_X = 1.0 / 1.646760  # gets rid of cordic gain, could use for amplitude modulation
Ejemplo n.º 4
0
    def __init__(self, gain=1.0):
        """
        :param gain: inverse of tx sensitivity
        """
        self.gain = gain
        # components / registers
        precision = -35
        self.conjugate = Complex(0.0 + 0.0j, 0, -17, overflow_style='saturate')
        self.mult = Complex(0.0 + 0.0j, 0, precision)
        self.angle = Angle(precision=precision)
        self.y = Sfix(0, 0, -17, overflow_style='saturate')

        # pi term gets us to -1 to +1
        self.GAIN_SFIX = Sfix(gain * np.pi,
                              4,
                              -13,
                              round_style='round',
                              overflow_style='saturate')

        self.DELAY = 1 + 1 + self.angle.DELAY
Ejemplo n.º 5
0
    def main(self, c):
        """
        :type c: Complex
        :return: abs (gain corrected) angle (in 1 to -1 range)
        """
        phase = Sfix(0.0, 0, -17)

        abs, _, angle = self.core.main(c.real, c.imag, phase)

        # get rid of CORDIC gain and extra bits
        self.y_abs = abs * (1.0 / 1.646760)
        self.y_angle = angle
        return self.y_abs, self.y_angle
Ejemplo n.º 6
0
    def main(self, phase_inc):
        """
        :param phase_inc: amount of rotation applied for next clock cycle, must be normalized to -1 to 1.
        :rtype: Complex
        """
        self.phase_acc = self.phase_acc + phase_inc

        start_x = self.INIT_X
        start_y = Sfix(0.0, 0, -17)

        x, y, phase = self.cordic.main(start_x, start_y, self.phase_acc)

        self.out = Complex(x, y)
        return self.out
Ejemplo n.º 7
0
    def __init__(self, window_length, window='hanning', coefficient_bits=18):
        self._pyha_simulation_input_callback = NumpyToDataValid(
            dtype=default_complex)
        self.WINDOW_LENGTH = window_length
        self.window_pure = get_window(window, window_length)
        self.WINDOW = [
            Sfix(x,
                 0,
                 -(coefficient_bits - 1),
                 round_style='round',
                 overflow_style='saturate') for x in self.window_pure
        ]

        self.output = DataValid(Complex(0, 0, -17, round_style='round'))
        self.index_counter = 1
        self.coef = self.WINDOW[0]
Ejemplo n.º 8
0
    def __init__(self):
        self._pyha_simulation_input_callback = NumpyToDataValid(dtype=Complex(
            0.0, 0, -11, overflow_style='saturate', round_style='round'))

        # components
        fft_size = 1024 * 8
        avg_freq_axis = 16
        avg_time_axis = 8
        window_type = 'hamming'
        fft_twiddle_bits = 8
        window_bits = 8
        dc_removal_len = 1024
        self.spect = Spectrogram(fft_size, avg_freq_axis, avg_time_axis,
                                 window_type, fft_twiddle_bits, window_bits,
                                 dc_removal_len)
        # TODO: could be unsigned!
        self.output = DataValid(
            Sfix(0.0, upper_bits=32)
        )  # no need to round because result is positive i.e. truncation = rounding
Ejemplo n.º 9
0
 def __init__(self):
     self._pyha_simulation_input_callback = NumpyToDataValid(
         dtype=default_complex)
     self.output = DataValid(Sfix(bits=36))
Ejemplo n.º 10
0
 def __init__(self):
     self.mem = np.random.uniform(-1, 1, 5)
     self.counter = Sfix(0, 4, 0)
Ejemplo n.º 11
0
    def __init__(self, precision=-17):
        self.core = Cordic(14, CordicMode.VECTORING, precision=precision)
        self.y_abs = Sfix(0, 0, -17, overflow_style='saturate')
        self.y_angle = Sfix(0, 0, -17, overflow_style='saturate')

        self.DELAY = self.core.ITERATIONS + 1
Ejemplo n.º 12
0
    def __init__(self):
        self.out_real = Sfix(0, 0, -15, round_style='round')
        self.out_imag = Sfix(0, 0, -15, round_style='round')

        self.DELAY = 1