Beispiel #1
0
class biasBufferGroup(HasTraits):
    name = str
    coarse = Enum('24u', '3.2u', '0.4u', '50n', '6.5n', '820p', '105p', '15p')
    fine = Range(0, 255)
    current = Str
    default = traitsButton()
    view = View(
        Group(Item(name='name',
                   style='readonly',
                   show_label=False,
                   emphasized=True),
              Spring(springy=True),
              Item(name='coarse', show_label=False),
              Item(name='fine', show_label=False),
              Item(name='current'),
              Item(name='default', label='Default', show_label=False),
              orientation='horizontal',
              layout='normal',
              style='simple'))

    def __init__(self, n):
        self.name = n

    def sentBias(self):
        configurator.set_bias(self.name,
                              self.coarse,
                              self.fine,
                              biasLowHigh='NONE',
                              biasType='NONE',
                              biasCascode='NONE',
                              biasEnable='NONE')

    def exportToString(self):
        return self.name + ',' + self.coarse + ',' + str(
            self.fine) + ',' + 'NONE,NONE,NONE,NONE,'

    def updateCurrent(self):
        unit = self.coarse[-1]
        maxCurrent = float(self.coarse.split(unit)[0])
        current = self.fine * maxCurrent / 256
        self.current = str(round(current, 4)) + unit
        self.sentBias()

    def _fine_changed(self):
        self.updateCurrent()

    def _coarse_changed(self):
        self.updateCurrent()

    def _default_fired(self):
        self.setDefaults('')

    def setDefaults(self, file):
        if file == '':
            defaults = configurator.read_default_bias(self.name)
        else:
            defaults = configurator.read_default_bias(self.name, def_file=file)
        self.coarse = defaults[1]
        self.fine = int(defaults[2])
        self.updateCurrent()
Beispiel #2
0
class PathConfiguratorGroup(HasTraits):

    configurator = MN256R1Configurator

    # Path
    enableAerPCIEToMonitor = Bool
    inputSelect = Bool
    outputSelect = Bool
    enablePipeline = Bool
    defaultConf = traitsButton()

    view = View(
        Group(Group(Group(Item(name='enablePipeline', label='Enable pipeline'),
                          Item(name='outputSelect',
                               label='Enable auto output'),
                          Item(name='inputSelect', label='Enable auto input'),
                          Item(name='enableAerPCIEToMonitor',
                               label='Enable PCIe to FX2'),
                          Spring(springy=True),
                          Item(name='defaultConf',
                               label='Default',
                               show_label=False),
                          orientation='horizontal'),
                    show_border=True,
                    label='Path'),
              orientation='vertical'))

    def __init__(self, conf):
        self.configurator = conf

    def _defaultConf_fired(self):
        self.enableAerPCIEToMonitor = False
        self.inputSelect = False
        self.outputSelect = False
        self.enablePipeline = False

    def _enableAerPCIEToMonitor_changed(self):
        if self.enableAerPCIEToMonitor == True:
            self.configurator.set_conf(1)
        else:
            self.configurator.set_conf(0)

    def _inputSelect_changed(self):
        if self.inputSelect == True:
            self.configurator.set_conf(3)
        else:
            self.configurator.set_conf(2)

    def _outputSelect_changed(self):
        if self.outputSelect == True:
            self.configurator.set_conf(5)
        else:
            self.configurator.set_conf(4)

    def _enablePipeline_changed(self):
        if self.enablePipeline == True:
            self.configurator.set_conf(7)
        else:
            self.configurator.set_conf(6)
Beispiel #3
0
class biasSpecialGroup(HasTraits):
    name = str
    value = Range(0, 63)
    default = traitsButton()
    view = View(
        Group(Item(name='name',
                   style='readonly',
                   show_label=False,
                   emphasized=True),
              Spring(springy=True),
              Item(name='value', show_label=False),
              Item(name='default', label='Default', show_label=False),
              orientation='horizontal',
              layout='normal',
              style='simple'))

    def __init__(self, n):
        self.name = n

    def sentBias(self):
        configurator.set_bias(self.name,
                              'SPECIAL',
                              self.value,
                              biasLowHigh='NONE',
                              biasType='NONE',
                              biasCascode='NONE',
                              biasEnable='NONE')

    def exportToString(self):
        return self.name + ',SPECIAL,' + str(
            self.value) + ',' + 'NONE,NONE,NONE,NONE,'

    def _value_changed(self):
        self.sentBias()

    def _default_fired(self):
        self.setDefaults('')

    def setDefaults(self, file):
        if file == '':
            defaults = configurator.read_default_bias(self.name)
        else:
            defaults = configurator.read_default_bias(self.name, def_file=file)
        self.value = int(defaults[2])
