The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Apr 18th, 2024, 4:24am
Pages: 1
Send Topic Print
VerilogAMS model for dual voltage clamper (Read 558 times)
sanforyou
Junior Member
**
Offline



Posts: 17

VerilogAMS model for dual voltage clamper
Sep 03rd, 2019, 5:38am
 
Hi,
I am writing a verilogAMS model for dual clamper. It's simple voltage clamp with upper threshold(upclamp) of 180mv and lower threshold(dnclamp) of 50mv. When upper threshold is reached then Output voltage is pulled down to ground and when lower threshold is reached then output voltage is pulled up to VDD.

AMS model works fine on block level testbench but it starts chattering on top level and slows down the simulation drastically?

Here is my verilogAMS code:

Code:
`include "constants.vams"
`include "disciplines.vams"

module compClamp (COMP2PWM,VoutDivRC2,COMPclamp,AVDD,AGND);
	input COMP2PWM;
	input VoutDivRC2;
	inout AVDD;
	inout AGND;
	output COMPclamp;

	electrical COMP2PWM, VoutDivRC2, COMPclamp, AVDD, AGND;
	electrical dnclamp,upclamp;

	real gm_dnclamp;
	real gm_upclamp;

    parameter real dn_clamp_offset=50m;
    parameter real up_clamp_offset=180m;
  
analog begin

    @(cross(dn_clamp_offset-V(COMP2PWM,VoutDivRC2),0))
		;
	if((dn_clamp_offset-V(COMP2PWM,VoutDivRC2))>0)
		gm_dnclamp= 11.0m;
    else
		gm_dnclamp= 1.0n;

    @(cross(V(COMP2PWM,VoutDivRC2)-up_clamp_offset,0))
		;
	if((V(COMP2PWM,VoutDivRC2)-up_clamp_offset)>0)
   		gm_upclamp= 11.0m;
    else
		gm_upclamp= 1.0n;

	I(AVDD,dnclamp) <+ V(AVDD,dnclamp) * transition(gm_dnclamp,0,500.0p,500.0p);
	I(upclamp,AGND) <+ V(upclamp,AGND) * transition(gm_upclamp,0,500.0p,500.0p);

	I(COMPclamp,upclamp) <+ V(COMPclamp,upclamp)*gm_upclamp;  
    I(COMPclamp,dnclamp) <+ V(COMPclamp,dnclamp)*gm_dnclamp;
end
endmodule 



Can anyone suggest improvement in the model to achieve this functionality without any slowdown? Thanks.
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.