-
Notifications
You must be signed in to change notification settings - Fork 9
/
2_multiple_sets_of_inputs.py
43 lines (35 loc) · 1.45 KB
/
2_multiple_sets_of_inputs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import badcrossbar
# Applied voltages in volts.
applied_voltages = [
[1.5, 4.1, 2.6, 2.1],
[2.3, 4.5, 1.1, 0.8],
[1.7, 4.0, 3.3, 1.1],
]
# Device resistances in ohms.
resistances = [
[345, 903, 755, 257, 646],
[652, 401, 508, 166, 454],
[442, 874, 190, 244, 635],
]
# Interconnect resistance in ohms.
r_i = 0.5
# Computing the solution.
solution = badcrossbar.compute(applied_voltages, resistances, r_i)
# Printing the current through the word line segment to the left of device in
# the second row and fourth column when the first set of inputs is applied
# (Python uses zero-based indexing).
current = solution.currents.word_line[1, 3, 0]
print(f"\nThe current through the word line segment is ~{current:.3g} A.")
# Printing the current at the third output when the second set of inputs is
# applied.
current = solution.currents.output[1, 2]
print(f"\nThe current at the third output is ~{current:.3g} A.")
# Printing the current through the crossbar device in the last row and the
# last column when the last set of inputs is applied (in Python, `-1` refers
# to the last element in an array).
current = solution.currents.device[-1, -1, -1]
print(f"\nThe current through the crossbar device is ~{current:.3g} A.")
# Printing the voltage on the bit line node in the last row and second column
# when the third set of inputs is applied.
voltage = solution.voltages.bit_line[-1, 1, 2]
print(f"\nThe voltage at the bit line node is ~{voltage:.3g} V.")