Пример #1
0
    def __init__(self, ui, dbgio):
        self.ui = ui
        self.dbgio = dbgio
        self.device = vendor.get_device(self.ui, soc_name)
        self.dbgio.connect(self.device.cpu_info.name, 'swd')
        self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
        self.device.bind_cpu(self.cpu)
        self.mem = mem.mem(self.cpu)
        self.flash = flash.flash(flash_driver.stm32l4x2(self.device),
                                 self.device, self.mem)
        gpio_drv = (gpio_driver.drv(self.device, gpio_cfg))
        self.gpio = gpio.gpio(gpio_drv)

        self.menu_root = (
            ('cpu', self.cpu.menu, 'cpu functions'),
            ('da', self.cpu.cmd_disassemble, cortexm.help_disassemble),
            ('debugger', self.dbgio.menu, 'debugger functions'),
            ('exit', self.cmd_exit),
            ('flash', self.flash.menu, 'flash functions'),
            ('go', self.cpu.cmd_go),
            ('gpio', self.gpio.menu, 'gpio functions'),
            ('halt', self.cpu.cmd_halt),
            ('help', self.ui.cmd_help),
            ('history', self.ui.cmd_history, cli.history_help),
            ('map', self.device.cmd_map),
            ('mem', self.mem.menu, 'memory functions'),
            ('program', self.flash.cmd_program, flash.help_program),
            ('regs', self.cmd_regs, soc.help_regs),
            ('vtable', self.cpu.cmd_vtable),
        )

        self.ui.cli.set_root(self.menu_root)
        self.set_prompt()
        self.dbgio.cmd_info(self.ui, None)
Пример #2
0
    def __init__(self, ui, dbgio):
        self.ui = ui
        self.dbgio = dbgio
        self.device = vendor.get_device(self.ui, soc_name)
        self.dbgio.connect(self.device.cpu_info.name, "swd")
        self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
        self.device.bind_cpu(self.cpu)
        self.mem = mem.mem(self.cpu)
        self.flash = flash.flash(flash_driver.stm32f0xx(self.device), self.device, self.mem)
        gpio_drv = gpio_driver.drv(self.device, gpio_cfg)
        self.gpio = gpio.gpio(gpio_drv)
        self.i2c = i2c.i2c(i2c_driver.gpio(gpio_drv, "PB6", "PB7"))

        self.menu_root = (
            ("cpu", self.cpu.menu, "cpu functions"),
            ("da", self.cpu.cmd_disassemble, cortexm.help_disassemble),
            ("debugger", self.dbgio.menu, "debugger functions"),
            ("exit", self.cmd_exit),
            ("flash", self.flash.menu, "flash functions"),
            ("go", self.cpu.cmd_go),
            ("gpio", self.gpio.menu, "gpio functions"),
            ("halt", self.cpu.cmd_halt),
            ("help", self.ui.cmd_help),
            ("history", self.ui.cmd_history, cli.history_help),
            ("i2c", self.i2c.menu, "i2c functions"),
            ("map", self.device.cmd_map),
            ("mem", self.mem.menu, "memory functions"),
            ("program", self.flash.cmd_program, flash.help_program),
            ("regs", self.cmd_regs, soc.help_regs),
            ("vtable", self.cpu.cmd_vtable),
        )

        self.ui.cli.set_root(self.menu_root)
        self.set_prompt()
        self.dbgio.cmd_info(self.ui, None)
Пример #3
0
def get_mem_power_spectra(vq, trajectory, parameters):
    test_frequency_range = np.array(parameters.frequency_range)

    # Check number of coefficients
    if vq.shape[0] <= parameters.number_of_coefficients_mem + 1:
        print(
            'Number of coefficients should be smaller than the number of time steps'
        )
        exit()

    psd_vector = []
    if not parameters.silent:
        _progress_bar(0, 'M. Entropy')
    for i in range(vq.shape[1]):
        psd_vector.append(
            mem.mem(test_frequency_range,
                    vq[:, i],
                    trajectory.get_time_step_average(),
                    coefficients=parameters.number_of_coefficients_mem))

        if not parameters.silent:
            _progress_bar(float(i + 1) / vq.shape[1], 'M. Entropy')

    psd_vector = np.array(psd_vector).T

    return psd_vector * unit_conversion
