Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to do a 48 bits counter in VHDL ?

Status
Not open for further replies.

voho

Full Member level 2
Joined
Feb 24, 2004
Messages
121
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,298
Location
Nador City
Activity points
852
counter in vhdl

Hi all,

how to do a counter 48 bits in vhdl because when i test my code i observed this problem:

hex:00 00 00 00 00 00
.....................
.....................
01 FF FF FF FF FF :eek:k
01 00 00 00 00 00 :error
02 00 00 00 00 00 :eek:k

it's a problem of carry i think?
 

counter in vhdl

It's something like this:

Code:
signal cnt, cnt_nxt : std_logic_vector(47 downto 0);
begin
  process (clk_i, reset_n_i) begin
    if reset_n_i = '0' then
      cnt      <= 0;
    elsif clk_i'event and clk_i = '1' then
      cnt      <= cnt_nxt;
    end if;
  end process;

  cnt_nxt <= cnt + 1;

end beh;
 

Re: counter in vhdl

cube007 said:
It's something like this:

Code:
signal cnt, cnt_nxt : std_logic_vector(47 downto 0);
begin
  process (clk_i, reset_n_i) begin
    if reset_n_i = '0' then
      cnt      <= 0;
    elsif clk_i'event and clk_i = '1' then
      cnt      <= cnt_nxt;
    end if;
  end process;

  cnt_nxt <= cnt + 1;



ok... you'd better write some GOOD vhdl!

first... put the numeric_std library on line.. =>  use ieee.numeric_std.all;

then the counter will be like this...

cpt_int is a signal 48 bits or what you want...;
cpt_out the output of the counter

process (raz, clk)
begin
if raz='1' then cpt_int<= (others => '0');
elsif rising_edge(clk)
then 
if cpt_int= x"FFFFFFFFFFFF" then cpt_int<= (others =>'0'); --optional line (for simu!)
else cpt_int<=std_logic_vector(unsigned(cpt_int)+1);
end if;
end if;
end process;
cpt_out<=cpt_int;

that's all
good vhdl!


end beh;
 

Re: counter in vhdl

Best way to design such a big counter is to divide it into smaller
counters. This will make counter hardware testing possble and easy!
Try to build 16 bit counter and instantiate it thrice to get 48 bit counter!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top