How to compute 2^N in VHDL?

F

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
 
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, 7+5@supereva.it (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?
 
Hi.

Left-Shift by N will do the trick.

Cheers,

Hernán Sánchez

"Fabio G." <7+5@supereva.it> escribió en el mensaje
news:40b9e6fc.14039214@powernews.inwind.it...
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
 
Christoph M. Wintersteiger <christoph@winterstiger.at> 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
 

Welcome to EDABoard.com

Sponsor

Back
Top