Пример #4
0
  def __init__(self, ui, dbgio):
    self.ui = ui
    self.dbgio = dbgio
    self.device = vendor.get_device(self.ui, soc_name)
    self.dbgio.connect(self.device.cpu_info.name, 'swd')
    self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
    self.device.bind_cpu(self.cpu)
    self.mem = mem.mem(self.cpu)
    self.flash = flash.flash(flash_driver.flash(self.device), self.device, self.mem)

    self.menu_root = (
      ('cpu', self.cpu.menu, 'cpu functions'),
      ('da', self.cpu.cmd_disassemble, cortexm.help_disassemble),
      ('debugger', self.dbgio.menu, 'debugger functions'),
      ('exit', self.cmd_exit),
      ('flash', self.flash.menu, 'flash functions'),
      ('go', self.cpu.cmd_go),
      ('halt', self.cpu.cmd_halt),
      ('help', self.ui.cmd_help),
      ('history', self.ui.cmd_history, cli.history_help),
      ('map', self.device.cmd_map),
      ('mem', self.mem.menu, 'memory functions'),
      ('program', self.flash.cmd_program, flash.help_program),
      ('regs', self.cmd_regs, soc.help_regs),
      ('vtable', self.cpu.cmd_vtable),
    )

    self.ui.cli.set_root(self.menu_root)
    self.set_prompt()
    self.dbgio.cmd_info(self.ui, None)
Пример #5
0
    def __init__(self, ui, dbgio):
        self.ui = ui
        self.dbgio = dbgio
        self.device = imxrt.get_device(self.ui, soc_name)
        self.dbgio.connect(self.device.cpu_info.name, 'swd')
        self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
        self.device.bind_cpu(self.cpu)
        self.mem = mem.mem(self.cpu)
        self.fw = firmware.firmware(self.cpu)
        self.flexspi = flexspi.flexspi(self.device)

        self.menu_root = (
            ('cpu', self.cpu.menu, 'cpu functions'),
            ('da', self.cpu.cmd_disassemble, cortexm.help_disassemble),
            ('debugger', self.dbgio.menu, 'debugger functions'),
            ('exit', self.cmd_exit),
            ('flexspi', self.flexspi.menu, 'flexspi functions'),
            ('fw', self.fw.menu, 'firmware functions'),
            ('go', self.cpu.cmd_go),
            ('halt', self.cpu.cmd_halt),
            ('help', self.ui.cmd_help),
            ('history', self.ui.cmd_history, cli.history_help),
            ('map', self.device.cmd_map),
            ('mem', self.mem.menu, 'memory functions'),
            ('regs', self.cmd_regs, soc.help_regs),
            ('vtable', self.cpu.cmd_vtable),
        )

        self.ui.cli.set_root(self.menu_root)
        self.set_prompt()
        self.dbgio.cmd_info(self.ui, None)
Пример #6
0
 def ERA(self, namef):
     self.memory.printMemory()
     self.namef = namef
     self.contParameters = 0
     self.variablesOfFunction = list(self.directory[self.namef]['vars'])
     newMemory = mem.mem(
     )  #Se crea una nueva instancia de memoria para la nueva funcion
     count = 0
     for i in self.memory.memory:
         if i is not None:
             newMemory.save(i, count)
         count = count + 1
     self.listOfMemories.append(self.memory)
     self.memory = newMemory
Пример #7
0
    def __init__(self, ui, dbgio):
        self.ui = ui
        self.dbgio = dbgio
        self.device = vendor.get_device(self.ui, soc_name)
        # add the 8MiB SDRAM
        self.device.insert(
            soc.make_peripheral('sdram', 0xc0000000, 8 << 20, None,
                                'external sdram'))
        self.dbgio.connect(self.device.cpu_info.name, 'swd')
        self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
        self.device.bind_cpu(self.cpu)
        self.mem = mem.mem(self.cpu)
        self.flash = flash.flash(flash_driver.sdrv(self.device), self.device,
                                 self.mem)
        gpio_drv = (gpio_driver.drv(self.device, gpio_cfg))
        self.gpio = gpio.gpio(gpio_drv)
        self.i2c1 = i2c.i2c(i2c_driver.bitbang(gpio_drv, 'PB8', 'PB9'))
        self.i2c3 = i2c.i2c(i2c_driver.bitbang(gpio_drv, 'PH7', 'PH8'))
        # setup the rtt client
        ram = self.device.sram
        self.rtt = rtt.rtt(self.cpu, mem.region('ram', ram.address, ram.size))

        self.menu_root = (
            ('cpu', self.cpu.menu, 'cpu functions'),
            ('da', self.cpu.cmd_disassemble, cortexm.help_disassemble),
            ('debugger', self.dbgio.menu, 'debugger functions'),
            ('exit', self.cmd_exit),
            ('flash', self.flash.menu, 'flash functions'),
            ('go', self.cpu.cmd_go),
            ('gpio', self.gpio.menu, 'gpio functions'),
            ('halt', self.cpu.cmd_halt),
            ('help', self.ui.cmd_help),
            ('history', self.ui.cmd_history, cli.history_help),
            ('i2c1', self.i2c1.menu, 'i2c1 functions'),
            ('i2c3', self.i2c3.menu, 'i2c3 functions'),
            ('map', self.device.cmd_map),
            ('mem', self.mem.menu, 'memory functions'),
            ('program', self.flash.cmd_program, flash.help_program),
            ('regs', self.cmd_regs, soc.help_regs),
            ('rtt', self.rtt.menu, 'rtt client functions'),
            ('vtable', self.cpu.cmd_vtable),
        )

        self.ui.cli.set_root(self.menu_root)
        self.set_prompt()
        self.dbgio.cmd_info(self.ui, None)
