Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - How to compute 2^N in VHDL?

 
Thread Tools Search this Thread
Old 05-30-2004, 09:39 PM   #1
Default How to compute 2^N in VHDL?


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.
  Reply With Quote
Old 05-30-2004, 10:27 PM   #2
Christoph M. Wintersteiger
 
Posts: n/a
Default Re: How to compute 2^N in VHDL?

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+ (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
  Reply With Quote
Old 05-31-2004, 12:25 PM   #3
Hernán Sánchez
 
Posts: n/a
Default Re: How to compute 2^N in VHDL?
Hi.

Left-Shift by N will do the trick.

Cheers,

Hernán Sánchez

"Fabio G." <7+> 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
  Reply With Quote
Old 05-31-2004, 07:55 PM   #4
Fabio G.
 
Posts: n/a
Default Re: How to compute 2^N in VHDL?
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.
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute an external software from VHDL? And how to interface VHDL with JAVA? becool_nikks Software 0 03-06-2009 07:08 PM
Help on auto conversion from Matlab to vhdl on filter design hardheart Hardware 0 12-07-2007 09:19 AM
VHDL RAM help!:) lastval Hardware 0 11-09-2007 01:40 PM
ARRAY(n DOWNTO 0) OF STD_LOGIC_VECTOR(m DOWNTO 0) - VHDL freitass Hardware 0 11-01-2007 03:44 PM
vhdl code amirster Hardware 0 05-10-2007 07:28 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46