-- $Header: /devl/xcs/repo/env/Databases/CAEInterfaces/vhdsclibs/data/simprims/simprim/VITAL/X_IBUFDS.vhd,v 1.5 2012/09/13 23:10:58 robh Exp $
-------------------------------------------------------------------------------
-- Copyright (c) 1995/2004 Xilinx, Inc.
-- All Right Reserved.
-------------------------------------------------------------------------------
--   ____  ____
--  /   /\/   /
-- /___/  \  /    Vendor : Xilinx
-- \   \   \/     Version : 11.1
--  \   \         Description : Xilinx Timing Simulation Library Component
--  /   /                  Differential Signaling Input Buffer
-- /___/   /\     Filename : X_IBUFDS.vhd
-- \   \  /  \    
--  \___\/\___\
--
-- Revision:
--    03/23/04 - Initial version.
--    07/21/05 - CR 212974 -- matched unisim parameters as requested by other tools
--    01/10/06 - CR 222428 -- added H(pullup) and L(pulldown) usage
--    07/19/06 - Add else to handle x case for o_out (CR 234718).
--    08/29/12 - 675332 - add parameter DQS_BIAS and functionality
--    09/11/12 - 677753 - remove X glitch on O
-- End Revision

----- CELL X_IBUFDS -----

library IEEE;
use IEEE.STD_LOGIC_1164.all;

library IEEE;
use IEEE.Vital_Primitives.all;
use IEEE.Vital_Timing.all;

entity X_IBUFDS is
  generic(
    Xon   : boolean := true;
    MsgOn : boolean := true;

    LOC   : string  := "UNPLACED";
    CAPACITANCE : string  := "DONT_CARE";
    DIFF_TERM   : boolean :=  FALSE;
    DQS_BIAS    : string :=  "FALSE";
    IBUF_DELAY_VALUE : string := "0";
    IFD_DELAY_VALUE  : string := "AUTO";
    IOSTANDARD  : string  := "DEFAULT";

    tipd_I : VitalDelayType01 := (0.000 ns, 0.000 ns);
    tipd_IB : VitalDelayType01 := (0.000 ns, 0.000 ns);

    tpd_IB_O : VitalDelayType01 := (0.000 ns, 0.000 ns);
    tpd_I_O : VitalDelayType01 := (0.000 ns, 0.000 ns)
    );

  port(
    O : out std_ulogic;

    I  : in std_ulogic;
    IB : in std_ulogic
    );

  attribute VITAL_LEVEL0 of
    X_IBUFDS : entity is true;
end X_IBUFDS;

architecture X_IBUFDS_V of X_IBUFDS is
  attribute VITAL_LEVEL0 of
    X_IBUFDS_V : architecture is true;

  signal O_zd   : std_ulogic := 'X';
  signal I_ipd  : std_ulogic := 'X';
  signal IB_ipd : std_ulogic := 'X';

  signal DQS_BIAS_BINARY : std_ulogic := '0';
begin

  WireDelay : block
  begin
    VitalWireDelay (I_ipd, I, tipd_I);
    VitalWireDelay (IB_ipd, IB, tipd_IB);
  end block;

  prcs_init : process
  variable FIRST_TIME        : boolean    := TRUE;
  begin

     if (FIRST_TIME = true) then
        FIRST_TIME := false;

        if (DQS_BIAS = "TRUE") then
           DQS_BIAS_BINARY <= '1';
        elsif (DQS_BIAS = "FALSE")  then
           DQS_BIAS_BINARY <= '0';
        else
           assert false
           report "Attribute Syntax Error: The Legal values for DQS_BIAS are TRUE or FALSE"
           severity Failure;
        end if;
--   
     end if;

     wait;
  end process prcs_init;

  Behavior : process (I_ipd, IB_ipd, DQS_BIAS_BINARY)
  begin
    if  (((I_ipd = '1') or (I_ipd = 'H')) and ((IB_ipd = '0') or (IB_ipd = 'L'))) then
      O_zd <= '1';
    elsif (((I_ipd = '0') or (I_ipd = 'L')) and ((IB_ipd = '1') or (IB_ipd = 'H'))) then
      O_zd <= '0';
    elsif ((I_ipd = 'Z' or I_ipd = '0' or I_ipd = 'L') and (IB_ipd = 'Z' or IB_ipd = '1' or IB_ipd = 'H')) then
      if (DQS_BIAS_BINARY = '1') then
        O_zd <= '0';
      else
        O_zd <= 'X';
      end if;
    elsif ((I_ipd = 'X') or (IB_ipd = 'X')) then
      O_zd <= 'X';
    end if;
  end process Behavior;

  prcs_timing : process
    variable O_GlitchData : VitalGlitchDataType;
    begin
    VitalPathDelay01 (
      OutSignal                 => O,
      GlitchData                => O_GlitchData,
      OutSignalName             => "O",
      OutTemp                   => O_zd,
      Paths                     => (0 => (I_ipd'last_event, tpd_I_O, true),
                                    1 => (IB_ipd'last_event, tpd_IB_O, true)),
      Mode                      => VitalTransport,
      Xon                       => Xon,
      MsgOn                     => MsgOn,
      MsgSeverity               => warning);

  wait on O_zd;
  end process prcs_timing;

end X_IBUFDS_V;
