The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 4:35pm
Pages: 1
Send Topic Print
Pulse generator in verilog-A (Read 3282 times)
ssp
Junior Member
**
Offline



Posts: 11

Pulse generator in verilog-A
Nov 20th, 2011, 5:46pm
 
Hi,

I'm new to verilog-A and I'm trying to generate an output pulse of 0V at every falling edge of my input pulse signal (1.8V to 0V) in Spectre. Unfortunetly, using the following code, my output pulse seems to be generated at a rising edge :

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

module allo(in,out);
parameter real td = 3n;   // width of pulse
parameter real tt = 0n;    // output transition time (s)

   output out;
   input in;
   voltage in, out;

   real Vout, tend;

   analog begin
     @(cross(V(in), -1)) begin
	 Vout = 0;
	 tend = $abstime + td;
     end
     @(timer(tend))
	 Vout = 1.8;
	   V(out) <+ transition(Vout, td, tt);
   end

endmodule
 


My resulting signals :


Back to top
 

pulse.png
View Profile   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #1 - Nov 20th, 2011, 9:02pm
 
To be more clear, this is the signal train I want to have :


[img][/img]

How can I obtain that output ?
Thank you for your help,
ssp
Back to top
 

v_pulse.png
View Profile   IP Logged
Forum Administrator
YaBB Administrator
*****
Offline



Posts: 145

Re: Pulse generator in verilog-A
Reply #2 - Nov 20th, 2011, 11:24pm
 
Your model looks okay to me. Perhaps the problem is elsewhere. Please provide enough information so we can replicate your simulation.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #3 - Nov 21st, 2011, 7:15am
 
Hi Ken,

the problem is that my code doesn't generate the output pulse as I wich it did. It seems that the @cross function is not working well, or perhaps the code I made have a mistake in it that I can't detect...I don't know if this can help but my input signal comes from a dynamic comparator working with an intern clock of 12ns period. I want to use the output pulse as a reset signal for a PMOS transistor.

Back to top
 
 
View Profile   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #4 - Nov 21st, 2011, 7:18am
 
Also, my simulation was made using Spectre Cadence with a transient analysis.
Back to top
 
 
View Profile   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Pulse generator in verilog-A
Reply #5 - Nov 21st, 2011, 7:37am
 
Hi,

Your cross event tests for negative crossing with threshold 0. This is probably not what you intended.

- B O E
Back to top
 
 
View Profile   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #6 - Nov 21st, 2011, 7:48am
 
Hi Boe,

yes, your right, that's the problem. Is there a way I can set the threshold voltage to 1.6V in the @cross function ? If not, is there a simple code to detect falling edge of a signal with min. 0V and max. 1.8V ?
Thanks!
Back to top
 
 
View Profile   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #7 - Nov 21st, 2011, 9:24am
 
By reading verilog-ams guide more carefully, I only need to add V(in)-1 in the cross function to make it work:

@(cross(V(in)-1,-1))
Back to top
 
 
View Profile   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1999
Massachusetts, USA
Re: Pulse generator in verilog-A
Reply #8 - Nov 22nd, 2011, 10:38am
 
ssp wrote on Nov 21st, 2011, 9:24am:
By reading verilog-ams guide more carefully


Always a good idea!
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #9 - Nov 23rd, 2011, 3:06pm
 
Hi guys,

I still don't exactly get the result I'm expecting with this code:

Code:
module allo(in,out);
parameter real td = 10n;   // width of pulse
parameter real tt = 0n;	// output transition time (s)
parameter real t1 = 0n;

   output out;
   input in;
   voltage in, out;

   real Vout, tend,rst;

analog begin

	@ (initial_step or cross(V(in)-1, -1)) begin
	   // @ (cross(V(in)-1, -1)) begin
		 Vout = 0;
		 tend = $abstime + td;//return simulation time + td
	  end

	  @(timer(tend))
		 Vout = 1.8;
		 V(out) <+ transition(Vout, td, tt);
	   end

endmodule
 



I want to detect the first falling edge on the Vin signal (time 65.24ns), while my code only detects the second falling edge at time 75.21 ns. Why is that ? Is there a way I can fix my code to detect the first falling edge ?

Thanks for your help,
ssp
Back to top
 

pulse_detector_code.png
View Profile   IP Logged
Forum Administrator
YaBB Administrator
*****
Offline



Posts: 145

Re: Pulse generator in verilog-A
Reply #10 - Nov 24th, 2011, 1:07am
 
Never put a contribution statement or a transition function inside an @ block.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Pulse generator in verilog-A
Reply #11 - Nov 24th, 2011, 4:42am
 
ssp wrote on Nov 23rd, 2011, 3:06pm:
...
I want to detect the first falling edge on the Vin signal (time 65.24ns), while my code only detects the second falling edge at time 75.21 ns. Why is that ? Is there a way I can fix my code to detect the first falling edge ?
You do detect the edge @ 65.24 ns; because of the 10 ns delay you specified (td in transition filter), the output changes @ 75.24.

BTW, Ken: The contribution statement is not inside the @ block, the code is just poorly indented.

- B O E
Back to top
 
 
View Profile   IP Logged
ssp
Junior Member
**
Offline



Posts: 11

Re: Pulse generator in verilog-A
Reply #12 - Nov 24th, 2011, 7:25am
 
wow, yes, I guess I was I tired when I wrote that..I add 2 delays with the transition.
I was wondering, at what rate does the @cross function samples signals ?
Back to top
 
 
View Profile   IP Logged
Forum Administrator
YaBB Administrator
*****
Offline



Posts: 145

Re: Pulse generator in verilog-A
Reply #13 - Nov 24th, 2011, 1:24pm
 
Argh. Normally I will not answer questions from people that cannot be bothered to format their code in a readable fashion. I should have stuck with that policy here.

Code:
module allo(in,out);
parameter real td = 10n;   // width of pulse
parameter real tt = 0n;	// output transition time (s)
parameter real t1 = 0n;
output out;
input in;
voltage in, out;
real Vout, tend,rst;

analog begin
    @(initial_step or cross(V(in)-1, -1)) begin
	  Vout = 0;
	  tend = $abstime + td;//return simulation time + td
    end

    @(timer(tend))
	  Vout = 1.8;

    V(out) <+ transition(Vout, td, tt);
end
endmodule 



Improperly indented code is largely unreadable, leading to confusion and mistakes, and making it hard for people to help you. Before asking someone to look at your code, you should indent it properly. It only took me a few seconds to do it, and in doing it you often find the problem yourself.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
boe
Community Fellow
*****
Offline



Posts: 615

Re: Pulse generator in verilog-A
Reply #14 - Nov 25th, 2011, 4:56am
 
ssp wrote on Nov 24th, 2011, 7:25am:
...
I was wondering, at what rate does the @cross function samples signals ?
See documentation: Cadence Verilog-A language reference, section cross-Event.

- B O E
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.