badcrossbar’s docs
Contents
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 shapem x p, wheremis the number of word lines andpis 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 shapem x n, wherenis the number of bit lines.r_i (
Optional[float]) – Interconnect resistance of the word and bit line segments. If None,r_i_word_lineandr_i_bit_lineare 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
currentsis a named tuple itself with fieldsoutput,device,word_lineandbit_lineand contains output currents, as well as currents flowing through the devices and interconnect segments of the word and bit lines. Fieldvoltagesis a named tuple itself with fieldsword_lineandbit_lineand contains the voltages at the nodes on the word and bit lines.currents.outputis an array of shapep x n, while all the others are arrays of shapem x nifp == 1, or arrays of shapem x n x pifp > 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
currentsis 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 fieldsdevice,word_lineandbit_linethat 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, argumentsdevice_scaling_factor = 2andnode_scaling_factor = 1/2would 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_crossingsis 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
voltagesis 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 fieldsword_lineandbit_linethat 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, argumentsdevice_scaling_factor = 2andnode_scaling_factor = 1/2would 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_crossingsis False, these crossings will be drawn as straight lines. Otherwise, they will be drawn as semicircles.**width – Width of the diagram in millimeters.