I want to write these 3 equations with one boundary condition assosciated. I have coded the same in matlab and it works fine. But here i have some problems, i want the function to return me an array of values so i can plot them. I used this approach in matlab. But in verilog i dont knw what idt and ddt returns, array or function of t...
eq 1 : d(w(t))/dt = [uv*Ron.I(t)]/D #uv,Ron,D are constant and I(t) = input current, From here i get array of W for different I(t) ( or maybe w(t) ..? )
#boundary condition of equation 1 is w(0)=1.5e-9
eq 2 : R = Ron*w(t)/D + Roff(1- w(t)/D)
eq 3 : V(t)=R*I(t);
Code:
Verilog A
[I]//Verilog a memristor model by Sourabh Sethi//
`include "disciplines.vams"
`include "constants.h"
//in outs
module Memristor_Linear(p, n);
input p;
output n;
electrical p,n;
ground gnd;
//parameters
parameter real D= 3e-9;
parameter real uv=1e-15;
parameter real Roff = 2e5;
parameter real Ron=100;
real w_temp;
real w;
real R;
//equations
analog begin[syntax=verilog][/syntax]
w_temp=(uv*Ron*I(p,n))/D;
w=idt(w_temp,1.5e-9); //initial condition w at t=0 is 1.5e-9
[B][I]R=(Ron*w)/D + (Roff*(1-(w/D); //Error is in this line[/I]
[I]V(p,n) <+ R*(I(p,n) ; // and this[/I][/B]
end
endmodule[/I]
Re: Need help writing equations in Verilog A. My first code in Verilog A.
I m calculating a function and i want to make one dimensional array of it by giving small time steps. How to do it ?
- - - Updated - - -
analog
begin
k=uv*Ron/D;
w = idt((k * I(p,n)),0.5*D);
r1=(Ron*w/D);
k2= (1-w/D);
r2=Roff*k2;
R=(r1+r2);
V(p,n)<+r1*I(p,n);
V(p,n)<+r2*I(p,n);
//V(p,n) <+ R* I(p,n);
end
Fixed above errors by splitting the equation. But i am getting a straight like, but my R is not constant , its a varying function. How to declare R as varying function of w ?
Re: Need help writing equations in Verilog A. My first code in Verilog A.
After some discussion with my guide, i will not try V(t)=R(t) * I(t) approach. I will now investigate multiplication of one dimensional array of resistance (which i will import from matlab) with Current's one dimensional array. Will update soon.
Re: Need help writing equations in Verilog A. My first code in Verilog A.
Array multiplication will be difficult as i need 1e5 sample size or more to get smooth curve.
I have solved above problem by trial and error and got hysteresis I-V plot in Verilog A.
Please contact me at [email address removed - reply on Edaboard for the benefit of others please].