How to compute 2^N in VHDL?

Discussion in 'VHDL' started by Fabio G., May 30, 2004.

  1. Fabio G.

    Fabio G. Guest

    In my design I have a parametrizable counter.
    Then I use a package to define the number of bits of the counter:

    constant Nbit_cont : integer :=8;

    I also need to define the value of the max countable value+1:

    For example, if Nbit_cont is 8, then I define:

    constant Count_max : integer :=256;

    But I'd want to make this last assignment dependent from the constant
    Nbit_cont, with an expression like this:

    constant Count_max : integer :=2^Nbit_cont;

    ....but the " ^ " operator is not recognized by my VHDL compiler.
    Is there a solution to this problem?


    --
    Per rispondermi via email sostituisci il risultato
    dell'operazione (in lettere) dall'indirizzo
    -*-
    To reply via email write the correct sum (in letters)
    in the email address
     
    Fabio G., May 30, 2004
    #1
    1. Advertising

  2. In VHDL there is no ^ operator; It's **, so 2**Nbit_cont should do the
    trick.

    Greetings,
    CM Wintersteiger

    On Sun, 30 May 2004 20:39:46 GMT, (Fabio G.) wrote:

    >In my design I have a parametrizable counter.
    >Then I use a package to define the number of bits of the counter:
    >
    >constant Nbit_cont : integer :=8;
    >
    >I also need to define the value of the max countable value+1:
    >
    >For example, if Nbit_cont is 8, then I define:
    >
    >constant Count_max : integer :=256;
    >
    >But I'd want to make this last assignment dependent from the constant
    >Nbit_cont, with an expression like this:
    >
    >constant Count_max : integer :=2^Nbit_cont;
    >
    >...but the " ^ " operator is not recognized by my VHDL compiler.
    >Is there a solution to this problem?
     
    Christoph M. Wintersteiger, May 30, 2004
    #2
    1. Advertising

  3. Hi.

    Left-Shift by N will do the trick.

    Cheers,

    Hernán Sánchez

    "Fabio G." <> escribió en el mensaje
    news:...
    > In my design I have a parametrizable counter.
    > Then I use a package to define the number of bits of the counter:
    >
    > constant Nbit_cont : integer :=8;
    >
    > I also need to define the value of the max countable value+1:
    >
    > For example, if Nbit_cont is 8, then I define:
    >
    > constant Count_max : integer :=256;
    >
    > But I'd want to make this last assignment dependent from the constant
    > Nbit_cont, with an expression like this:
    >
    > constant Count_max : integer :=2^Nbit_cont;
    >
    > ...but the " ^ " operator is not recognized by my VHDL compiler.
    > Is there a solution to this problem?
    >
    >
    > --
    > Per rispondermi via email sostituisci il risultato
    > dell'operazione (in lettere) dall'indirizzo
    > -*-
    > To reply via email write the correct sum (in letters)
    > in the email address
     
    Hernán Sánchez, May 31, 2004
    #3
  4. Fabio G.

    Fabio G. Guest

    Christoph M. Wintersteiger <> ha scritto:

    >In VHDL there is no ^ operator; It's **, so 2**Nbit_cont should do the
    >trick.


    Ok, it works!

    --
    Per rispondermi via email sostituisci il risultato
    dell'operazione (in lettere) dall'indirizzo
     
    Fabio G., May 31, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2tpcmtieQ==?=

    Problem using COMPUTE with SPROC on ASP Application

    =?Utf-8?B?c2tpcmtieQ==?=, Nov 1, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    308
    Scott Allen
    Nov 1, 2004
  2. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.Web.HttpException: Cannot compute Count for a data source t

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    5,646
    Scott Allen
    Nov 5, 2004
  3. Replies:
    0
    Views:
    321
  4. afd
    Replies:
    1
    Views:
    8,552
    Colin Paul Gloster
    Mar 23, 2007
  5. PerlFAQ Server
    Replies:
    0
    Views:
    286
    PerlFAQ Server
    Feb 2, 2011
Loading...

Share This Page