-------------------------------------------------------------------------
-- Project: MIPS System controller
-- This file: 
--
-- Copyright (C) 2008 J. Ahrensfeld
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- For questions and ideas, please contact the author at jens@jayfield.org
--
--------------------------------------------------------------------------

library IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.NUMERIC_STD.ALL;
USE IEEE.MATH_REAL.ALL;

package async_types is

	type async_timespec_t is record
		T_leadin			: real;
		T_pulse_rd			: real;
		T_pulse_wr			: real;
		T_leadout			: real;
		T_release			: real;
		T_pulse_rst			: real;
		T_pulse_page_rd		: real;
		can_page_rd			: boolean;
		nbits_page_rd		: natural;
		pol_cs				: std_logic;
		pol_oe				: std_logic;
		pol_we				: std_logic;
		pol_be				: std_logic;
		pol_rst				: std_logic;
	end record;

	function to_cycles(T_ns : real; f_Mhz : real) return natural;

end async_types;

package body async_types is

	function to_cycles(T_ns : real; f_Mhz : real) return natural is
	begin
		
		return natural(ceil(1.0E-3*T_ns*f_Mhz));

	end to_cycles;	
end async_types;
