VHDL Beginner: Reset a counter (instead of "000000000....000000") - better way ?

May 09, 2004 7 Replies

Hello,



i have a counter which is 27 bit long.



signal counter : STD_LOGIC_VECTOR(26 downto 0);



Is there a "better" way to reset than counter


Martin,

If your signal "counter" is declared as an integer with a valid range you can then use a reset as shown:

signal counter : integer range 0 to 67108863 := 0; ... if reset = '0' then signal counter Hello,

Allan & Jason B. show the typical ways; alternatively, if you are using numeric_std, you could write:

counter

Personally, if I'm doing a counter I would use an unsigned type (or even an integer!) rather than "casting" to std_logic_vector all the time. After all, what you're representing is a number...

Cheers, Martin

martin.j.thompson@trw.com TRW Conekt, Solihull, UK http://www.trw.com/conekt

Hi,

Here's a different but similar question: Is there a better way to do the following (vector extension):

signal A,B: std_logic_vector(10 downto 0); signal X: std_logic_vector( 7 downto 0);

A Jason T. Wright

--

--Ray Andraka, P.E. President, the Andraka Consulting Group, Inc.

401/884-7930 Fax 401/884-7950 email snipped-for-privacy@andraka.com
formatting link

"They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin, 1759

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required