From cc587b9aa209137c68e888aed50a8ee18f5bfaee Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 15 Jul 2026 14:41:00 -0700 Subject: functional SPICE crossbar --- src/crossbar.cir | 57 +++++++++++++++++++++++++++++++++++++++++ src/custom_memristor.sub | 14 ---------- src/hp_memristor.cir | 45 ++++++++++++++++++++++++++++++++ src/memristor_spires_proof.png | Bin 0 -> 86864 bytes src/torch_reservoir.py | 6 ++--- 5 files changed, 105 insertions(+), 17 deletions(-) create mode 100644 src/crossbar.cir delete mode 100644 src/custom_memristor.sub create mode 100644 src/hp_memristor.cir create mode 100644 src/memristor_spires_proof.png (limited to 'src') diff --git a/src/crossbar.cir b/src/crossbar.cir new file mode 100644 index 0000000..5668221 --- /dev/null +++ b/src/crossbar.cir @@ -0,0 +1,57 @@ +*========================================================== +* 2x2 HP Memristor Crossbar +*========================================================== + +.include "hp_memristor.cir" + +****************************************************** +* Input Voltages (Rows) +****************************************************** + +.param VIN0=0.25 +.param VIN1=0.75 + +VROW0 row0 0 DC {VIN0} +VROW1 row1 0 DC {VIN1} + +****************************************************** +* Memristor Array +****************************************************** + +X00 row0 col0 memristor PARAMS: Rinit=1k +X01 row0 col1 memristor PARAMS: Rinit=100k +X02 row0 col2 memristor PARAMS: Rinit=50k +X03 row0 col3 memristor PARAMS: Rinit=70k + +X10 row1 col0 memristor PARAMS: Rinit=1k +X11 row1 col1 memristor PARAMS: Rinit=100k +X12 row1 col2 memristor PARAMS: Rinit=50k +X13 row1 col3 memristor PARAMS: Rinit=70k + +****************************************************** +* Column Loads +****************************************************** + +RLOAD0 col0 0 1k +RLOAD1 col1 0 1k +RLOAD2 col2 0 1k +RLOAD3 col3 0 1k + +****************************************************** +* Simulation +****************************************************** + +.tran 1n 100n uic + +.control + +run + +print v(col0) +print v(col1) +print v(col2) +print v(col3) +save all +.endc + +.end diff --git a/src/custom_memristor.sub b/src/custom_memristor.sub deleted file mode 100644 index bd909c8..0000000 --- a/src/custom_memristor.sub +++ /dev/null @@ -1,14 +0,0 @@ -* This is completely ai generated to be honest -* Custom Behavioral Memristor Model -.subckt custom_memristor plus minus state_node -* Internal state capacitor to store value 'w' -Cstate state_node 0 1IC=0.1 - -* Example behavioral state derivative derivative equation (dw/dt) -* Gbar represents the rate of change based on voltage across plus and minus -Gstate 0 state_node value={V(plus,minus) * 1e3} - -* Behavioral current equation (I = V / R(w)) -* Resistance varies inversely with the voltage at 'state_node' -Gmem plus minus value={V(plus,minus) / (100 + (10000 * (1 - V(state_node))))} -.ends custom_memristor diff --git a/src/hp_memristor.cir b/src/hp_memristor.cir new file mode 100644 index 0000000..1865a7a --- /dev/null +++ b/src/hp_memristor.cir @@ -0,0 +1,45 @@ +* HP Memristor SPICE Model +* For Transient Analysis only +* created by Zdenek and Dalibor Biolek +************************** +* Ron, Roff - Resistance in ON / OFF States +* Rinit - Resistance at T=0 +* D - Width of the thin film +* uv - Migration coefficient +* p - Parameter of the WINDOW-function +* for modeling nonlinear boundary conditions +* x - W/D Ratio, W is the actual width +* of the doped area (from 0 to D) +* +.SUBCKT memristor Plus Minus PARAMS: ++ Ron=1K Roff=100K Rinit=80K D=10N uv=10F p=1 +*********************************************** +* DIFFERENTIAL EQUATION MODELING * +*********************************************** +Gx 0 x value={ I(Emem)*uv*Ron/D^2*f(V(x),p)} +Cx x 0 1 IC={(Roff-Rinit)/(Roff-Ron)} +Raux x 0 1T + +* RESISTIVE PORT OF THE MEMRISTOR * +******************************* +Emem plus aux value={-I(Emem)*V(x)*(Roff-Ron)} +Roff aux minus {Roff} +*********************************************** +*Flux computation* +*********************************************** +*does not work with ngspice +*Eflux flux 0 value={SDT(V(plus,minus))} +*********************************************** +*Charge computation* +*********************************************** +*does not work with ngspice +*Echarge charge 0 value={SDT(I(Emem))} +*********************************************** +* WINDOW FUNCTIONS +* FOR NONLINEAR DRIFT MODELING * +*********************************************** +*window function, according to Joglekar +.func f(x,p)={1-(2*x-1)^(2*p)} +*proposed window function +;.func f(x,i,p)={1-(x-stp(-i))^(2*p)} +.ENDS memristor diff --git a/src/memristor_spires_proof.png b/src/memristor_spires_proof.png new file mode 100644 index 0000000..ea294fc Binary files /dev/null and b/src/memristor_spires_proof.png differ diff --git a/src/torch_reservoir.py b/src/torch_reservoir.py index 6e7ceb7..a21ed75 100644 --- a/src/torch_reservoir.py +++ b/src/torch_reservoir.py @@ -14,7 +14,7 @@ import time # ----- PARAMETERS ----- NUM_INPUTS = 1 NUM_OUTPUTS = 1 -NUM_NEURONS = 2000 +NUM_NEURONS = 800 time_steps = 2000 input_layer = torch.nn.Linear(NUM_INPUTS, NUM_NEURONS, bias=False) @@ -122,12 +122,12 @@ test_steps = np.arange(800, time_steps) plt.figure(figsize=(10, 5)) plt.plot(test_steps, y_test, label="True Future Wave", color="black", linestyle="dashed") plt.plot(test_steps, predictions, label="Reservoir Prediction", color="blue", alpha=0.8) -plt.title("spires memristor Time-Series Forecasting") +plt.title("spires memristor Time-Series prediction") plt.xlabel("time steps") plt.ylabel("Amplitude") plt.legend() plt.tight_layout() -plt.show() +plt.savefig("memristor_spires_proof.png") free_spires_reservoir(spires_reservoir) -- cgit v1.2.3