// Simulation EPaper Cell 

`include "disciplines.vams"
`include "constants.vams"
`include "otft.va"


module myfet(d, g, s);
  inout electrical d, g, s;
  parameter real kp = 1m;
  parameter real vt = 1;
  real vgst;
  real cur;
  analog begin
   vgst = V(g,s)-vt;
   cur = 0.0;
   if (vgst > 0)
    if (vgst > V(d,s))
     cur = (vgst-0.5*V(d,s))*V(d,s);
    else
     cur = 0.5*pow(vgst, 2);
     I(d,s) <+ kp*cur;
   end
endmodule



module rdot_pixel(vs, gate, gnd);
   electrical vs, gate, gnd;
   electrical con;

   myfet FET1(con, gate, gnd);

   resistor #(.r(2075)) Rppy(vs, con); 
   capacitor #(.c(500u)) Cppy(vs, con);

endmodule 

module tb_rdot;
   electrical src_gate, src_vs, gnd;
   ground gnd;

   parameter real on_V = 10.0;
   parameter real off_V = 0;

   parameter real on_T = 2;  // 2s on after 1s delay 
   parameter real off_T = 0;
   parameter real startDelay = 1;

   // Puls-Quelle 
   /*prameters expected for 'pulse' are '[dc] [mag [phase]] val0 val1 [td [rise [fall [width [period]]]]] */
   vpulse #(.val0(off_V), .val1(on_V), .td(startDelay), .rise(1n), .fall(1n), .width(on_T)) PL(src_gate, gnd);

   vdc #(.dc(1.0)) VDC1 (src_vs, gnd);
   // Pixel
   rdot_pixel pixel1(src_vs, src_gate, gnd);
endmodule 
