Line 20... |
Line 20... |
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
--
|
--
|
-- VHDL Units : o8_sys_timer
|
-- VHDL Units : o8_sys_timer
|
-- Description: Provides an 8-bit microsecond resolution timer for generating
|
-- Description: Provides an 24-bit microsecond resolution timer for generating
|
-- : periodic interrupts for the Open8 CPU.
|
-- : periodic interrupts for the Open8 CPU.
|
--
|
--
|
-- Register Map:
|
-- Register Map:
|
-- Offset Bitfield Description Read/Write
|
-- Offset Bitfield Description Read/Write
|
-- 0x00 AAAAAAAA Req Interval Byte 0 (RW)
|
-- 0x00 AAAAAAAA Req Interval Byte 0 (RW)
|
Line 45... |
Line 45... |
-- Seth Henry 04/09/20 Modified timer update logic to reset the timer on
|
-- Seth Henry 04/09/20 Modified timer update logic to reset the timer on
|
-- interval write.
|
-- interval write.
|
-- Seth Henry 04/16/20 Modified to use Open8 bus record
|
-- Seth Henry 04/16/20 Modified to use Open8 bus record
|
-- Seth Henry 04/17/20 Altered interval to be a 24-bit counter
|
-- Seth Henry 04/17/20 Altered interval to be a 24-bit counter
|
-- Seth Henry 05/18/20 Added write qualification input
|
-- Seth Henry 05/18/20 Added write qualification input
|
|
-- Seth Henry 01/18/23 Added microsecond/millisecond generic
|
|
|
|
|
library ieee;
|
library ieee;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_1164.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_arith.all;
|
use ieee.std_logic_arith.all;
|
Line 57... |
Line 59... |
library work;
|
library work;
|
use work.open8_pkg.all;
|
use work.open8_pkg.all;
|
|
|
entity o8_sys_timer_ii is
|
entity o8_sys_timer_ii is
|
generic(
|
generic(
|
|
mSec_Resolution : boolean := FALSE;
|
Address : ADDRESS_TYPE
|
Address : ADDRESS_TYPE
|
);
|
);
|
port(
|
port(
|
Open8_Bus : in OPEN8_BUS_TYPE;
|
Open8_Bus : in OPEN8_BUS_TYPE;
|
Write_Qual : in std_logic := '1';
|
Write_Qual : in std_logic := '1';
|
Line 99... |
Line 102... |
signal Update_Interval : std_logic := '0';
|
signal Update_Interval : std_logic := '0';
|
signal Update_Pending : std_logic := '0';
|
signal Update_Pending : std_logic := '0';
|
signal Output_Enable : std_logic := '0';
|
signal Output_Enable : std_logic := '0';
|
signal Timer_Cnt : std_logic_vector(23 downto 0) := x"000000";
|
signal Timer_Cnt : std_logic_vector(23 downto 0) := x"000000";
|
|
|
|
constant MSEC_DELAY : std_logic_vector(9 downto 0) :=
|
|
conv_std_logic_vector(1000,10);
|
|
|
|
signal mSec_Timer : std_logic_vector(9 downto 0) := (others => '0');
|
|
|
|
signal Timer_Tick : std_logic := '0';
|
|
|
begin
|
begin
|
|
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
Addr_Match <= '1' when Comp_Addr = User_Addr else '0';
|
Wr_En_d <= Addr_Match and Open8_Bus.Wr_En;
|
Wr_En_d <= Addr_Match and Open8_Bus.Wr_En;
|
Rd_En_d <= Addr_Match and Open8_Bus.Rd_En;
|
Rd_En_d <= Addr_Match and Open8_Bus.Rd_En;
|
|
|
|
mSec_Resolution_enabled : if( mSec_Resolution )generate
|
|
|
|
mSec_Tick_proc: process( Clock, Reset )
|
|
begin
|
|
if( Reset = Reset_Level )then
|
|
mSec_Timer <= (others => '0');
|
|
Timer_Tick <= '0';
|
|
elsif( rising_edge(Clock) )then
|
|
mSec_Timer <= mSec_Timer - uSec_Tick;
|
|
Timer_Tick <= '0';
|
|
if( mSec_Timer = 0 )then
|
|
mSec_Timer <= MSEC_DELAY;
|
|
Timer_Tick <= '1';
|
|
end if;
|
|
end if;
|
|
end process;
|
|
|
|
end generate;
|
|
|
|
uSec_Resolution_enabled : if( not mSec_Resolution )generate
|
|
|
|
Timer_Tick <= uSec_Tick;
|
|
|
|
end generate;
|
|
|
io_reg: process( Clock, Reset )
|
io_reg: process( Clock, Reset )
|
begin
|
begin
|
if( Reset = Reset_Level )then
|
if( Reset = Reset_Level )then
|
Reg_Sel_q <= "00";
|
Reg_Sel_q <= "00";
|
Wr_En_q <= '0';
|
Wr_En_q <= '0';
|
Line 171... |
Line 206... |
Int_Interval <= x"000000";
|
Int_Interval <= x"000000";
|
Timer_Cnt <= x"000000";
|
Timer_Cnt <= x"000000";
|
Interrupt <= '0';
|
Interrupt <= '0';
|
elsif( rising_edge(Clock) )then
|
elsif( rising_edge(Clock) )then
|
Interrupt <= '0';
|
Interrupt <= '0';
|
Timer_Cnt <= Timer_Cnt - uSec_Tick;
|
Timer_Cnt <= Timer_Cnt - Timer_Tick;
|
if( Update_Interval = '1' )then
|
if( Update_Interval = '1' )then
|
Int_Interval <= Req_Interval;
|
Int_Interval <= Req_Interval;
|
Timer_Cnt <= Req_Interval;
|
Timer_Cnt <= Req_Interval;
|
elsif( or_reduce(Timer_Cnt) = '0' )then
|
elsif( or_reduce(Timer_Cnt) = '0' )then
|
Timer_Cnt <= Int_Interval;
|
Timer_Cnt <= Int_Interval;
|