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.

Counter inferred from VHDL

Status
Not open for further replies.

kingslayer

Member level 4
Joined
Jun 14, 2010
Messages
78
Helped
25
Reputation
48
Reaction score
24
Trophy points
1,288
Location
Milano, Italy
Activity points
1,827
Dear all,

suppose I want to increment a value at each clock-cycle in VHDL. I can do the following, in which I omitted initial and declarations:

Code:
-- [...]
signal counter : std_logic_vector(3 downto 0);
-- [...]

COUNT_UP_PROCESS : process (clk_i,rst_i) is
begin
   if rst_i='1' then
      counter <= (others => '0');
   else
      if clk_i'event and clk_i='1' then
         counter <= counter + 1;
      end if;
   end if;
end process COUNT_UP_PROCESS;

I guess that the synthesis tool is able to recognize a counter, but I have a doubt: the counter value I want is 4-bits wide, thus it takes values up to 15 inclusive; during functional simulation (e.g., using NCSim from Cadence), the value of the counter gets correctly reset to 0 every 16 clock-cycles.

My question is: will this functionality be preserved in the final implementation? I mean, is the synthesis tool able to add any extra logic to recognize and manage overflow situations? Or should I put this logic explicitely in the design?

Thanks for your attention
Cheers
 

the code will work without any problems. The counter will reset automatically to 0 after 15.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top