The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Mar 29th, 2024, 1:43am
Pages: 1
Send Topic Print
[SOLVED] oneshot circuit or monostable multivibrator (Read 3977 times)
Shahriar
Junior Member
**
Offline



Posts: 19
Chelsmford, MA
[SOLVED] oneshot circuit or monostable multivibrator
Sep 29th, 2016, 12:23pm
 
Hi,

I'm new to veriloga. I'm trying to make a veriloga model for a one-shot circuit. The steady output will be low. It would trigger on both positive and negative edges of input and the output will stay high for a defined "pw" parameter.

I can't figure out how to code the output getting back to steady state after "pw" time has passed after an edge occurs in input.

Here's the code I've written so far.

Code:
// VerilogA for scratch_veriloga, oneshot, veriloga

`include "constants.vams"
`include "disciplines.vams"

module oneshot (trigger, oneshot);

input trigger;
output oneshot;
voltage trigger, oneshot;

parameter real vil = 0.5;
parameter real vih = 2;
parameter real thres = (vil+vih)/2;
parameter real vol = 0;
parameter real voh = 2.5;

parameter real td = 0.1n from [0:inf);
parameter real tt = 0.1n from [0:inf);
parameter real pw = 3u from [0:inf);
//parameter integer dir = +1 from [-1:+1] exclude 0;

real state;

analog begin

	@(cross(V(trigger)-thres)) state = 1;

	//can't figure out how to code that 'state' will go back to 0 after 'pw' time after cross event.

	V(oneshot) <+ transition(state?voh:vol,td,tt);

end

endmodule 



Could anyone please tell me how I can do this? Or point me to an example?

Thanks.
Back to top
 
« Last Edit: Sep 30th, 2016, 10:57am by Shahriar »  

Shahriar
View Profile Shahriar   IP Logged
Shahriar
Junior Member
**
Offline



Posts: 19
Chelsmford, MA
Re: oneshot circuit or monostable multivibrator
Reply #1 - Sep 30th, 2016, 10:56am
 
Found the solution myself here. http://www.designers-guide.org/Forum/YaBB.pl?num=1210828245

Code:
@(cross(V(trigger)-thres)) begin
		state = 1;
		next = $abstime + pw;
	end
	@(timer(next)) state = 0; 

Back to top
 
 

Shahriar
View Profile Shahriar   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2384
Silicon Valley
Re: [SOLVED] oneshot circuit or monostable multivibrator
Reply #2 - Oct 1st, 2016, 6:00pm
 
Thanks for posting your solution.

-Ken
Back to top
 
 
View Profile WWW   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.