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

Reply

VHDL - 64 bit counter with shift

 
Thread Tools Search this Thread
Old 10-21-2004, 10:11 AM   #1
Default 64 bit counter with shift


Hi there,

I want to have a 64 bit counter, which overflows (return to 0) if it
reaches its limit. Also, I want to do some schift operations with this
counter.

My question is, if there is a predefined 64 bit type or if I have to
implement the counter manually with four integers (they are 16 bit wide,
aren't they?).
For the shifter: I don't have a specific device yet, and I wonder if the
compiler get it right with the "srl"-operator or if it is better to multiply
the value.

I am pretty new to vhdl, so hopefully this is quite easy to do..

And by the way, are there any online sources where I can view the contents
of the ieee-libraries?? If I search the IEEE-site I get too many hits.

Many thanks,
Stephan




Stephan Mueller
  Reply With Quote
Old 10-21-2004, 02:26 PM   #2
Marcus Schaemann
 
Posts: n/a
Default Re: 64 bit counter with shift
Stephan Mueller schrieb:
> Hi there,
>
> I want to have a 64 bit counter, which overflows (return to 0) if it
> reaches its limit. Also, I want to do some schift operations with this
> counter.
>
> My question is, if there is a predefined 64 bit type or if I have to
> implement the counter manually with four integers (they are 16 bit wide,
> aren't they?).
> For the shifter: I don't have a specific device yet, and I wonder if the
> compiler get it right with the "srl"-operator or if it is better to multiply
> the value.
>
> I am pretty new to vhdl, so hopefully this is quite easy to do..
>
> And by the way, are there any online sources where I can view the contents
> of the ieee-libraries?? If I search the IEEE-site I get too many hits.
>
> Many thanks,
> Stephan
>
>


Hi Stephan,

the easiest way might be the use of a std_logic_vector with 64 bits.
With vectors shifting becomes very easy.

Btw, as far as I know integers are 32 bits wide (at least Synopsys
synthesizes them to be 32 bits if you don't specify a range).

You can find the IEEE libraries on the website of the Hamburg VHDL library:

http://tech-www.informatik.uni-hamburg.de/vhdl/

They have links to several textbooks there as well (even in german

Regards,

Marcus


Marcus Schaemann
  Reply With Quote
Old 10-21-2004, 02:32 PM   #3
Mike Treseler
 
Posts: n/a
Default Re: 64 bit counter with shift
Stephan Mueller wrote:

> I want to have a 64 bit counter, which overflows (return to 0) if it
> reaches its limit.


Consider using unsigned. It overflows as default.

> Also, I want to do some schift operations with this counter.


ieee.numeric_std has shifts for unsigned.

> My question is, if there is a predefined 64 bit type or if I have to
> implement the counter manually with four integers (they are 16 bit wide,
> aren't they?).


Integers are often 32 bits.
Consider unsigned instead.

> For the shifter: I don't have a specific device yet, and I wonder if the
> compiler get it right with the "srl"-operator or if it is better to multiply
> the value.


Consider numeric_std.shift_left or numeric_std.sll

> I am pretty new to vhdl, so hopefully this is quite easy to do..


Once you know how to do it, it's quite easy.

> And by the way, are there any online sources where I can view the contents
> of the ieee-libraries?? If I search the IEEE-site I get too many hits.

see:
http://www.eda.org/vhdl-200x/vhdl-20...ges/files.html

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 10-21-2004, 03:25 PM   #4
Stephan Mueller
 
Posts: n/a
Default Re: 64 bit counter with shift
Hi Marcus,

thanks for the link and I did it with a std_logic_vector..

Dankeschoen

Stephan




Stephan Mueller
  Reply With Quote
Old 10-21-2004, 07:08 PM   #5
Rob Young
 
Posts: n/a
Default Re: 64 bit counter with shift
"Stephan Mueller" <> wrote in message news:<>...
> Hi there,
>
> I want to have a 64 bit counter, which overflows (return to 0) if it
> reaches its limit. Also, I want to do some schift operations with this
> counter.
>
> My question is, if there is a predefined 64 bit type or if I have to
> implement the counter manually with four integers (they are 16 bit wide,
> aren't they?).
> For the shifter: I don't have a specific device yet, and I wonder if the
> compiler get it right with the "srl"-operator or if it is better to multiply
> the value.
>
> I am pretty new to vhdl, so hopefully this is quite easy to do..
>
> And by the way, are there any online sources where I can view the contents
> of the ieee-libraries?? If I search the IEEE-site I get too many hits.
>
> Many thanks,
> Stephan


I tried this with the QuartusII web edition and it compiled and fit an
APEX20K part. Didn't try and shifting operations.


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity counter is
port (
clock : in std_logic;
clear : in std_logic;
count : in std_logic;
Q : out std_logic_vector(63 downto 0)
);
end counter;

architecture behavorial of counter is
signal tempQ : std_logic_vector(63 downto 0);
begin
process(clock, clear, count)
begin
if clear='1' then
tempQ <= (others => '0');
elsif (clock'event and clock='1') then
if count = '1' then
tempQ <= tempQ + 1;
end if;
end if;
end process;
Q <= tempQ;
end behavorial;

Rob Young



Rob Young
  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
VHDL sll shift question ohaqqi Hardware 4 09-29-2009 11:27 AM
The Counter Strikes... aihockey44 Gaming 0 04-29-2009 08:35 PM
divide by n counter (with n as variable) rnpatil Hardware 0 04-27-2009 12:42 PM
VHDL problem - Signal counter cannot be synthesized, bad synchronous description. shipacpoloy Software 0 08-14-2007 07:26 AM
Resetting The Counter. Patrick D. Rockwell DVD Video 3 07-09-2004 10:32 PM




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