The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> syntax error about the comparator
https://designers-guide.org/forum/YaBB.pl?num=1188718569

Message started by James Bond on Sep 2nd, 2007, 12:36am

Title: syntax error about the comparator
Post by James Bond on Sep 2nd, 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

Title: Re: syntax error about the comparator
Post by Ken Kundert on 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

Title: Re: syntax error about the comparator
Post by James Bond on 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

Title: Re: syntax error about the comparator
Post by Ken Kundert on 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

Title: Re: syntax error about the comparator
Post by James Bond on Sep 3rd, 2007, 10:43am

Thank you very much. It's working

Best Regards
James

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.