// E2R.vams - basic Verilog-AMS electrical to discrete wreal connection module
// last revised:  08/01/06, jhou
//
// REVISION HISTORY:
// Created:  08/01/06, jhou

`include "disciplines.vams"
`timescale 1ns / 100ps

connectmodule E2R (Ain, Dout);
input Ain;
electrical Ain;    //input electrical
output Dout;
wreal Dout;        //output wreal
\logic Dout;       //discrete domain

  parameter real vdelta=1.8/64   from (0:inf);    // voltage delta
  parameter real vtol=vdelta/4   from (0:vdelta); // voltage tolerance
  parameter real ttol=10p        from (0:1m];     // time tolerance

  real Dreg;       //real register for A to D wreal conversion

  assign Dout = Dreg;

  //discretize V(Ain) triggered by absdelta function
  always @(absdelta(V(Ain), vdelta, ttol, vtol))
	Dreg = V(Ain);

endmodule

