matrixofdynamism
Advanced Member level 2
- Joined
- Apr 17, 2011
- Messages
- 593
- Helped
- 24
- Reputation
- 48
- Reaction score
- 23
- Trophy points
- 1,298
- Activity points
- 7,681
Library ieee;
use ieee.std_logic_1164.all ;
use ieee.numeric_std.all;
Entity generic_tmr is
Generic
( G_TMR_TC := C_TMR_DEFAULT_TC; -- Threshold count value
G_TMR_SIZE:= C_TMR_DEFAULT_SIZE); -- size in bits
Port
(i_clk : in std_logic;
i_rst : in _std_logic;
i_en : in std_logic;
o_tc : out std_logic);
end generic_tmr;
Architecture rtl of generic_tmr is
s_tmr : unsigned(G_TMR_LEN - 1 downto 0);
begin
P_TMR: process(i_clk)
begin
if (i_clk'event and i_clk = '1') then
if (i_rst = '1') then
s_tmr <= (others => '0');
o_tc <= '1';
else
o_tc <= '0';
if (i_en = '1') then
if (s_tmr < to_unsigned(G_TMR_LEN, G_TMR_SIZE)) then
s_tmr <= s_tmr + 1;
else
s_tmr <= (others => '0');
o_tc <= '1';
end if;
end if;
end if;
end if;
end process P_TMR;
end rtl;
A method to avoid big timers is to use that clock enable (i_en in the VHDL code above) so that it is a pulsed signal with the time resolution of your timer.
What does that mean?
To be more dramatic than the 8 bit timer example exposed by axcdd. Suppose you want to count 1 ms and your FPGA has a 50 MHz clock.
Your timer should count up to 500.00. The next value logic of your timer should be of 16 bits. Many FPGAs (Cyclone II, Spartan 3) will find trouble fitting the logic at this frequency.
Exactly for that, nothing else. If you absolutely need floating point then you should get a IEEE 754 floating point IP core and use that.thanks dude, I just spent some tens of minutes searching about what this is used for on google.
I assume that we can use this for the purpose of testbenches and constants in RTL code?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?