Beispiel #4
0
class AerConfiguratorGroup(HasTraits):

    dpiNames = {'NPDPIE': 0, 'NPDPII': 1, 'PDPIE': 2, 'VDPIE': 3, 'VDPII': 4}

    plasticLatches = {'Recurrent': 0, 'Broadcast': 1}

    non_plasticLatches = {
        'Recurrent': 0,
        'Exc_Inh': 1,
        'W0': 2,
        'W1': 3,
        'Broadcast': 4
    }

    configurator = MN256R1Configurator
    mon_neuron = Range(0, 255)
    mon_dpi_neuron = Range(0, 255)
    set_monitor = traitsButton()
    set_dpi_monitor = traitsButton()
    dpi = Enum('NPDPIE', 'NPDPII', 'PDPIE', 'VDPIE', 'VDPII')
    reset_mon = traitsButton()
    #neuron
    set_neuron = Range(0, 255)
    set_neuron_latch = traitsButton()
    reset_neuron_latch = traitsButton()
    enable_reset_buffer = traitsButton()
    disable_reset_buffer = traitsButton()
    #plastic synapses
    set_plastic_latch = traitsButton()
    reset_plastic_latch = traitsButton()
    set_plastic_weight_hi = traitsButton()
    set_plastic_weight_lo = traitsButton()
    plastic_latch = Enum('Recurrent', 'Broadcast')
    plastic_row = Range(0, 255)
    plastic_col = Range(0, 255)
    #non_plastic synapses
    set_non_plastic_latch = traitsButton()
    reset_non_plastic_latch = traitsButton()
    non_plastic_latch = Enum('Recurrent', 'Exc_Inh', 'W0', 'W1', 'Broadcast')
    non_plastic_row = Range(0, 255)
    non_plastic_col = Range(0, 255)

    #Multiplexer
    mux_value = Range(0, 8)
    set_mux = Range(0, 8)

    set_mux = traitsButton()

    #Send Test Spikes
    row = Range(0, 255)
    col = Range(0, 519)
    col_bc = Range(0, 511)
    set_plastic_monitor = traitsButton()
    spike_frequency = Range(1, 500)
    spike_count = Range(0, 10000)
    start_test_sequencer = traitsButton()
    spike_frequency_bc = Range(1, 500)
    spike_count_bc = Range(0, 10000)
    start_test_sequencer_bc = traitsButton()

    view = View(
        Group(
            Group(Group(Spring(springy=True),
                        Item(name='mon_neuron',
                             label='Membrane potential of neuron'),
                        Item(name='set_monitor',
                             label='Set Monitor',
                             show_label=False),
                        orientation='horizontal'),
                  Group(Spring(springy=True),
                        Item(name='dpi', label='DPI current of'),
                        Item(name='mon_dpi_neuron', label='of neuron'),
                        Item(name='set_dpi_monitor',
                             label='Set Monitor',
                             show_label=False),
                        orientation='horizontal'),
                  Group(Spring(springy=True),
                        Item(name='reset_mon',
                             label='Resset All Monitors',
                             show_label=False),
                        orientation='horizontal'),
                  show_border=True,
                  label='Monitor'),
            ###
            Group(Group(Item(name='set_neuron', label='Number of neuron'),
                        Spring(springy=True),
                        Item(name='set_neuron_latch',
                             label='Set Bias1',
                             show_label=False),
                        Item(name='reset_neuron_latch',
                             label='ReSet All to Bias2',
                             show_label=False),
                        orientation='horizontal'),
                  Group(Spring(springy=True),
                        Item(name='enable_reset_buffer',
                             label='Enable Reset Buffer of Neuron',
                             show_label=False),
                        Item(name='disable_reset_buffer',
                             label='Disable Reset Buffer of Neuron',
                             show_label=False),
                        orientation='horizontal'),
                  show_border=True,
                  label='Neuron'),
            ###
            Group(Group(Item(name='plastic_col', label='Column'),
                        Item(name='plastic_row', label='Row'),
                        Spring(springy=True),
                        Item(name='set_plastic_monitor',
                             label='Set Monitor',
                             show_label=False),
                        orientation='horizontal'),
                  Group(Spring(springy=True),
                        Item(name='plastic_latch', label='Configure latches'),
                        Item(name='set_plastic_latch',
                             label='Set',
                             show_label=False),
                        Item(name='reset_plastic_latch',
                             label='Reset',
                             show_label=False),
                        orientation='horizontal'),
                  Group(Spring(springy=True),
                        Item(name='set_plastic_weight_hi',
                             label='Set Weight High',
                             show_label=False),
                        Item(name='set_plastic_weight_lo',
                             label='Set Weight Low',
                             show_label=False),
                        orientation='horizontal'),
                  show_border=True,
                  label='Plastic Synapses'),
            ###
            Group(Group(Item(name='non_plastic_col', label='Column'),
                        Item(name='non_plastic_row', label='Row'),
                        Spring(springy=True),
                        Item(name='non_plastic_latch',
                             label='Configure latches'),
                        Item(name='set_non_plastic_latch',
                             label='Set',
                             show_label=False),
                        Item(name='reset_non_plastic_latch',
                             label='Reset',
                             show_label=False),
                        orientation='horizontal'),
                  show_border=True,
                  label='Non Plastic Synapses'),
            ### Multiplexer
            Group(Group(Spring(springy=True),
                        Item(name='mux_value', label='Mux'),
                        Item(name='set_mux', label='Set Mux',
                             show_label=False),
                        orientation='horizontal'),
                  show_border=True,
                  label='Multiplexer'),
            ###
            Group(Group(Item(name='col', label='Column'),
                        Item(name='row', label='Row'),
                        Spring(springy=True),
                        Item(name='spike_count', label='Number of spikes'),
                        Item(name='spike_frequency', label='Frequency (Hz)'),
                        Item(name='start_test_sequencer',
                             label='Send',
                             show_label=False),
                        orientation='horizontal'),
                  Group(Item(name='col_bc', label='Broadcast Column'),
                        Spring(springy=True),
                        Item(name='spike_count_bc', label='Number of spikes'),
                        Item(name='spike_frequency_bc',
                             label='Frequency (Hz)'),
                        Item(name='start_test_sequencer_bc',
                             label='Send',
                             show_label=False),
                        orientation='horizontal'),
                  show_border=True,
                  label='Send Test Spikes'),
            orientation='vertical'))

    def __init__(self, conf):
        self.configurator = conf

    def _start_test_sequencer_fired(self):
        for i in range(0, self.spike_count):
            self.configurator.set_aer(self.col * 256 + self.row)
            time.sleep(1 / float(self.spike_frequency))

    def _start_test_sequencer_bc_fired(self):
        for i in range(0, self.spike_count_bc):
            self.configurator.set_aer(self.col_bc + 133120)
            time.sleep(1 / float(self.spike_frequency))

    def _set_plastic_weight_hi_fired(self):
        self.configurator.set_aer(1 * 256 * 256 + self.plastic_col * 256 +
                                  self.plastic_row + 1051136)

    def _set_plastic_weight_lo_fired(self):
        self.configurator.set_aer(self.plastic_col * 256 + self.plastic_row +
                                  1051136)

    def _set_neuron_latch_fired(self):
        self.configurator.set_aer(self.set_neuron + 1249026)
        self.configurator.set_aer(1249283)  #PLEASE FIX!
        self.configurator.set_aer(self.set_neuron + 1249026)

    def _reset_neuron_latch_fired(self):
        self.configurator.set_aer(1249282)
        self.configurator.set_aer(1249283)

    def _enable_reset_buffer_fired(self):
        self.configurator.set_aer(1249540)

    def _disable_reset_buffer_fired(self):
        self.configurator.set_aer(1249541)
        self.configurator.set_aer(self.mon_neuron + 1249284)  #PLEASE FIX!
        self.configurator.set_aer(1249541)
        self.configurator.set_aer(self.mon_neuron + 1249284)  #PLEASE FIX!

    def _set_plastic_latch_fired(self):
        self.configurator.set_aer(self.plasticLatches[self.plastic_latch] * 2 *
                                  256 * 256 + 1 * 256 * 256 +
                                  self.plastic_col * 256 + self.plastic_row +
                                  788992)

    def _reset_plastic_latch_fired(self):
        self.configurator.set_aer(self.plasticLatches[self.plastic_latch] * 2 *
                                  256 * 256 + 0 * 256 * 256 +
                                  self.plastic_col * 256 + self.plastic_row +
                                  788992)

    def _set_non_plastic_latch_fired(self):
        self.configurator.set_aer(
            self.non_plasticLatches[self.non_plastic_latch] * 2 * 256 * 256 +
            1 * 256 * 256 + self.non_plastic_col * 256 + self.non_plastic_row +
            133632)

    def _reset_non_plastic_latch_fired(self):
        self.configurator.set_aer(
            self.non_plasticLatches[self.non_plastic_latch] * 2 * 256 * 256 +
            0 * 256 * 256 + self.non_plastic_col * 256 + self.non_plastic_row +
            133632)

    def _set_plastic_monitor_fired(self):
        self.setMonitorNeuron()
        self.configurator.set_aer(self.plastic_col * 256 + self.plastic_row +
                                  1182208)

    def _reset_mon_fired(self):
        self.configurator.set_aer(1249024)

    def setMultiplexer(self):
        self.configurator.set_aer(self.mux_value + 1249542)

    def _set_mux_fired(self):
        self.setMultiplexer()

    def _mux_value_changed(self):
        self.setMultiplexer()

    def setMonitorNeuron(self):
        self.configurator.set_aer(1249024)
        self.configurator.set_aer(1249025)
        self.configurator.set_aer(self.mon_neuron + 1249284)  #PLEASE FIX!
        self.configurator.set_aer(1249025)
        self.configurator.set_aer(self.mon_neuron + 1249284)

    def _set_monitor_fired(self):
        self.setMonitorNeuron()

    def _mon_neuron_changed(self):
        self.setMonitorNeuron()

    def setMonitorDPI(self):
        self.configurator.set_aer(self.dpiNames[self.dpi] * 256 +
                                  self.mon_dpi_neuron + 1247744)

    def _set_dpi_monitor_fired(self):
        self.setMonitorDPI()

    def _mon_dpi_neuron_changed(self):
        self.setMonitorDPI()

    def _dpi_changed(self):
        self.setMonitorDPI()