Пример #8
0
    def __init__(self, ui, dbgio):
        self.ui = ui
        self.dbgio = dbgio
        self.device = vendor.get_device(self.ui, soc_name)
        self.dbgio.connect(self.device.cpu_info.name, 'swd')
        self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
        self.device.bind_cpu(self.cpu)
        self.mem = mem.mem(self.cpu)
        self.flash = flash.flash(flash_driver.sdrv(self.device), self.device,
                                 self.mem)
        gpio_drv = (gpio_driver.drv(self.device, gpio_cfg))
        self.gpio = gpio.gpio(gpio_drv)
        self.i2c = i2c.i2c(i2c_driver.gpio(gpio_drv, 'PB6', 'PB9'))
        self.dac = dac.cs43l22(self.i2c, 0x94, self.dac_reset)
        # setup the rtt client
        ram = self.device.sram
        self.rtt = rtt.rtt(self.cpu, mem.region('ram', ram.address, ram.size))
        # setup the gdb server
        self.gdb = gdb.gdb(self.cpu)

        self.menu_root = (
            ('cpu', self.cpu.menu, 'cpu functions'),
            ('da', self.cpu.cmd_disassemble, cortexm.help_disassemble),
            ('dac', self.dac.menu, 'dac functions'),
            ('debugger', self.dbgio.menu, 'debugger functions'),
            ('exit', self.cmd_exit),
            ('flash', self.flash.menu, 'flash functions'),
            ('gdb', self.gdb.run),
            ('go', self.cpu.cmd_go),
            ('gpio', self.gpio.menu, 'gpio functions'),
            ('halt', self.cpu.cmd_halt),
            ('help', self.ui.cmd_help),
            ('history', self.ui.cmd_history, cli.history_help),
            ('i2c', self.i2c.menu, 'i2c functions'),
            ('map', self.device.cmd_map),
            ('mem', self.mem.menu, 'memory functions'),
            ('program', self.flash.cmd_program, flash.help_program),
            ('regs', self.cmd_regs, soc.help_regs),
            ('rtt', self.rtt.menu, 'rtt client functions'),
            ('vtable', self.cpu.cmd_vtable),
        )

        self.ui.cli.set_root(self.menu_root)
        self.set_prompt()
        self.dbgio.cmd_info(self.ui, None)
Пример #9
0
  def __init__(self, ui, dbgio):
    self.ui = ui
    self.dbgio = dbgio
    self.device = vendor.get_device(self.ui, soc_name)
    self.dbgio.connect(self.device.cpu_info.name, 'swd')
    self.cpu = cortexm.cortexm(self, ui, self.dbgio, self.device)
    self.device.bind_cpu(self.cpu)
    self.mem = mem.mem(self.cpu)
    self.flash = flash.flash(flash_driver.sdrv(self.device), self.device, self.mem)
    gpio_drv = (gpio_driver.drv(self.device, gpio_cfg))
    self.gpio = gpio.gpio(gpio_drv)
    self.i2c = i2c.i2c(i2c_driver.gpio(gpio_drv, 'PB6', 'PB9'))
    self.dac = dac.cs43l22(self.i2c, 0x94, self.dac_reset)
    # setup the rtt client
    ram = self.device.sram
    self.rtt = rtt.rtt(self.cpu, mem.region('ram', ram.address, ram.size))
    # setup the gdb server
    self.gdb = gdb.gdb(self.cpu)

    self.menu_root = (
      ('cpu', self.cpu.menu, 'cpu functions'),
      ('da', self.cpu.cmd_disassemble, cortexm.help_disassemble),
      ('dac', self.dac.menu, 'dac functions'),
      ('debugger', self.dbgio.menu, 'debugger functions'),
      ('exit', self.cmd_exit),
      ('flash', self.flash.menu, 'flash functions'),
      ('gdb', self.gdb.run),
      ('go', self.cpu.cmd_go),
      ('gpio', self.gpio.menu, 'gpio functions'),
      ('halt', self.cpu.cmd_halt),
      ('help', self.ui.cmd_help),
      ('history', self.ui.cmd_history, cli.history_help),
      ('i2c', self.i2c.menu, 'i2c functions'),
      ('map', self.device.cmd_map),
      ('mem', self.mem.menu, 'memory functions'),
      ('program', self.flash.cmd_program, flash.help_program),
      ('regs', self.cmd_regs, soc.help_regs),
      ('rtt', self.rtt.menu, 'rtt client functions'),
      ('vtable', self.cpu.cmd_vtable),
    )

    self.ui.cli.set_root(self.menu_root)
    self.set_prompt()
    self.dbgio.cmd_info(self.ui, None)
