示例#1
0
def test_proc_statement_no_input():
    test_input = "proc clock() \
                    bus outbus { \
                        val: u4 range 0 to 2; \
                    }; \
                    { outbus.val = 1; }"

    test_output = "channel clock_outbus_val : {0 .. 15}\nclock_outbus_val_monitor(c) = c ? x -> if 0 <= x and x <= 2 then SKIP else STOP\n"
    output = taps(test_input)
    assert output == test_output
示例#2
0
def test_proc_statement_with_input():
    test_input = "proc clock( in inbus) \
                    bus outbus { \
                        val: u4 range 0 to 2; \
                    }; \
                    { result = inbus.val + 1; \
                    outbus.val = result; }"

    test_output = "channel clock_outbus_val : {0 .. 15}\nClock(inbus) =\nlet\nresult = inbus + 1\nwithin\nclock_outbus_val ! result ->\nSKIP\nclock_outbus_val_monitor(c) = c ? x -> if 0 <= x and x <= 2 then SKIP else STOP\n"
    output = taps(test_input)
    assert output == test_output
示例#3
0
def test_proc_output_bus_several_channels():
    test_input = "proc clock() \
                    bus outbus { \
                        val: u4 range 0 to 2; \
                        val2: u4 range 0 to 2; \
                    }; \
                    { }"

    test_output = "channel clock_outbus_val2 : {0 .. 15}\nchannel clock_outbus_val : {0 .. 15}\nclock_outbus_val_monitor(c) = c ? x -> if 0 <= x and x <= 2 then SKIP else STOP\nclock_outbus_val2_monitor(c) = c ? x -> if 0 <= x and x <= 2 then SKIP else STOP\n"
    output = taps(test_input)
    assert output == test_output
示例#4
0
    def fft_channelizer( self, fft_len, channel_bins):
        #do a fwd fft
        self.fft_channelizer_s2v = blocks.stream_to_vector( gr.sizeof_gr_complex*1, fft_len)
        self.fft_channelizer_fft_fwd = fft.fft_vcc( fft_len, True, (window.blackmanharris(1024)), True, 1)
        self.fft_channelizer_v2s = blocks.vector_to_stream( gr.sizeof_gr_complex*1, fft_len)
        self.connect(   self.fft_channelizer_s2v,
                        self.fft_channelizer_fft_fwd,
                        self.fft_channelizer_v2s)

        #per channel
        self.fft_channelizer_skiphead = []
        self.fft_channelizer_keep_m_in_n = []
        self.fft_channelizer_stream2vector = []
        self.fft_channelizer_multiply_const = []
        self.fft_channelizer_fft_rev = []
        self.fft_channelizer_vector2stream = []
        for from_bin, to_bin in channel_bins:
            #output samp rate: samp_rate / (fft_len/keep)
            keep = to_bin - from_bin
            fft_channelizer_taps = taps.taps(keep)

            self.fft_channelizer_skiphead.append( blocks.skiphead(gr.sizeof_gr_complex*1, from_bin))
            self.fft_channelizer_keep_m_in_n.append( blocks.keep_m_in_n(gr.sizeof_gr_complex, keep, fft_len, 0))
            self.fft_channelizer_stream2vector.append( blocks.stream_to_vector(gr.sizeof_gr_complex*1, keep))
            self.fft_channelizer_multiply_const.append( blocks.multiply_const_vcc(fft_channelizer_taps))
            self.fft_channelizer_fft_rev.append( fft.fft_vcc( keep, False, (window.blackmanharris(1024)), True, 1))
            self.fft_channelizer_vector2stream.append( blocks.vector_to_stream( gr.sizeof_gr_complex*1, keep))

            self.connect(   self.fft_channelizer_v2s,
                            self.fft_channelizer_skiphead[-1],
                            self.fft_channelizer_keep_m_in_n[-1],
                            self.fft_channelizer_stream2vector[-1],
                            self.fft_channelizer_multiply_const[-1],
                            self.fft_channelizer_fft_rev[-1],
                            self.fft_channelizer_vector2stream[-1])


        return self.fft_channelizer_s2v, self.fft_channelizer_vector2stream
示例#5
0
def test_proc_variable_in_process():
    test_input = "proc clock() var x : u4; { }"
    test_output = ""
    # Will not generate a channel because it does not have an output bus
    output = taps(test_input)
    assert output == test_output
示例#6
0
def test_proc_name_without_input():
    test_input = "proc clock() { }"
    test_output = ""
    # Will not generate a channel because it does not have an output bus
    output = taps(test_input)
    assert output == test_output
示例#7
0
def test_proc_name_with_input():
    test_input = "proc clock(in x) { }"
    test_output = "Clock(x) =\nlet\nwithin\nSKIP\n"
    output = taps(test_input)
    assert output == test_output