Beispiel #5
0
class biasTraits(HasTraits):

    #biases
    bias0 = Instance(biasGroup(str))
    bias1 = Instance(biasGroup(str))
    bias2 = Instance(biasGroup(str))
    bias3 = Instance(biasGroup(str))
    bias4 = Instance(biasGroup(str))
    bias5 = Instance(biasGroup(str))
    bias6 = Instance(biasGroup(str))
    bias7 = Instance(biasGroup(str))
    bias8 = Instance(biasGroup(str))
    bias9 = Instance(biasGroup(str))
    bias10 = Instance(biasGroup(str))
    bias11 = Instance(biasGroup(str))
    bias12 = Instance(biasGroup(str))
    bias13 = Instance(biasGroup(str))
    bias14 = Instance(biasGroup(str))
    bias15 = Instance(biasGroup(str))
    bias16 = Instance(biasGroup(str))
    bias17 = Instance(biasGroup(str))
    bias18 = Instance(biasGroup(str))
    bias19 = Instance(biasGroup(str))
    bias20 = Instance(biasGroup(str))
    bias21 = Instance(biasGroup(str))
    bias22 = Instance(biasGroup(str))
    bias23 = Instance(biasGroup(str))
    bias24 = Instance(biasGroup(str))
    bias25 = Instance(biasGroup(str))
    bias26 = Instance(biasGroup(str))
    bias27 = Instance(biasGroup(str))
    bias28 = Instance(biasGroup(str))
    bias29 = Instance(biasGroup(str))
    bias30 = Instance(biasGroup(str))
    bias31 = Instance(biasGroup(str))
    bias32 = Instance(biasGroup(str))
    bias33 = Instance(biasGroup(str))
    bias34 = Instance(biasGroup(str))
    bias35 = Instance(biasGroup(str))
    bias36 = Instance(biasGroup(str))
    bias37 = Instance(biasGroup(str))
    bias38 = Instance(biasGroup(str))
    bias39 = Instance(biasGroup(str))
    bias40 = Instance(biasGroup(str))
    bias41 = Instance(biasGroup(str))
    bias42 = Instance(biasGroup(str))
    bias43 = Instance(biasGroup(str))
    bias44 = Instance(biasGroup(str))
    bias45 = Instance(biasGroup(str))
    bias46 = Instance(biasGroup(str))
    bias47 = Instance(biasGroup(str))
    bias48 = Instance(biasGroup(str))
    bias49 = Instance(biasGroup(str))
    bias50 = Instance(biasGroup(str))
    bias51 = Instance(biasGroup(str))
    bias52 = Instance(biasGroup(str))
    bias53 = Instance(biasGroup(str))
    bias54 = Instance(biasGroup(str))
    bias55 = Instance(biasGroup(str))
    bias56 = Instance(biasGroup(str))
    bias57 = Instance(biasGroup(str))
    bias58 = Instance(biasGroup(str))
    bias59 = Instance(biasGroup(str))
    bias60 = Instance(biasGroup(str))
    bias61 = Instance(biasGroup(str))
    bias62 = Instance(biasGroup(str))
    bias63 = Instance(biasGroup(str))
    bias64 = Instance(biasBufferGroup(str))
    bias65 = Instance(biasSpecialGroup(str))
    bias66 = Instance(biasSpecialGroup(str))

    #aer configurator
    aerConf = Instance(AerConfiguratorGroup)

    #path configurator
    pathConf = Instance(PathConfiguratorGroup)

    #pci configurator
    FPGA_ID = Range(0, 3, 1, mode='spinner')
    FPGA_CHNL = Range(1, 1, 1, mode='spinner')
    pcieconf = Instance(MN256R1Configurator)
    close_pcie = traitsButton()
    status_pcie = Str('undefined')
    pcie_flag = False

    #CMOL
    cmol_enable = traitsButton()
    cmol_view_enabled = False

    #tcp socket
    tcp_flag = False
    tcp_flag_not = True
    tcp_ip = Str('127.0.0.1')
    tcp_port = Range(50000, 100000, 50005)
    open_tcp = traitsButton()
    close_tcp = traitsButton()

    #bias tuning
    bias_tune_name = Str('BIAS_NAME_TYPE')
    bias_tune_fine_start = Range(0, 255)
    bias_tune_fine_end = Range(0, 255)
    tune_repetitions = Range(1, 1000)
    tune_pause_ms = Range(0, 10000)
    tune_start = traitsButton()

    ##usb flags
    usb_flag = False
    usb_flag_not = True

    #control buttons
    file_to_save = Str
    file_to_load = Str
    save_all_biases = traitsButton()
    load_all_biases = traitsButton()
    load_all_default_biases = traitsButton()
    open_device = traitsButton()
    interface = Enum('PCIe', 'USB')

    cmol_view = View(
        Group(
            Group(Item('bias62',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_DC_P <->',
                       emphasized=True),
                  Item('bias12',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_THR_N <->',
                       emphasized=True),
                  Item('bias6',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_AHTAU_N <->',
                       emphasized=True),
                  Item('bias5',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_AHW_P <->',
                       emphasized=True),
                  Item('bias8',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_TAU_N <->',
                       emphasized=True),
                  Item('bias2',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_AHTHR_N <->',
                       emphasized=True),
                  Item('bias4',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_RFR_N <->',
                       emphasized=True),
                  Item('bias11',
                       style='custom',
                       show_label=True,
                       label='CMOL_IF_CASC_N <->',
                       emphasized=True),
                  label='CMOL_SOMA',
                  show_border=True),
            Group(Item('bias19',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_THUP_P <->',
                       emphasized=True),
                  Item('bias17',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_WTA_P <->',
                       emphasized=True),
                  Item('bias15',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_BUF_N <->',
                       emphasized=True),
                  Item('bias20',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_CATAU_P <->',
                       emphasized=True),
                  Item('bias21',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_CAW_N <->',
                       emphasized=True),
                  Item('bias14',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_MEMTHR_N <->',
                       emphasized=True),
                  Item('bias18',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_CATHR_P <->',
                       emphasized=True),
                  Item('bias13',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_THDN_P <->',
                       emphasized=True),
                  Item('bias16',
                       style='custom',
                       show_label=True,
                       label='CMOL_SL_THMIN_N <->',
                       emphasized=True),
                  label='CMOL_SOMA_LEARN',
                  show_border=True),
            Group(Item('bias46',
                       style='custom',
                       show_label=True,
                       label='CMOL_WEIGHT_N <->',
                       emphasized=True),
                  Item('bias24',
                       style='custom',
                       show_label=True,
                       label='CMOL_BUF_BIAS <->',
                       emphasized=True),
                  Item('bias41',
                       style='custom',
                       show_label=True,
                       label='CMOL_PWLKPOST_P <->',
                       emphasized=True),
                  Item('bias48',
                       style='custom',
                       show_label=True,
                       label='CMOL_PWLKPRE_P <->',
                       emphasized=True),
                  Item('bias44',
                       style='custom',
                       show_label=True,
                       label='CMOL_DPI_TAU_P <->',
                       emphasized=True),
                  Item('bias45',
                       style='custom',
                       show_label=True,
                       label='CMOL_DPI_THR_P <->',
                       emphasized=True),
                  Item('bias43',
                       style='custom',
                       show_label=True,
                       label='CMOL_PUPREQ_P <->',
                       emphasized=True),
                  Item('bias63',
                       style='custom',
                       show_label=True,
                       label='CMOL_RSTXARB <->',
                       emphasized=True),
                  label='CMOL_SPECIAL',
                  show_border=True)))

    traits_view = View(
        Group(Group(Item('bias0', style='custom', show_label=False),
                    Item('bias1', style='custom', show_label=False),
                    Item('bias2', style='custom', show_label=False),
                    Item('bias3', style='custom', show_label=False),
                    Item('bias4', style='custom', show_label=False),
                    Item('bias5', style='custom', show_label=False),
                    Item('bias6', style='custom', show_label=False),
                    Item('bias7', style='custom', show_label=False),
                    Item('bias8', style='custom', show_label=False),
                    Item('bias9', style='custom', show_label=False),
                    Item('bias10', style='custom', show_label=False),
                    Item('bias11', style='custom', show_label=False),
                    Item('bias12', style='custom', show_label=False),
                    label='SOMA',
                    show_border=True),
              Group(Item('bias13', style='custom', show_label=False),
                    Item('bias14', style='custom', show_label=False),
                    Item('bias15', style='custom', show_label=False),
                    Item('bias16', style='custom', show_label=False),
                    Item('bias17', style='custom', show_label=False),
                    Item('bias18', style='custom', show_label=False),
                    Item('bias19', style='custom', show_label=False),
                    Item('bias20', style='custom', show_label=False),
                    Item('bias21', style='custom', show_label=False),
                    label='SOMA_LEARN',
                    show_border=True),
              Group(Item('bias22', style='custom', show_label=False),
                    Item('bias23', style='custom', show_label=False),
                    Item('bias24', style='custom', show_label=False),
                    Item('bias25', style='custom', show_label=False),
                    Item('bias26', style='custom', show_label=False),
                    Item('bias27', style='custom', show_label=False),
                    label='HOMEOSTATIC',
                    show_border=True),
              label='Soma'),
        Group(Group(Item('bias28', style='custom', show_label=False),
                    Item('bias29', style='custom', show_label=False),
                    Item('bias30', style='custom', show_label=False),
                    Item('bias31', style='custom', show_label=False),
                    Item('bias32', style='custom', show_label=False),
                    Item('bias33', style='custom', show_label=False),
                    label='VIRTUAL',
                    show_border=True),
              Group(Item('bias34', style='custom', show_label=False),
                    Item('bias35', style='custom', show_label=False),
                    Item('bias36', style='custom', show_label=False),
                    Item('bias37', style='custom', show_label=False),
                    Item('bias38', style='custom', show_label=False),
                    Item('bias39', style='custom', show_label=False),
                    Item('bias40', style='custom', show_label=False),
                    Item('bias41', style='custom', show_label=False),
                    Item('bias42', style='custom', show_label=False),
                    Item('bias43', style='custom', show_label=False),
                    Item('bias44', style='custom', show_label=False),
                    Item('bias45', style='custom', show_label=False),
                    label='PLASTIC',
                    show_border=True),
              Group(Item('bias46', style='custom', show_label=False),
                    Item('bias47', style='custom', show_label=False),
                    Item('bias48', style='custom', show_label=False),
                    Item('bias49', style='custom', show_label=False),
                    Item('bias50', style='custom', show_label=False),
                    Item('bias51', style='custom', show_label=False),
                    Item('bias52', style='custom', show_label=False),
                    Item('bias53', style='custom', show_label=False),
                    Item('bias54', style='custom', show_label=False),
                    Item('bias55', style='custom', show_label=False),
                    Item('bias56', style='custom', show_label=False),
                    Item('bias57', style='custom', show_label=False),
                    label='NON_PLASTIC',
                    show_border=True),
              label='Synapses'),
        Group(Group(Item('bias58', style='custom', show_label=False),
                    Item('bias59', style='custom', show_label=False),
                    Item('bias60', style='custom', show_label=False),
                    Item('bias61', style='custom', show_label=False),
                    Item('bias62', style='custom', show_label=False),
                    Item('bias63', style='custom', show_label=False),
                    label='ADDITIONAL',
                    show_border=True),
              Group(Item('bias64', style='custom', show_label=False),
                    Item('bias65', style='custom', show_label=False),
                    Item('bias66', style='custom', show_label=False),
                    label='SPECIAL',
                    show_border=True),
              label='Special'),
        Group(Item(name='file_to_load'),
              Item('load_all_biases', label='Load File', show_label=False),
              Item('load_all_default_biases',
                   label='Load Default',
                   show_label=False),
              label='Load'),
        Group(Item(name='file_to_save'),
              Item('save_all_biases', label='Save File', show_label=False),
              label='Save'),
        Group(Item('aerConf', style='custom', show_label=False),
              label='Chip Configurator'),
        Group(Item('pathConf', style='custom', show_label=False),
              label='Path Configurator'),
        Group(Group(Spring(springy=True),
                    Item(name='interface', label='Please choose an interface'),
                    Item('open_device', label='Open Device', show_label=False),
                    label='Interface',
                    show_border=True,
                    orientation='horizontal'),
              Group(Item(name='FPGA_ID',
                         label='Device ID',
                         enabled_when='pcie_flag_not'),
                    Item(name='FPGA_CHNL',
                         label='Channel',
                         enabled_when='pcie_flag_not'),
                    Spring(springy=True),
                    Item(name='status_pcie',
                         label='Status',
                         style='readonly',
                         emphasized=True),
                    Item(name='close_pcie',
                         label='Close',
                         show_label=False,
                         enabled_when='pcie_flag'),
                    label='PCIe',
                    show_border=True,
                    orientation='horizontal'),
              Group(Item(name='tcp_ip',
                         label='IP Address',
                         enabled_when='tcp_flag_not'),
                    Item(name='tcp_port',
                         label='Port',
                         enabled_when='tcp_flag_not'),
                    Spring(springy=True),
                    Item('open_tcp',
                         label='Connect',
                         show_label=False,
                         enabled_when='tcp_flag_not'),
                    Item('close_tcp',
                         label='Close',
                         show_label=False,
                         enabled_when='tcp_flag'),
                    label='TCP/IP',
                    show_border=True,
                    orientation='horizontal'),
              Group(Item(name='bias_tune_name',
                         style='readonly',
                         show_label=False,
                         emphasized=True),
                    Spring(springy=True),
                    Item(name='bias_tune_fine_start',
                         label='Fine current from'),
                    Item(name='bias_tune_fine_end', label='to'),
                    Spring(springy=True),
                    Item(name='tune_repetitions', label='Repetitions'),
                    Item(name='tune_pause_ms', label='Pause (ms)'),
                    Item(name='tune_start', label='Start', show_label=False),
                    label='Bias Tuning',
                    show_border=True,
                    orientation='horizontal'),
              Group(Spring(springy=True),
                    Item(name='cmol_enable',
                         label='Open CMOL biases control dialog',
                         show_label=False),
                    orientation='horizontal',
                    show_border=True,
                    label='CMOL'),
              label='Setup'))

    def _cmol_enable_fired(self):
        if (not (self.cmol_view_enabled)):
            self.configure_traits(view='cmol_view')
            self.cmol_view_enabled = True

    def _program_monitor_fired(self):
        return

    def _open_tcp_fired(self):
        if self.tcp_flag_not:
            self.tcp_flag = True
            self.tcp_flag_not = False
            configurator.openTCP(self.tcp_ip, self.tcp_port)

    def _close_tcp_fired(self):
        if self.tcp_flag:
            self.tcp_flag = False
            self.tcp_flag_not = True
            configurator.closeTCP()

    def _tune_start_fired(self):
        #change bias here
        self.bias_tune_name = self.bias12.name
        for r in range(0, self.tune_repetitions):
            for i in range(self.bias_tune_fine_start,
                           self.bias_tune_fine_end + 1):
                self.bias12.fine = i
                time.sleep(self.tune_pause_ms / 1000.0)
                print 'Repetition: ' + str(r)

    def openDefaultDevice(self):
        #configurator.openPCIe(self.FPGA_ID,self.FPGA_CHNL)
        self.status_pcie = 'closed'
        self.pcie_flag = False
        self.pcie_flag_not = True

    def _open_device_fired(self):
        if self.interface == 'PCIe':
            if self.pcie_flag == False:
                configurator.openPCIe(self.FPGA_ID, self.FPGA_CHNL)
                self.status_pcie = 'opened'
                self.pcie_flag = True
                self.pcie_flag_not = False
        if self.interface == 'USB':
            print "usb interface selected"
            import biasusb_wrap
            self.usb_flag = True
            self.usb_flag_not = False

    def _close_pcie_fired(self):
        if self.pcie_flag == True:
            configurator.closePCIe()
            self.status_pcie = 'closed'
            self.pcie_flag = False
            self.pcie_flag_not = True

    def _save_all_biases_fired(self):
        output = ''
        output += self.bias0.exportToString() + '\n'
        output += self.bias1.exportToString() + '\n'
        output += self.bias2.exportToString() + '\n'
        output += self.bias3.exportToString() + '\n'
        output += self.bias4.exportToString() + '\n'
        output += self.bias5.exportToString() + '\n'
        output += self.bias6.exportToString() + '\n'
        output += self.bias7.exportToString() + '\n'
        output += self.bias8.exportToString() + '\n'
        output += self.bias9.exportToString() + '\n'
        output += self.bias10.exportToString() + '\n'
        output += self.bias11.exportToString() + '\n'
        output += self.bias12.exportToString() + '\n'
        output += self.bias13.exportToString() + '\n'
        output += self.bias14.exportToString() + '\n'
        output += self.bias15.exportToString() + '\n'
        output += self.bias16.exportToString() + '\n'
        output += self.bias17.exportToString() + '\n'
        output += self.bias18.exportToString() + '\n'
        output += self.bias19.exportToString() + '\n'
        output += self.bias20.exportToString() + '\n'
        output += self.bias21.exportToString() + '\n'
        output += self.bias22.exportToString() + '\n'
        output += self.bias23.exportToString() + '\n'
        output += self.bias24.exportToString() + '\n'
        output += self.bias25.exportToString() + '\n'
        output += self.bias26.exportToString() + '\n'
        output += self.bias27.exportToString() + '\n'
        output += self.bias28.exportToString() + '\n'
        output += self.bias29.exportToString() + '\n'
        output += self.bias30.exportToString() + '\n'
        output += self.bias31.exportToString() + '\n'
        output += self.bias32.exportToString() + '\n'
        output += self.bias33.exportToString() + '\n'
        output += self.bias34.exportToString() + '\n'
        output += self.bias35.exportToString() + '\n'
        output += self.bias36.exportToString() + '\n'
        output += self.bias37.exportToString() + '\n'
        output += self.bias38.exportToString() + '\n'
        output += self.bias39.exportToString() + '\n'
        output += self.bias40.exportToString() + '\n'
        output += self.bias41.exportToString() + '\n'
        output += self.bias42.exportToString() + '\n'
        output += self.bias43.exportToString() + '\n'
        output += self.bias44.exportToString() + '\n'
        output += self.bias45.exportToString() + '\n'
        output += self.bias46.exportToString() + '\n'
        output += self.bias47.exportToString() + '\n'
        output += self.bias48.exportToString() + '\n'
        output += self.bias49.exportToString() + '\n'
        output += self.bias50.exportToString() + '\n'
        output += self.bias51.exportToString() + '\n'
        output += self.bias52.exportToString() + '\n'
        output += self.bias53.exportToString() + '\n'
        output += self.bias54.exportToString() + '\n'
        output += self.bias55.exportToString() + '\n'
        output += self.bias56.exportToString() + '\n'
        output += self.bias57.exportToString() + '\n'
        output += self.bias58.exportToString() + '\n'
        output += self.bias59.exportToString() + '\n'
        output += self.bias60.exportToString() + '\n'
        output += self.bias61.exportToString() + '\n'
        output += self.bias62.exportToString() + '\n'
        output += self.bias63.exportToString() + '\n'
        output += self.bias64.exportToString() + '\n'
        output += self.bias65.exportToString() + '\n'
        output += self.bias66.exportToString() + '\n'
        configurator.save_all_biases(self.file_to_save, output)
        return

    def _load_all_default_biases_fired(self):
        self.load_biases('')

    def _load_all_biases_fired(self):
        self.load_biases(self.file_to_load)

    def load_biases(self, file):
        self.bias0.setDefaults(file)
        self.bias1.setDefaults(file)
        self.bias2.setDefaults(file)
        self.bias3.setDefaults(file)
        self.bias4.setDefaults(file)
        self.bias5.setDefaults(file)
        self.bias6.setDefaults(file)
        self.bias7.setDefaults(file)
        self.bias8.setDefaults(file)
        self.bias9.setDefaults(file)
        self.bias10.setDefaults(file)
        self.bias11.setDefaults(file)
        self.bias12.setDefaults(file)
        self.bias13.setDefaults(file)
        self.bias14.setDefaults(file)
        self.bias15.setDefaults(file)
        self.bias16.setDefaults(file)
        self.bias17.setDefaults(file)
        self.bias18.setDefaults(file)
        self.bias19.setDefaults(file)
        self.bias20.setDefaults(file)
        self.bias21.setDefaults(file)
        self.bias22.setDefaults(file)
        self.bias23.setDefaults(file)
        self.bias24.setDefaults(file)
        self.bias25.setDefaults(file)
        self.bias26.setDefaults(file)
        self.bias27.setDefaults(file)
        self.bias28.setDefaults(file)
        self.bias29.setDefaults(file)
        self.bias30.setDefaults(file)
        self.bias31.setDefaults(file)
        self.bias32.setDefaults(file)
        self.bias33.setDefaults(file)
        self.bias34.setDefaults(file)
        self.bias35.setDefaults(file)
        self.bias36.setDefaults(file)
        self.bias37.setDefaults(file)
        self.bias38.setDefaults(file)
        self.bias39.setDefaults(file)
        self.bias40.setDefaults(file)
        self.bias41.setDefaults(file)
        self.bias42.setDefaults(file)
        self.bias43.setDefaults(file)
        self.bias44.setDefaults(file)
        self.bias45.setDefaults(file)
        self.bias46.setDefaults(file)
        self.bias47.setDefaults(file)
        self.bias48.setDefaults(file)
        self.bias49.setDefaults(file)
        self.bias50.setDefaults(file)
        self.bias51.setDefaults(file)
        self.bias52.setDefaults(file)
        self.bias53.setDefaults(file)
        self.bias54.setDefaults(file)
        self.bias55.setDefaults(file)
        self.bias56.setDefaults(file)
        self.bias57.setDefaults(file)
        self.bias58.setDefaults(file)
        self.bias59.setDefaults(file)
        self.bias60.setDefaults(file)
        self.bias61.setDefaults(file)
        self.bias62.setDefaults(file)
        self.bias63.setDefaults(file)
        self.bias64.setDefaults(file)
        self.bias65.setDefaults(file)
        self.bias66.setDefaults(file)
