The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> using binary numbers in VerilogA
https://designers-guide.org/forum/YaBB.pl?num=1265985977

Message started by hali on Feb 12th, 2010, 6:46am

Title: using binary numbers in VerilogA
Post by hali on Feb 12th, 2010, 6:46am

Hi.Can anyone tell me that can I use binary numbers in verilog A .e.g can i assign( integer i=0100); if no wat is the way to use binary numbers in verilog A? :-[

Title: Re: using binary numbers in VerilogA
Post by pancho_hideboo on Feb 12th, 2010, 7:56am


hali wrote on Feb 12th, 2010, 6:46am:
Can anyone tell me that can I use binary numbers in verilog A .e.g can i assign( integer i=0100);
There is no direct method which is available in Verilog-D or Verilog-AMS.


hali wrote on Feb 12th, 2010, 6:46am:
if no wat is the way to use binary numbers in verilog A?
It is same as C-language.
i = 0*(1<<3) + 1*(1<<2) + 0*(1<<1) + 0*(1<<0);


Quote:
integer iflag, i, j, a, d;
integer x, h;

real test;

analog begin
  @(initial_step) begin
     iflag = 0;
     d = 1;
     x = 0;
     for(i=0; i<=REGISTER_LENGTH;i=i+1) begin
        x = x + (1 << i);
     end

     if(REGISTER_LENGTH == 15)
        h = (1 << 0) + (1 << 14) + (1 << 15);
     else
        h = (1 << 0) + (1 << 5) + (1 << 9);
  end // initial_step

  @(timer(Clock_Period/10, Clock_Period)) begin
     if(iflag > 0) begin
        a = x & h;

        j = 0;
        for(i=1; i<=REGISTER_LENGTH;i=i+1) begin
           j = j ^ ((a >> i) & 1);
        end
        x = x & (~1);
        x = x ^ j;

        x = x << 1;
     end
     iflag = 1;
  end // timer



Title: Re: using binary numbers in VerilogA
Post by Andrew Beckett on Feb 15th, 2010, 9:23am

Slightly confused by Pancho Hideboo's response, as in Verilog you can do:

i=4'b1010;

to assign a 4 bit binary number to an integer.

Regards,

Andrew.

Title: Re: using binary numbers in VerilogA
Post by hali on Feb 15th, 2010, 9:25am

thanks pancho.Ur reply really helped me a lot:)thanks once again

Title: Re: using binary numbers in VerilogA
Post by pancho_hideboo on Feb 15th, 2010, 9:26am


Andrew Beckett wrote on Feb 15th, 2010, 9:23am:
Slightly confused by Pancho Hideboo's response, as in Verilog you can do:
i=4'b1010;
to assign a 4 bit binary number to an integer.
This is not valid for Verilog-A.

Title: Re: using binary numbers in VerilogA
Post by Andrew Beckett on Feb 15th, 2010, 9:32am

And you can do this in VerilogAMS (not spectre's VerilogA though):


Code:
analog begin
   @(initial_step) i=4'b1011;
...


Regards,

Andrew.

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