Awesome Array Driver - arenaudineau/AwesomeArray-PythonDriver Wiki

Welcome to the AwesomeArray-PythonDriver wiki!

Installation verification

By following the quick installation guide from README, you should be able to import the library wherever you want:

import aad

Several errors can show up:

Missing aad

ModuleNotFoundError: No module named 'aad'

The library has not been correctly installed. [...]

Missing B1530driver

ModuleNotFoundError: Failed to import B1530driver. Please make sure that the B1530driver files are in 'extlibs/B1530Driver'.

The two licenced files B1530driver.py and B1530ErrorModule.py are missing, you must provide them in aad/extlibs/B1530Driver, aside the DRIVER_SCRIPTS_HERE file.

Missing wgfmu DLL

error occurs with wgfmu.dll

wgfmu.dll failed to load, it must be in C:\B1530A_InstLib\. Alternatively, modify its path in aad/extlibs/B1530Driver/B1530driver.py with the variable wgfmu_link. If it still fails to load, then ¯\_(ツ)_/¯

Initialization

driver = aad.AwesomeArrayDriver()

Again, several errors may occur:

Microcontroller not found

Exception: µc not found, please verify its connection or specify its PID

Make sure the microcontroller is connected. There are two USB port on the board:

  • PWR is used to power and program it and is NOT used by the driver, it may be connected to the PC the driver is run from, or another one ;
  • USER is used for serial communication and IS used by the driver, it must be connected to the PC the driver is run from ;

By default, the driver is looking for a USB device with a Product IDentifier (PID): 22336.
For some reason the board may not have this one. You can either change it by reprogramming the microcontroller (in STM32Cube, in the project, ioc file, search for USB_DEVICE on the left panel, go down, Device Descriptor panel, PID (Product IDentifier)) or provide it to the driver:
aad.print_ports() will show every device connected and its associated PID. (⚠️ This is NOT STMicroelectronics STLink Virtual COM Port)

You can then use:

driver = aad.AwesomeArrayDriver(uc_pid={correct_pid})

Microcontroller port already open

serial.serialutil.SerialException: could not open port '{PORT}': PermissionError(13, 'Access is denied.', None, 5)

The serial connection is already opened somewhere else, check if there are no other instance of AwesomeArrayDriver running (for example in another Jupyter Notebook ; you may want to interrupt/restart the kernel)

Lost microcontroller connection

serial.serialutil.SerialException: WriteFile failed (PermissionError(13, 'The device does not recognize the command.', None, 22))

This error will not happen right after the initialization but can appear when using it. It means the USB cable have been plugged out or that the connection has timed out.

B1530 not found

Exception: -5: Error in WGFMU_openSession("GPIB0::18::INSTR");
        viReadSTB returned -1073807304.

Check the connection or that EasyEXPERT on the B1500A has been closed.

B1530 already open

Exception: -3: Error in WGFMU_openSession("GPIB0::18::INSTR");
        A session has already been opened by WGFMU_openSession("GPIB0::18::INSTR").

The connection is already opened somewhere else, check if there are no other instance of AwesomeArrayDriver running (for example in another Jupyter Notebook ; you may want to interrupt/restart the kernel)

Usage

For now, the driver configures by default the Awesome Array, and can only be used, in CARAC mode.

A memristor can be addressed by three parameters:

  • col: its column index in the Test Array ;
  • row: its row index in the Test Array ;
  • bar: boolean to adress the complementary memristor if True [False by default]

On each of them you can perform the operations: form, set, reset and read. The three first do not return anything, the last one returns the memristor value in Ω ohm.

Words in the Awesome Array are 64 bits long (64x64 * 2 = 8 192 memristors). The constant aad.SR_WORD_SIZE is set to this value for more explicit code.

Examples

"""
Forms each memristor
⚠️ it takes several **minutes** to run, the bottleneck being the calls to the B1530 underlying driver
"""

for col in range(aad.SR_WORD_SIZE):
  for row in range(aad.SR_WORD_SIZE):
    driver.form(col=col, row=row, bar=False)
    driver.form(col=col, row=row, bar=True)
"""Toggles the complementary memristor at column 6, row 42"""

RES_LIMIT = 5e3

res = driver.read(col=6, row=42, bar=True)
print("Before toggle:", res)

if res > RES_LIMIT:
  driver.set(col=6, row=42, bar=True)
else:
  driver.reset(col=6, row=42, bar=True)

res = driver.read(col=6, row=42, bar=True)
print("After toggle:", res)