Beispiel #6
0
class LearningGUI(HasTraits):
        plot = Instance(Plot)
        meanrate = CFloat(0.0)
        cv = CFloat(0.0)
        teach = Bool(0)
        teach_active = Bool(0)
        teach_high = Range(100., 1000.)
        teach_low = Range(100., 1000.)
        f_max = Range(0., 1000.)
        f_min = Range(0., 1000.)
        updater = Instance(EventsUpdater)
        npre = Int(1)
        f_max_demo = Range(0., 1000.)
        durationl = Range(0., 10000.)
        
        stimlearn = traitsButton()
        inilearn = traitsButton()
        set_wij = traitsButton()
        get_wij = traitsButton()
        reset0_wij = traitsButton()
        reset1_wij = traitsButton()
        learning = Bool

        #Plot properties
        tDuration = Range(0.,20) 
        channel = Enum(range(getDefaultMonChannelAddress().nChannels))
        
        period = 1
        port = 50002
        host = nsetup.communicator.kwargs['host']
        stimulator = PoissonStimulator(SeqChannelAddress=None,
                                            channel=1,
                                            host=host,
                                            port_stim=port,
                                            rates=[],
                                            period=period)

        def _tDuration_default(self): return 5.
        
        def _meanrate_default(self): return 0.
        
        def _cv_default(self): return 0.
        
        def _learning_default(self): return True
        
        def _teach_high_default(self): return 200.
        def _teach_low_default(self): return 500.
        def _f_max_default(self): return 55.
        def _f_min_default(self): return 10.
        def _f_max_demo_default(self): return 55.
        def _durationl_default(self): return 200.
        
        def __init__(self, markersize=4, marker='circle', color='black'):
                super(LearningGUI, self).__init__()
                self.plotdata = ArrayPlotData(neurons = [0], times = [0])
                plot = Plot(self.plotdata)
                plot.plot(( "times", "neurons" ), 
                          type = "scatter",
                          marker = marker,
                          marker_size = markersize,
                          color=color)
                self.plot = plot
                
                self.wijstate = ArrayPlotData(imagedata=zeros((124, 28)))
                wijstate_plot = Plot(self.wijstate)
                wijstate_plot.img_plot("imagedata")
                self.wijstate_plot = wijstate_plot
        
                self.char = ArrayPlotData(imagedata=zeros((28, 28)))
                char_plot = Plot(self.char)
                char_plot.img_plot("imagedata")
                self.char_plot = char_plot
        
        def _channel_changed(self):
                print('Switching to channel: %d' % self.channel)
                self.updater.channel = self.channel
                self.updater.tot_neurons = []
                self.updater.tot_times = []
                try:
                        self.updater.eventsQueue.stop()
                except:
                        pass
                #addrBuildHashTable(self.updater.stcs[self.channel])
                self.updater.eventsQueue = pyAex.netMonClient(MonChannelAddress=self.updater.stcs,
                                                           channels = [self.channel],
                                                           host = self.updater.host,
                                                           port = self.updater.port,
                                                           autostart = True,
                                                           fps = self.updater.fps)


        def _teach_active_changed(self):
            if self.teach_active:
                host = nsetup.communicator.kwargs['host']
                self.stimulator = PoissonStimulator(SeqChannelAddress=None,
                                                    channel=1,
                                                    seq_export=False,
                                                    host=host,
                                                    port_stim=50002,
                                                    rates=[[SYN_PADDR,
                                                            self.teach_low]],
                                                    period=self.period)
                self.set_teacher()
                self.stimulator.start()
            else:
                self.stimulator.stop()

        def _teach_changed(self):
            self.set_teacher()

        def set_teacher(self):
            if self.teach:
                self.stimulator.rates = [[SYN_PADDR,
                                          self.teach_high]]
            else:
                self.stimulator.rates = [[SYN_PADDR,
                                          self.teach_low]]
        
        def _teach_high_changed(self):
            if self.teach:
                self.stimulator.rates = [[SYN_PADDR,
                                          self.teach_high]]
        
        def _teach_low_changed(self):
            if not self.teach:
                self.stimulator.rates = [[SYN_PADDR,
                                          self.teach_low]]

        def _learning_changed(self):
            if self.learning:
                chip.setBias(learning_on_biases)
            else: 
                chip.setBias(learning_off_biases)

        traits_view = View(
            Group(
                Group(
                    Group(
                        Item('teach_active', label='Teacher active   '),
                        Group(
                            Item('teach_low', label='NO freq   ',
                                 editor=RangeEditor(low=100, high=1000, mode='xslider')),
                            Item('teach_high', label='YES freq   ',
                                 editor=RangeEditor(low=100, high=1000, mode='xslider')),
                            orientation='vertical'
                        ),
                        Item('teach', label='Teach!   '),
                        label='Teacher',
                        orientation='vertical',
                    ),
                    #Group(
                        #Item('f_max_demo', label="f_max   "),
                        #Item('npre', label="Rounds   "),
                        #Item('durationl', label="Stim duration   "),
                        #Item('inilearn', show_label=False),
                        #label='Demo stimulator',
                        #orientation='vertical',
                    #),
                    Group(
                        # can't resize to fit in the window
                        #Item('char_plot', editor=ComponentEditor(), show_label=False),
                        Item('f_max', label="f_max   "),
                        Item('f_min', label="f_min   "),
                        Item('durationl', label="Stim duration   "),
                        Item('learning', label="Plasticity   "),
                        Item('stimlearn', show_label=False),
                        label='Stimulator',
                        orientation='vertical',
                    ),
                    Group(
                        Item('meanrate', label='MeanRate(Hz)    ', style='readonly'),
                        Item('cv', label='ISI CV    ', style='readonly'),
                        label='Quick measures',
                        orientation='vertical'
                    ),
                ),
                Group(
                    Item('plot', editor=ComponentEditor(), show_label=False),
                    label='Viewer',
                    orientation='vertical',
                ),
                orientation='horizontal'
            ),
            dock='tab',
            menubar=MenuBar(Menu(Action(name="Edit Plot",
                                        action="edit_plot"),
                                 CloseAction,
                                 name="File"),
                            Menu(Action(name="Default",
                                        action="load_default_biases"),
                                 Action(name="Set scan 0",
                                        action="setscanx_0"),
                                 name="Biases")),
            buttons=LiveButtons,
            handler = Controller,
            width=1600, 
            height=600, 
            resizable=True, 
            title="Leonardo",
        )
        
        plot_edit_view = View(Group(Item('tDuration'),
                                    #Item('colormap'),
                                    Item('channel')),
                              buttons=['OK','Cancel'])
