def test_or_bb(self): src1_data = [1, 2, 2, 3, 0x04, 0x50] src2_data = [8, 2, 2, 1, 0x08, 0x05] src3_data = [8, 2, 1, 1, 0x08, 0x05] expected_result = [9, 2, 3, 3, 0x0C, 0x55] op = blocks.or_bb() self.help_bb((src1_data, src2_data, src3_data), expected_result, op)
def test_or_bb(self): src1_data = (1, 2, 2, 3, 0x04, 0x50) src2_data = (8, 2, 2, 1, 0x08, 0x05) src3_data = (8, 2, 1, 1, 0x08, 0x05) expected_result = (9, 2, 3, 3, 0x0C, 0x55) op = blocks.or_bb() self.help_bb((src1_data, src2_data, src3_data), expected_result, op)
def __init__(self, code_index, code_size=31, DataRate_Kbps=850, Nburst=32, Ncpb=16, MeanPRF_KHz=15600, Nsync=64, deltaL=16, Nsdf=8, bypass_conv_enc=0, isRangingPacket=0, msgq_limit=2): """ Hierarchical block for the IEEE 802.15.4a UWB modulation. Packets to be sent are enqueued by calling send_pkt. The output is the complex modulated signal at baseband. @param fg: flow graph @type fg: flow graph @param msgq_limit: maximum number of messages in message queue @type msgq_limit: int @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples @param bypass_conv_enc: bypass the convolutional encoding (1) or not (0)[default] @type bypass_conv_enc: int """ gr.hier_block2.__init__(self, "ieee804154a_uwb_mod_pkt", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_char)) # Output signature # setting parameters self.code_index = code_index self.code_size = code_size self.DataRate_Kbps = DataRate_Kbps self.Nburst = Nburst self.Ncpb = Ncpb self.MeanPRF_KHz = MeanPRF_KHz self.Nsync = Nsync self.deltaL = deltaL self.Nsdf = Nsdf self.bypass_conv_enc = bypass_conv_enc self.isRangingPacket = bypass_conv_enc ############ THE SYNCH PATH # synchronization header self.synch_seq = ieee802_15_4a.msg_formatter.set_synch(self.code_size, self.code_index, self.Nsync, self.deltaL, self.Nsdf) self.synch_msg = gr.message_from_string(self.synch_seq) self._synch_input = blocks.message_source(gr.sizeof_char, msgq_limit) ############ THE MAIN PATH # accepts messages from the outside world self._pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit) # convolutional encoding self._convolutional_encoder = ieee802_15_4a.conv_encoder (self.bypass_conv_enc); # BPSK BPM modulator self._modulator = ieee802_15_4a.bpsk_bpm_modulator(self.code_index, self.Nburst, self.Ncpb) # connect the blocks self.connect(self._pkt_input, self._convolutional_encoder, self._modulator) # THE CONNECTION BETWEEN THE PATHS self.delay = blocks.delay (gr.sizeof_char, len(self.synch_seq)) self.sum2 = blocks.or_bb(1); self.connect (self._synch_input, (self.sum2, 0)) self.connect (self._modulator, self.delay) self.connect (self.delay, (self.sum2, 1)) self.connect (self.sum2, self)
def test_or_bb (self): src1_data = (1, 2, 2, 3, 0x04, 0x50) src2_data = (8, 2, 2, 1 , 0x08, 0x05) src3_data = (8, 2, 1, 1 , 0x08, 0x05) expected_result = (9, 2, 3, 3, 0x0C, 0x55) op = blocks.or_bb () self.help_bb ((src1_data, src2_data, src3_data), expected_result, op)
def __init__(self, EbN0, viterbi=False): gr.top_block.__init__(self) self.sps = 5 alpha = 0.35 const = digital.constellation_bpsk().base() modulator = digital.generic_mod( constellation=const, differential=False, samples_per_symbol=self.sps, pre_diff_code=True, excess_bw=alpha, verbose=False, log=False, ) channel = channels.channel_model( noise_voltage=self.EbN0_to_noise_voltage(EbN0, viterbi), frequency_offset=0, epsilon=1.0, taps=(0, 0, (1+1j)/numpy.sqrt(2), ), noise_seed=RAND_SEED, block_tags=False ) self.sink = blocks.vector_sink_f() biterrors = BitErrors() dut = lilacsat1_ber_viterbi() if viterbi else lilacsat1_ber_bpsk() pack = blocks.pack_k_bits_bb(8) descrambler = digital.descrambler_bb(0x21, 0x00, 16) self.connect(blocks.vector_source_b([1], repeat=True), blocks.head(gr.sizeof_char, int(N_BITS)), digital.scrambler_bb(0x21, 0x00, 16), digital.diff_encoder_bb(2), pack) self.connect(modulator, channel, blocks.multiply_const_cc(0.1), # we set some amplitude to test the agc # signal amplitude 1 seems very important dut, digital.diff_decoder_bb(2), descrambler) self.connect(biterrors, self.sink) if viterbi: deinterleave_viterbi = blocks.deinterleave(gr.sizeof_char) interleave_viterbi = blocks.interleave(gr.sizeof_char) self.connect(pack, fec.encode_ccsds_27_bb(), deinterleave_viterbi) self.connect((deinterleave_viterbi, 0), (interleave_viterbi, 1)) self.connect((deinterleave_viterbi, 1), blocks.not_bb(), blocks.and_const_bb(1), (interleave_viterbi, 0)) self.connect(interleave_viterbi, blocks.pack_k_bits_bb(8), modulator) descrambler2 = digital.descrambler_bb(0x21, 0x00, 16) self.connect((dut, 1), digital.diff_decoder_bb(2), descrambler2) or2 = blocks.or_bb() self.connect(descrambler, or2) self.connect(descrambler2, (or2, 1)) self.connect(or2, biterrors) #self.sinkviterbi1 = blocks.vector_sink_b() #self.sinkviterbi2 = blocks.vector_sink_b() #self.connect(descrambler, self.sinkviterbi1) #self.connect(descrambler2, self.sinkviterbi2) else: self.connect(pack, modulator) self.connect(descrambler, biterrors)
def __init__(self): gr.top_block.__init__(self, "And or xor") Qt.QWidget.__init__(self) self.setWindowTitle("And or xor") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "logicalsignal") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0.set_y_label('XOR', "") self.qtgui_time_sink_x_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('OR', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('AND', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ 'blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue' ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_xor_xx_0_0 = blocks.xor_bb() self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_uchar_to_float_0_0_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_or_xx_0 = blocks.or_bb() self.blocks_null_source_0 = blocks.null_source(gr.sizeof_char * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_and_xx_0 = blocks.and_bb() self.analog_sig_source_x_1 = analog.sig_source_b( samp_rate, analog.GR_SQR_WAVE, 4000, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_b( samp_rate, analog.GR_SQR_WAVE, 1000, 1, 0, 0) self.analog_const_source_x_0 = analog.sig_source_b( 0, analog.GR_CONST_WAVE, 0, 0, 1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_xor_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_and_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_or_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_xor_xx_0_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_xor_xx_0, 0)) self.connect((self.blocks_and_xx_0, 0), (self.blocks_uchar_to_float_0_0_0_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_or_xx_0, 0), (self.blocks_uchar_to_float_0_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 1)) self.connect((self.blocks_uchar_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_uchar_to_float_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_and_xx_0, 1)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_or_xx_0, 1)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_xor_xx_0_0, 1)) self.connect((self.blocks_xor_xx_0_0, 0), (self.blocks_uchar_to_float_0_0, 0))