Velocity Reviews > VHDL > How to compute 2^N in VHDL?

# How to compute 2^N in VHDL?

Fabio G.
Guest
Posts: n/a

 05-30-2004
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)

Christoph M. Wintersteiger
Guest
Posts: n/a

 05-30-2004

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, (E-Mail Removed) (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?

Hernán Sánchez
Guest
Posts: n/a

 05-31-2004
Hi.

Left-Shift by N will do the trick.

Cheers,

Hernán Sánchez

"Fabio G." <(E-Mail Removed)> escribió en el mensaje
news:(E-Mail Removed)...
> 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)

Fabio G.
Guest
Posts: n/a

 05-31-2004
Christoph M. Wintersteiger <(E-Mail Removed)> 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

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post PerlFAQ Server Perl Misc 0 02-02-2011 05:00 AM gadget_guru_@hotmail.com ASP .Net 0 11-17-2005 09:53 AM bronby Java 4 06-03-2005 08:42 AM =?Utf-8?B?UGF0cmljay5PLklnZQ==?= ASP .Net 4 11-05-2004 02:00 AM =?Utf-8?B?c2tpcmtieQ==?= ASP .Net 1 11-01-2004 12:55 PM