Beispiel #7
0
class mapperTraits(HasTraits):

    #pci configurator
    SEQ_FPGA_ID = Range(0, 3, 1, mode='spinner')
    SEQ_FPGA_CHNL = Range(0, 0, 0, mode='spinner')
    MON_FPGA_ID = Range(0, 3, 0, mode='spinner')
    MON_FPGA_CHNL = Range(0, 0, 0, mode='spinner')
    pcieconf = Instance(PCIeMapperConfigurator)
    close_pcie_seq = traitsButton()
    close_pcie_mon = traitsButton()
    status_pcie_seq = Str('undefined')
    status_pcie_mon = Str('undefined')
    pcie_flag_seq = False
    pcie_flag_not_seq = True
    pcie_flag_mon = False
    pcie_flag_not_mon = True

    #control buttons
    open_devices = traitsButton()
    interface = Enum('PCIe')

    #stats
    in_rate = Str('0000.0 kEvt/s')
    out_rate = Str('0000.0 kEvt/s')

    #mapper process
    mapper = Instance(mapperProcess(PCIeMapperConfigurator, Lock))

    traits_view = View(
        Group(Group(Item(name='in_rate',
                         label='Input rate',
                         style='readonly',
                         emphasized=True),
                    Spring(springy=True),
                    Item(name='out_rate',
                         label='Output rate',
                         style='readonly',
                         emphasized=True),
                    label='Statistics',
                    orientation='horizontal',
                    show_border=True),
              Group(Item(name='mapper', style='custom', show_label=False),
                    label='Configuration',
                    show_border=True),
              label='Mapper'),
        Group(Group(Spring(springy=True),
                    Item(name='interface', label='Please choose an interface'),
                    Item('open_devices',
                         label='Open Devices',
                         show_label=False),
                    label='Interface',
                    show_border=True,
                    orientation='horizontal'),
              Group(Item(name='MON_FPGA_ID',
                         label='Device ID',
                         enabled_when='pcie_flag_not_mon'),
                    Item(name='MON_FPGA_CHNL',
                         label='Channel',
                         enabled_when='pcie_flag_not_mon'),
                    Spring(springy=True),
                    Item(name='status_pcie_mon',
                         label='Status',
                         style='readonly',
                         emphasized=True),
                    Item(name='close_pcie_mon',
                         label='Close',
                         show_label=False,
                         enabled_when='pcie_flag_mon'),
                    label='PCIe Monitor',
                    show_border=True,
                    orientation='horizontal'),
              Group(Item(name='SEQ_FPGA_ID',
                         label='Device ID',
                         enabled_when='pcie_flag_not_seq'),
                    Item(name='SEQ_FPGA_CHNL',
                         label='Channel',
                         enabled_when='pcie_flag_not_seq'),
                    Spring(springy=True),
                    Item(name='status_pcie_seq',
                         label='Status',
                         style='readonly',
                         emphasized=True),
                    Item(name='close_pcie_seq',
                         label='Close',
                         show_label=False,
                         enabled_when='pcie_flag_seq'),
                    label='PCIe Sequencer',
                    show_border=True,
                    orientation='horizontal'),
              label='Setup'))

    def _anytrait_changed(self):
        if not (self.mapper is None):
            self.mapper.terminateMapperProcess()

    def openDefaultDevices(self):
        self.lock.acquire()
        self.pcieconf.openPCIeMon(self.MON_FPGA_ID, self.MON_FPGA_CHNL)
        self.pcieconf.openPCIeSeq(self.SEQ_FPGA_ID, self.SEQ_FPGA_CHNL)
        self.status_pcie_mon = 'opened'
        self.status_pcie_seq = 'opened'
        self.pcie_flag_mon = True
        self.pcie_flag_not_mon = False
        self.pcie_flag_seq = True
        self.pcie_flag_not_seq = False
        self.lock.release()

    def _open_devices_fired(self):
        self.lock.acquire()
        if self.interface == 'PCIe':
            if self.pcie_flag_seq == False:
                self.pcieconf.openPCIeSeq(self.SEQ_FPGA_ID, self.SEQ_FPGA_CHNL)
                self.status_pcie_seq = 'opened'
                self.pcie_flag_seq = True
                self.pcie_flag_not_seq = False
            if self.pcie_flag_mon == False:
                self.pcieconf.openPCIeMon(self.MON_FPGA_ID, self.MON_FPGA_CHNL)
                self.status_pcie_mon = 'opened'
                self.pcie_flag_mon = True
                self.pcie_flag_not_mon = False
        self.lock.release()

    def _close_pcie_seq_fired(self):
        self.lock.acquire()
        if self.pcie_flag_seq == True:
            self.pcieconf.closePCIeSeq()
            self.status_pcie_seq = 'closed'
            self.pcie_flag_seq = False
            self.pcie_flag_not_seq = True
        self.lock.release()

    def _close_pcie_mon_fired(self):
        self.lock.acquire()
        if self.pcie_flag_mon == True:
            self.pcieconf.closePCIeMon()
            self.status_pcie_mon = 'closed'
            self.pcie_flag_mon = False
            self.pcie_flag_not_mon = True
        self.lock.release()
