The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 8:39pm
Pages: 1
Send Topic Print
How to Generate a Rectangular Pulse with Different Amplitudes (Read 3906 times)
Kevin Finn
New Member
*
Offline



Posts: 3
Germany
How to Generate a Rectangular Pulse with Different Amplitudes
May 30th, 2013, 7:57am
 
Hi everyone,

I've been trying to implement the following with Verilog A; however, I couldn't make it work thus far. What I wanna do is basically generate a rectangular pulse with more than 2 different amplitudes. For example, the amplitudes I want my pulse to have are 5, 3, 1, and -1 (in voltage).

During each unit interval, which's let's say 50 ns, I want my pulse to be equal to one of the abovewritten values.

I expect to code something like the following:

Code:
@(above($abstime - unit_interval) x = 5;
@(above($abstime - 2*unit_interval) x = 3;
@(above($abstime - 3*unit_interval) x = 1;
@(above($abstime - 4*unit_interval) x = -1;

pulse <+  transition (x); 



However, the second line overwrites the first line, the third line overwrites the first two lines, and so on and so forth.

Could you please help me as to how I can code such a pulse in Verilog A?

Thanks in advance!
Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: How to Generate a Rectangular Pulse with Different Amplitudes
Reply #1 - May 31st, 2013, 1:16am
 
Try using @timer rather than @above. Use the second argument on the timer function to implement periodicity.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Kevin Finn
New Member
*
Offline



Posts: 3
Germany
Re: How to Generate a Rectangular Pulse with Different Amplitudes
Reply #2 - May 31st, 2013, 2:24am
 
Thanks for your response, Ken!

I actually had tried the @timer event before and couldn't make it work either.

Could you please tell me what's wrong with the following code? V(out) seems to be zero at all times when I simulate it.

Code:
@(timer(0, unit_interval)) x = 5;
@(timer(unit_interval, 2*unit_interval)) x = 3;
@(timer(2*unit_interval, 3*unit_interval)) x = 1;
@(timer(3*unit_interval, 4*unit_interval)) x = -1;

V(out) <+ transition(x, 0.0, period/100.0 );
 

Back to top
 
 
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: How to Generate a Rectangular Pulse with Different Amplitudes
Reply #3 - May 31st, 2013, 10:19am
 
You have not given enough of the model to see the problem. Please give the entire module.

-Ken
Back to top
 
 
View Profile WWW   IP Logged
Kevin Finn
New Member
*
Offline



Posts: 3
Germany
Re: How to Generate a Rectangular Pulse with Different Amplitudes
Reply #4 - Jun 3rd, 2013, 2:10am
 
Thanks for your response, Ken! Now, it's working, although I didn't get what the problem was before. I'm learning Verilog-A from scratch, so perhaps I did something nonesense.

Code:
module vsource_test (out);


output out;
voltage out;

parameter real unit_interval = 40n;

integer x;

analog begin

	@(timer(0, unit_interval)) x = 5;
	@(timer(unit_interval, 2*unit_interval)) x = 3;
	@(timer(2*unit_interval, 3*unit_interval)) x = 1;
	@(timer(3*unit_interval, 4*unit_interval)) x = -1;

	V(out) <+ transition(x, 0, unit_interval/100);

end


endmodule
 

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.