Пример #10
0
    def mem_test():

        clk = Signal(bool(0))
        rnw = Signal(bool(1))

        di  = Signal(intbv(0)[WIDTH:])
        do  = Signal(intbv(0)[WIDTH:])
        a   = Signal(intbv(0)[WIDTH:])

        mem_inst = mem(do, di, a, rnw, clk, width=WIDTH, depth=DEPTH)

        DELAY = delay(PERIOD // 2)

        @always(DELAY)
        def clkgen():
            clk.next = not clk

        @instance
        def monitor():
            while True:
                print "%d MEM[%s] do %s di %s" % (rnw, BIN(a), BIN(do), BIN(di))
                yield DELAY

        @instance
        def stimulus():
            def write(byte, adr):
                a.next = adr
                di.next = byte
                yield clk.posedge

                rnw.next = 0
                yield clk.posedge

                rnw.next = 1
                yield clk.posedge

            for step in range(STEPS):
                yield write(step << 4, step)

            raise StopSimulation

        return mem_inst, clkgen, monitor, stimulus
Пример #11
0
    def __init__(self, ui, jtag_driver):
        self.ui = ui
        self.jtag_driver = jtag_driver
        self.soc = esp32.make_soc()
        self.cpu = esp32.xtensa(ui, jtag_driver, _ofs, _ir_chain, self.soc)
        self.soc.bind_cpu(self.cpu)
        self.mem = mem.mem(self.cpu)

        self.menu_root = (
            ('esp32', self.cpu.menu, 'esp32 functions'),
            ('jtag', self.jtag_driver.menu, 'jtag functions'),
            ('exit', self.cmd_exit),
            ('help', self.ui.cmd_help),
            ('history', self.ui.cmd_history, cli.history_help),
            ('map', self.soc.cmd_map),
            ('regs', self.cmd_regs, soc.help_regs),
            ('mem', self.mem.menu, 'memory functions'),
        )

        self.ui.cli.set_root(self.menu_root)
        self.set_prompt()
        self.jtag_driver.cmd_info(self.ui, None)
Пример #12
0
item += 'COMMIT'.ljust(15)
print(item)

# Main Code
while (len(ROB) > 0) | (cycle == 1):

    # ISSUE stage
    if (PC.PC < len(instructions)) & (PC.valid == 1):
        issue(cycle, PC, instructions, ROB, size_ROB, rs_int_adder,
              rs_fp_adder, rs_fp_multi, ld_sd_queue, size_ld_sd_queue, rat_int,
              rat_fp)

    # EXE stage
    exe(fu_int_adder, time_fu_int_adder, fu_fp_adder, time_fu_fp_adder,
        fu_fp_multi, time_fu_fp_multi, results_buffer, rs_int_adder,
        rs_fp_adder, rs_fp_multi, ld_sd_exe, time_ld_sd_exe, ld_sd_queue,
        cycle, ROB, PC)

    # MEM stage
    mem(ld_sd_queue, ld_sd_mem, time_ld_sd_mem, results_buffer, memory, ROB,
        cycle)

    # CDB stage
    wb(cdb, rat_int, rat_fp, rs_int_adder, rs_fp_adder, rs_fp_multi,
       ld_sd_queue, ROB, cycle, results_buffer)

    # COMMIT stage
    commit(ROB, reg_int, reg_fp, cycle, instructions)

    # cycle number
    cycle += 1
Пример #13
0
def mem_coefficient_scan_analysis(vq, trajectory, parameters):
    from dynaphopy.analysis.fitting import fitting_functions

    mem_full_dict = {}

    for i in range(vq.shape[1]):
        test_frequency_range = parameters.frequency_range
        fit_data = []
        scan_params = []
        power_spectra = []
        if not parameters.silent:
            _progress_bar(0, 'ME Coeff.')
        for number_of_coefficients in parameters.mem_scan_range:

            power_spectrum = mem.mem(test_frequency_range,
                                     vq[:, i],
                                     trajectory.get_time_step_average(),
                                     coefficients=number_of_coefficients)

            power_spectrum *= unit_conversion

            guess_height = np.max(power_spectrum)
            guess_position = test_frequency_range[np.argmax(power_spectrum)]

            Fitting_function_class = fitting_functions.fitting_functions[
                parameters.fitting_function]

            if np.isnan(power_spectrum).any():
                print(('Warning: power spectrum error, skipping point {0}'.
                       format(number_of_coefficients)))
                continue

        #  Fitting_curve = fitting_functions[parameters.fitting_function]
            fitting_function = Fitting_function_class(
                test_frequency_range,
                power_spectrum,
                guess_height=guess_height,
                guess_position=guess_position)

            fitting_parameters = fitting_function.get_fitting()

            if not fitting_parameters['all_good']:
                print(('Warning: Fitting error, skipping point {0}'.format(
                    number_of_coefficients)))
                continue

#            frequency = fitting_parameters['peak_position']
            area = fitting_parameters['area']
            width = fitting_parameters['width']
            #            base_line = fitting_parameters['base_line']
            maximum = fitting_parameters['maximum']
            error = fitting_parameters['global_error']

            fit_data.append([number_of_coefficients, width, error, area])
            scan_params.append(fitting_function._fit_params)
            power_spectra.append(power_spectrum)
            if not (parameters.silent):
                _progress_bar(
                    float(number_of_coefficients + 1) /
                    parameters.mem_scan_range[-1], "M.E. Method")

        fit_data = np.array(fit_data).T
        if fit_data.size == 0:
            continue

        best_width = np.average(fit_data[1], weights=np.sqrt(1. / fit_data[2]))

        best_index = int(np.argmin(fit_data[2]))
        power_spectrum = power_spectra[best_index]

        mem_full_dict.update({
            i: [power_spectrum, best_width, best_index, fit_data, scan_params]
        })

    for i in range(vq.shape[1]):
        if not i in list(mem_full_dict.keys()):
            continue

        print(('Peak # {0}'.format(i + 1)))
        print('------------------------------------')
        print(('Estimated width      : {0} THz'.format(mem_full_dict[i][1])))

        fit_data = mem_full_dict[i][3]
        scan_params = mem_full_dict[i][4]
        best_index = mem_full_dict[i][2]

        print(('Position (best fit): {0} THz'.format(
            scan_params[best_index][0])))
        print(('Area (best fit): {0} eV'.format(fit_data[3][best_index])))
        print(('Coefficients num (best fit): {0}'.format(
            fit_data[0][best_index])))
        print(('Fitting global error (best fit): {0}'.format(
            fit_data[2][best_index])))
        print("\n")

        plt.figure(i + 1)
        plt.suptitle('Peak {0}'.format(i + 1))
        ax1 = plt.subplot2grid((2, 2), (0, 0), colspan=2)
        ax2 = plt.subplot2grid((2, 2), (1, 0))
        ax3 = plt.subplot2grid((2, 2), (1, 1))

        ax1.set_xlabel('Number of coefficients')
        ax1.set_ylabel('Width [THz]')
        ax1.set_title('Peak width')
        ax1.plot(fit_data[0], fit_data[1])
        ax1.plot((fit_data[0][0], fit_data[0][-1]),
                 (mem_full_dict[i][1], mem_full_dict[i][1]), 'k-')

        ax2.set_xlabel('Number of coefficients')
        ax2.set_ylabel('(Global error)^-1')
        ax2.set_title('Fitting error')
        ax2.plot(fit_data[0], np.sqrt(1. / fit_data[2]))

        ax3.set_xlabel('Frequency [THz]')
        ax3.set_title('Best curve fitting')
        ax3.plot(test_frequency_range,
                 mem_full_dict[i][0],
                 label='Power spectrum')
        ax3.plot(test_frequency_range,
                 fitting_function._function(test_frequency_range,
                                            *scan_params[best_index]),
                 label='{} fit'.format(fitting_function.curve_name))

        plt.show()