Beispiel #8
0
class mapperProcess(HasTraits):

    #fields
    pcieconf = PCIeMapperConfigurator
    mapper = BasicMapper
    p = Process

    #traits
    mapperType = Enum('BasicMapper')
    startMapper = traitsButton()
    stopMapper = traitsButton()

    view = View(
        Group(Group(Item(name='mapperType', label='Select instance'),
                    Spring(springy=True),
                    Item(name='startMapper',
                         label='Run',
                         show_label=False,
                         enabled_when='isNotRunning'),
                    Item(name='stopMapper',
                         label='Stop',
                         show_label=False,
                         enabled_when='isRunning'),
                    layout='normal',
                    style='simple',
                    orientation='horizontal'),
              orientation='vertical'))

    def run(self):
        self.lock.acquire()
        #do mapping
        while True:
            addr = self.pcieconf.get_32()
            print(addr)
            #self.pcieconf.send_32(addr)

    def terminateMapperProcess(self):
        if self.isRunning:
            self.isRunning = False
            self.isNotRunning = True
            self.p.terminate()
            self.lock.release()

    def __init__(self, pcieconf, lock):
        self.lock = lock
        self.pcieconf = pcieconf
        self.isRunning = False
        self.isNotRunning = True

    def _startMapper_fired(self):
        if self.isNotRunning:
            #instantiate mapper
            self.mapper = BasicMapper()
            #start mapper process
            self.p = Process(target=self.run)
            self.p.start()
            self.isRunning = True
            self.isNotRunning = False

    def _stopMapper_fired(self):
        if self.isRunning:
            self.terminateMapperProcess()
            del self.mapper
