badcrossbar’s docs#

Computing#

badcrossbar.compute.compute(applied_voltages, resistances, r_i=None, r_i_word_line=None, r_i_bit_line=None, **kwargs)[source]#

Computes branch currents and node voltages of a crossbar.

Parameters
  • applied_voltages (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – Applied voltages. Voltages must be supplied in an array of shape m x p, where m is the number of word lines and p is the number of examples (sets of voltages applied one by one).

  • resistances (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) – Resistances of crossbar devices. Resistances must be supplied in an array of shape m x n, where n is the number of bit lines.

  • r_i (Optional[float]) – Interconnect resistance of the word and bit line segments. If None, r_i_word_line and r_i_bit_line are used instead.

  • r_i_word_line (Optional[float]) – Interconnect resistance of the word line segments.

  • r_i_bit_line (Optional[float]) – Interconnect resistance of the bit line segments.

  • **node_voltages – If False, None is returned instead of node voltages.

  • **all_currents – If False, only output currents are returned, while all the other ones are set to None.

Return type

Solution

Returns

Branch currents and node voltages of the crossbar. Field currents is a named tuple itself with fields output, device, word_line and bit_line and contains output currents, as well as currents flowing through the devices and interconnect segments of the word and bit lines. Field voltages is a named tuple itself with fields word_line and bit_line and contains the voltages at the nodes on the word and bit lines. currents.output is an array of shape p x n, while all the others are arrays of shape m x n if p == 1, or arrays of shape m x n x p if p > 1.

Plotting#

badcrossbar.plot.branches(device_vals=None, word_line_vals=None, bit_line_vals=None, currents=None, **kwargs)[source]#

Plots a crossbar array and colors its branches according to the values passed. The diagram is saved as a PDF file.

If currents is passed, then it is used to plot the currents in the branches. Otherwise, at least one of {device_vals, word_line_vals, bit_line_vals} has to be passed.

Parameters
  • device_vals (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]], None]) – Values associated with crossbar devices.

  • word_line_vals (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]], None]) – Values associated with the interconnect segments along the word lines.

  • bit_line_vals (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]], None]) – Values associated with the interconnect segments along the bit lines.

  • currents (Optional[Currents]) – Crossbar branch currents. It should have fields device, word_line and bit_line that contain currents flowing through the devices and interconnect segments of the word and bit lines (at least one of them should be not None).

  • **default_color – Normalized RGB values of the nodes and certain types of branches if their values are not provided.

  • **wire_scaling_factor – Scaling factor for the width of the word and bit lines.

  • **device_scaling_factor – Scaling factor for the width of the devices. Also scales the nodes.

  • **node_scaling_factor – Scaling factor for the diameter of the nodes which is combined with device_scaling_factor. For example, if one wanted to only scale the device width by a factor of 2, but keep the node diameter the same, arguments device_scaling_factor = 2 and node_scaling_factor = 1/2 would have to be passed.

  • **axis_label – Axis label of the color bar.

  • **low_rgb – Normalized RGB value associated with the lower limit.

  • **zero_rgb – Normalized RGB value associated with the value of zero.

  • **high_rgb – Normalized RGB value associated with the upper limit.

  • **allow_overwrite – If True, can overwrite existing PDF files with the same name.

  • **filename – Filename, excluding PDF extension.

  • **device_type – Device type to be drawn. One of {"memristor", "memristor_2", "resistor_usa", "resistor_europe"}.

  • **significant_figures – Number of significant figures to use for the limits of the color bar.

  • **round_crossings – Because the circuit of a crossbar array is non-planar, the 2D diagram of it will have some wire crossings. If round_crossings is False, these crossings will be drawn as straight lines. Otherwise, they will be drawn as semicircles.

  • **width – Width of the diagram in millimeters.

badcrossbar.plot.nodes(word_line_vals=None, bit_line_vals=None, voltages=None, **kwargs)[source]#

Plots a crossbar array and colors its nodes according to the values passed. The diagram is saved as a PDF file.

If voltages is passed, then it is used to plot the voltages on the nodes. Otherwise, at least one of {word_line_vals, bit_line_vals} has to be passed.

Parameters
  • word_line_vals (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]], None]) – Values associated with the nodes on the word lines.

  • bit_line_vals (Union[_SupportsArray[dtype], _NestedSequence[_SupportsArray[dtype]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]], None]) – Values associated with the nodes on the bit lines.

  • voltages (Optional[Voltages]) – Crossbar node voltages. It should have fields word_line and bit_line that contain the potentials at the nodes on the word and bit lines (at least one of them should be not None).

  • **default_color – Normalized RGB values of the branches and certain type of nodes if its values are not provided.

  • **wire_scaling_factor – Scaling factor for the width of the word and bit lines.

  • **device_scaling_factor – Scaling factor for the width of the devices.

  • nodes. (Also scales the) –

  • **node_scaling_factor – Scaling factor for the diameter of the nodes which is combined with device_scaling_factor. For example, if one wanted to only scale the device width by a factor of 2, but keep the node diameter the same, arguments device_scaling_factor = 2 and node_scaling_factor = 1/2 would have to be passed.

  • **axis_label – Axis label of the color bar.

  • **low_rgb – Normalized RGB value associated with the lower limit.

  • **zero_rgb – Normalized RGB value associated with the value of zero.

  • **high_rgb – Normalized RGB value associated with the upper limit.

  • **allow_overwrite – If True, can overwrite existing PDF files with the same name.

  • **filename – Filename, excluding PDF extension.

  • **device_type – Device type to be drawn. One of {"memristor", "memristor_2", "resistor_usa", "resistor_europe"}.

  • **significant_figures – Number of significant figures to use for the limits of the color bar.

  • **round_crossings – Because the circuit of a crossbar array is non-planar, the 2D diagram of it will have some wire crossings. If round_crossings is False, these crossings will be drawn as straight lines. Otherwise, they will be drawn as semicircles.

  • **width – Width of the diagram in millimeters.