The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 16th, 2024, 8:22pm
Pages: 1
Send Topic Print
syntax error about the comparator (Read 3074 times)
James Bond
Community Member
***
Offline



Posts: 82

syntax error about the comparator
Sep 02nd, 2007, 12:36am
 
Hi, all,

I wrote the veriloga code for the comparator, but when I compiled this code, it reported:
"@cross(<<--? V(insin) - V(intri),0)",  Does anybody know where is the problem ?

My code is like this:

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

module comparator3(cout, intri, insin);

output cout;
input intri,insin;
electrical cout,intri,insin;
parameter real td = 1n,tr = 1n,tf = 1n;
 
analog begin
  @cross(V(insin) - V(intri),0)
     V(cout) <+ transition((V(insin) > V(intri)) ? 1:0,td,tr,tf);
end

endmodule


Please give me some instructions, thank you very much.

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



Posts: 2386
Silicon Valley
Re: syntax error about the comparator
Reply #1 - Sep 2nd, 2007, 1:00am
 
I believe you need the argument to the @ statement to be within parentheses.

@(cross(...))

rather than

@cross(...)

In addition, you cannot have a transition function, or a contribution operator, in the body of an event statement.  Instead you probably want something like the following ...

analog begin
   @(cross(V(insin) - V(intri), 0)
       ;
   V(cout) <+ transition(V(insin) > V(intri), td, tr, tf);
end
Back to top
 
 
View Profile WWW   IP Logged
James Bond
Community Member
***
Offline



Posts: 82

Re: syntax error about the comparator
Reply #2 - Sep 2nd, 2007, 7:37am
 
Hi, Ken,

Thank you so much. Now it is working. I would like to ask you another question about this model.

Now the V(cout) is 1V, but my supply is 2V, how can I program to make it reach  the full swing supply ?

or maybe, since my input signal intri and insin are not ideal signal, they all have a dc bias about 1V, how can I make my comparator output have a 1V dc , the it will reach 2V swing, I think.


Thank you very much
Best Regards
James
Back to top
 

aa_001.jpg
View Profile   IP Logged
Ken Kundert
Global Moderator
*****
Offline



Posts: 2386
Silicon Valley
Re: syntax error about the comparator
Reply #3 - Sep 2nd, 2007, 2:18pm
 
To adjust the output voltage to 2V use ...
   V(cout) <+ 2*transition(V(insin) > V(intri), td, tr, tf);

With that the output will swing between 0 and 2v. If you want the output to swing between two arbitrary voltages use ...
   parameter real vl = 0;
   parameter real vh = 2;
   V(cout) <+ transition(V(insin) > V(intri) ? vh : vl, td, tr, tf);

-Ken
Back to top
 
 
View Profile WWW   IP Logged
James Bond
Community Member
***
Offline



Posts: 82

Re: syntax error about the comparator
Reply #4 - Sep 3rd, 2007, 10:43am
 
Thank you very much. It's working

Best Regards
James
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.