Beispiel #9
0
class dvspairTraits(HasTraits):

    #pci configurator
    FPGA_ID = Range(0, 3, 0, mode='spinner')
    FPGA_CHNL = Range(0, 0, 0, mode='spinner')
    pcieconf = Instance(DVSPAIRConfigurator)
    close_pcie = traitsButton()
    status_pcie = Str('undefined')
    pcie_flag = False

    #control buttons
    open_device = traitsButton()
    interface = Enum('PCIe', 'Serial')

    #filter settings
    leftYhigh = Range(0, 127, 127)
    leftYlow = Range(0, 127, 0)
    leftXhigh = Range(0, 127, 127)
    leftXlow = Range(0, 127, 0)
    rightYhigh = Range(0, 127, 127)
    rightYlow = Range(0, 127, 0)
    rightXhigh = Range(0, 127, 127)
    rightXlow = Range(0, 127, 0)

    #filter configuration
    ponEnable = Bool(True)
    poffEnable = Bool(True)
    fx2Enable = Bool(True)
    pcieEnable = Bool(True)
    leftEnable = Bool(True)
    rightEnable = Bool(True)

    traits_view = View(
        Group(Group(Item(name='leftXlow', label='Xmin'),
                    Item(name='leftXhigh', label='Xmax'),
                    Item(name='leftYlow', label='Ymin'),
                    Item(name='leftYhigh', label='Ymax'),
                    label='Left Boundaries',
                    orientation='horizontal',
                    show_border=True),
              Group(Item(name='rightXlow', label='Xmin'),
                    Item(name='rightXhigh', label='Xmax'),
                    Item(name='rightYlow', label='Ymin'),
                    Item(name='rightYhigh', label='Ymax'),
                    label='Right Boundaries',
                    orientation='horizontal',
                    show_border=True),
              Group(Item(name='ponEnable', label='Polarity ON'),
                    Item(name='poffEnable', label='Polarity OFF'),
                    Item(name='fx2Enable', label='To FX2'),
                    Item(name='pcieEnable', label='To PCIe'),
                    Item(name='leftEnable', label='Left DVS'),
                    Item(name='rightEnable', label='Right DVS'),
                    label='Configuration',
                    orientation='horizontal',
                    show_border=True),
              label='Filter'),
        Group(Group(Spring(springy=True),
                    Item(name='interface', label='Please choose an interface'),
                    Item('open_device', label='Open Device', show_label=False),
                    label='Interface',
                    show_border=True,
                    orientation='horizontal'),
              Group(Item(name='FPGA_ID',
                         label='Device ID',
                         enabled_when='pcie_flag_not'),
                    Item(name='FPGA_CHNL',
                         label='Channel',
                         enabled_when='pcie_flag_not'),
                    Spring(springy=True),
                    Item(name='status_pcie',
                         label='Status',
                         style='readonly',
                         emphasized=True),
                    Item(name='close_pcie',
                         label='Close',
                         show_label=False,
                         enabled_when='pcie_flag'),
                    label='PCIe Sequencer',
                    show_border=True,
                    orientation='horizontal'),
              label='Setup'))

    def _leftXlow_changed(self):
        self.setLeftFilterParams()

    def _leftXhigh_changed(self):
        self.setLeftFilterParams()

    def _leftYlow_changed(self):
        self.setLeftFilterParams()

    def _leftYhigh_changed(self):
        self.setLeftFilterParams()

    def setLeftFilterParams(self):
        bits = (int(self.leftXhigh) << 21) + (int(self.leftXlow) << 14) + (
            int(self.leftYhigh) << 7) + (int(self.leftYlow) << 0)
        self.pcieconf.send_left_params(bits)

    def _rightXlow_changed(self):
        self.setRightFilterParams()

    def _rightXhigh_changed(self):
        self.setRightFilterParams()

    def _rightYlow_changed(self):
        self.setRightFilterParams()

    def _rightYhigh_changed(self):
        self.setRightFilterParams()

    def setRightFilterParams(self):
        bits = (int(self.rightXhigh) << 21) + (int(self.rightXlow) << 14) + (
            int(self.rightYhigh) << 7) + (int(self.rightYlow) << 0)
        self.pcieconf.send_right_params(bits)

    def _ponEnable_changed(self):
        self.setConfParams()

    def _poffEnable_changed(self):
        self.setConfParams()

    def _fx2Enable_changed(self):
        self.setConfParams()

    def _pcieEnable_changed(self):
        self.setConfParams()

    def _leftEnable_changed(self):
        self.setConfParams()

    def _rightEnable_changed(self):
        self.setConfParams()

    def setConfParams(self):
        bits = (int(self.poffEnable) << 5) + (int(self.ponEnable) << 4) + (
            int(self.fx2Enable) << 3) + (int(self.pcieEnable) << 2) + (
                int(self.leftEnable) << 1) + (int(self.rightEnable))
        self.pcieconf.send_conf_params(bits)

    def openDefaultDevice(self):
        self.pcieconf.openPCIe(self.FPGA_ID, self.FPGA_CHNL)
        self.status_pcie = 'opened'
        self.pcie_flag = True
        self.pcie_flag_not = False

    def _open_device_fired(self):
        if self.interface == 'PCIe':
            if self.pcie_flag == False:
                self.pcieconf.openPCIe(self.FPGA_ID, self.FPGA_CHNL)
                self.status_pcie = 'opened'
                self.pcie_flag = True
                self.pcie_flag_not = False

    def _close_pcie_fired(self):
        if self.pcie_flag == True:
            self.pcieconf.closePCIe()
            self.status_pcie = 'closed'
            self.pcie_flag = False
            self.pcie_flag_not = True