The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 2nd, 2024, 7:42am
Pages: 1
Send Topic Print
using binary numbers in VerilogA (Read 10169 times)
hali
New Member
*
Offline



Posts: 6

using binary numbers in VerilogA
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? Embarrassed
Back to top
 
 
View Profile   IP Logged
pancho_hideboo
Senior Fellow
******
Offline



Posts: 1424
Real Homeless
Re: using binary numbers in VerilogA
Reply #1 - 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


Back to top
 
« Last Edit: Feb 12th, 2010, 8:57am by pancho_hideboo »  
View Profile WWW Top+Secret Top+Secret   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: using binary numbers in VerilogA
Reply #2 - 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.
Back to top
 
 
View Profile WWW   IP Logged
hali
New Member
*
Offline



Posts: 6

Re: using binary numbers in VerilogA
Reply #3 - Feb 15th, 2010, 9:25am
 
thanks pancho.Ur reply really helped me a lot:)thanks once again
Back to top
 
 
View Profile   IP Logged
pancho_hideboo
Senior Fellow
******
Offline



Posts: 1424
Real Homeless
Re: using binary numbers in VerilogA
Reply #4 - 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.
Back to top
 
 
View Profile WWW Top+Secret Top+Secret   IP Logged
Andrew Beckett
Senior Fellow
******
Offline

Life, don't talk to
me about Life...

Posts: 1742
Bracknell, UK
Re: using binary numbers in VerilogA
Reply #5 - 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.
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.