/*
 *
 * Copyright © 1996 Norlinvest Ltd. All rights reserved.
 * EDComX, EDSpice, EDWin, EE Designer, CompCAD, CAD 1000,
 * CAD ABC and Visionics are trade marks of Norlinvest Ltd.
 * Copyright © 1983 - 2002.
 *
 */

#include "LprimEx.h"

void fnVhdlAnd2(int Input1, int Input2, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlAnd3(int Input1, int Input2, int Input3, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlAnd4(int Input1, int Input2, int Input3, int Input4, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && 
      PEEK(Input3) == HIGH && PEEK(Input4) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlAnd5(int Input1, int Input2, int Input3, int Input4, int Input5,
                int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd6 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd7 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd8 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd9 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd10 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd11 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd12 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd13 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd14 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH && PEEK(Input14) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd15 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH && PEEK(Input14) == HIGH && PEEK(Input15) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlAnd16 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Input16, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH && PEEK(Input14) == HIGH && PEEK(Input15) == HIGH &&
      PEEK(Input16) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlNand2(int Input1, int Input2, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlNand3(int Input1, int Input2, int Input3, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlNand4(int Input1, int Input2, int Input3, int Input4, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && 
      PEEK(Input3) == HIGH && PEEK(Input4) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand5(int Input1, int Input2, int Input3, int Input4, int Input5,
                 int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand6 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand7 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand8 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand9 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand10 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand11 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand12 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand13 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand14 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH && PEEK(Input14) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand15 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH && PEEK(Input14) == HIGH && PEEK(Input15) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNand16 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Input16, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
      PEEK(Input4) == HIGH && PEEK(Input5) == HIGH && PEEK(Input6) == HIGH &&
      PEEK(Input7) == HIGH && PEEK(Input8) == HIGH && PEEK(Input9) == HIGH &&
      PEEK(Input10) == HIGH && PEEK(Input11) == HIGH && PEEK(Input12) == HIGH &&
      PEEK(Input13) == HIGH && PEEK(Input14) == HIGH && PEEK(Input15) == HIGH &&
      PEEK(Input16) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlOr2(int Input1, int Input2, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlOr3(int Input1, int Input2, int Input3, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlOr4(int Input1, int Input2, int Input3, int Input4, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || 
      PEEK(Input3) == HIGH || PEEK(Input4) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlOr5(int Input1, int Input2, int Input3, int Input4, int Input5,
               int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlOr6 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr7 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr8 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr9 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr10 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr11 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr12 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr13 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr14 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH || PEEK(Input14) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr15 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH || PEEK(Input14) == HIGH || PEEK(Input15) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlOr16 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Input16, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH || PEEK(Input14) == HIGH || PEEK(Input15) == HIGH ||
      PEEK(Input16) == HIGH)
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}


void fnVhdlNor2(int Input1, int Input2, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlNor3(int Input1, int Input2, int Input3, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlNor4(int Input1, int Input2, int Input3, int Input4, int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || 
      PEEK(Input3) == HIGH || PEEK(Input4) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlNor5(int Input1, int Input2, int Input3, int Input4, int Input5,
                int Output, float tLH, float tHL)
{
   if(PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor6 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor7 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor8 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor9 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor10 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor11 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor12 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor13 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor14 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH || PEEK(Input14) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor15 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH || PEEK(Input14) == HIGH || PEEK(Input15) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlNor16 (int Input1, int Input2, int Input3, int Input4, int Input5, int Input6, int Input7, int Input8, int Input9, int Input10, int Input11, int Input12, int Input13, int Input14, int Input15, int Input16, int Output, float tLH, float tHL)
{
   if (PEEK(Input1) == HIGH || PEEK(Input2) == HIGH || PEEK(Input3) == HIGH ||
      PEEK(Input4) == HIGH || PEEK(Input5) == HIGH || PEEK(Input6) == HIGH ||
      PEEK(Input7) == HIGH || PEEK(Input8) == HIGH || PEEK(Input9) == HIGH ||
      PEEK(Input10) == HIGH || PEEK(Input11) == HIGH || PEEK(Input12) == HIGH ||
      PEEK(Input13) == HIGH || PEEK(Input14) == HIGH || PEEK(Input15) == HIGH ||
      PEEK(Input16) == HIGH)
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}


void fnVhdlXor2(int Input1, int Input2, int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW))
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlXor3(int Input1, int Input2, int Input3, int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW  && PEEK(Input3) == LOW))
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlXor4(int Input1, int Input2, int Input3, int Input4, int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
       PEEK(Input4) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW  && PEEK(Input3) == LOW  &&
       PEEK(Input4) == LOW))
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlXor5(int Input1, int Input2, int Input3, int Input4, int Input5,
                int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
       PEEK(Input4) == HIGH && PEEK(Input5) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW  && PEEK(Input3) == LOW  &&
       PEEK(Input4) == LOW  && PEEK(Input5) == LOW))
      POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

void fnVhdlXnor2(int Input1, int Input2, int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW))
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlXnor3(int Input1, int Input2, int Input3, int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW  && PEEK(Input3) == LOW))
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlXnor4(int Input1, int Input2, int Input3, int Input4, int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
       PEEK(Input4) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW  && PEEK(Input3) == LOW  &&
       PEEK(Input4) == LOW))
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlXnor5(int Input1, int Input2, int Input3, int Input4, int Input5,
                 int Output, float tLH, float tHL)
{
   if((PEEK(Input1) == HIGH && PEEK(Input2) == HIGH && PEEK(Input3) == HIGH &&
       PEEK(Input4) == HIGH && PEEK(Input5) == HIGH) ||
      (PEEK(Input1) == LOW  && PEEK(Input2) == LOW  && PEEK(Input3) == LOW  &&
       PEEK(Input4) == LOW  && PEEK(Input5) == LOW))
      POKE_DRV(Output, HIGH, tLH, tHL);
   else
      POKE_DRV(Output, LOW, tLH, tHL);
}

// Tristate

void fnVhdlTristate(int Input, int Control, int Output, float tLH, float tHL,
                    float tLZ, float tHZ, float tZL, float tZH)
{
   if(PEEK_CHANGE(Control))
   {
      if(PEEK(Control) == HIGH)
      {
         POKE_DRV(Output, PEEK(Input), tZH, tZL);
      }
      else
      {
            POKE_ZIMP(Output, tLZ, tHZ);
      }
   }
   else
   {
      if(PEEK(Control) == HIGH)
      {
            POKE_DRV(Output, PEEK(Input), tLH, tHL);
      }
		else //rajesh added else part
		{
				POKE_ZIMP(Output, tLZ, tHZ);
		}
   }
}

void fnVhdlInverter(int Input, int Output, float tLH, float tHL)
{
   if(PEEK(Input) == HIGH) POKE_DRV(Output, LOW, tLH, tHL);
   else
      POKE_DRV(Output, HIGH, tLH, tHL);
}

// Latche

void fnVhdlLd(int Input, int Gate, int Output, float tLH, float tHL, float gLH, float gHL)
{
   if(PEEK(Gate) == HIGH)
   {
      if(PEEK_CHANGE(Gate))
         POKE_DRV(Output, PEEK(Input), gLH, gHL);
      else
         POKE_DRV(Output, PEEK(Input), tLH, tHL);
   }
}

// Buffer

void fnVhdlBuffer(int Input, int Output, float tLH, float tHL)
{
   POKE_DRV(Output, PEEK(Input), tLH, tHL);
}


// Flip-Flops

void fnVhdlDff (int Input, int Clock, int Clear, int Preset, int Output, float tLH, float tHL, float clrHL, float preLH)
{
   if (PEEK(Clear) == LOW)
      POKE_DRV(Output, LOW, clrHL, clrHL);
   else
      if (PEEK(Preset) == LOW)
         POKE_DRV(Output, HIGH, preLH, preLH);
      else
         if (PEEK_CHANGE(Clock) && PEEK(Clock) == HIGH)
            POKE_DRV(Output,  PEEK(Input), tLH, tHL);
}


void fnVhdlDffe (int Input, int Clock, int ClockEnable, int Clear, int Preset, int Output, float tLH, float tHL, float clrHL, float preLH)
{
   if (PEEK(Clear) == LOW)
      POKE_DRV(Output, LOW, clrHL, clrHL);
   else
      if (PEEK(Preset) == LOW)
         POKE_DRV(Output, HIGH, preLH, preLH);
      else
         if (PEEK_CHANGE(Clock) && PEEK(Clock) == HIGH && PEEK(ClockEnable) == HIGH)
            POKE_DRV(Output,  PEEK(Input), tLH, tHL);
}


void fnVhdlFd(int Input, int Clock, int Output, float tLH, float tHL)
{
   if(PEEK_CHANGE(Clock) && PEEK(Clock) == HIGH)
      POKE_DRV(Output,  PEEK(Input), tLH, tHL);
}


void fnVhdlFdc(int Input, int Clock, int Clear, int Output, float tLH, float tHL, float clrHL)
{
   if(PEEK(Clear) == HIGH)
   {
      POKE_DRV(Output, LOW, clrHL, clrHL);
   }
   else
      if(PEEK_CHANGE(Clock) && PEEK(Clock) == HIGH)
         POKE_DRV(Output,  PEEK(Input), tLH, tHL);
}

void fnVhdlFdp(int Input, int Clock, int Preset, int Output, float tLH, float tHL, float preLH)
{
   if(PEEK(Preset) == HIGH)
   {
      POKE_DRV(Output, HIGH, preLH, preLH);
   }
   else
      if(PEEK_CHANGE(Clock) && PEEK(Clock) == HIGH)
         POKE_DRV(Output,  PEEK(Input), tLH, tHL);
}

void fnVhdlFdcp(int Input, int Clock, int Clear, int Preset, int Output,
                float tLH, float tHL, float clrHL, float preLH)
{
   if(PEEK(Clear) == HIGH && PEEK(Preset) == LOW)
   {
      POKE_DRV(Output, LOW, clrHL, clrHL);
   }
   else
      if(PEEK(Clear) == LOW && PEEK(Preset) == HIGH)
      {
         POKE_DRV(Output, HIGH, preLH, preLH);
      }
      else
         if(PEEK(Clear) == HIGH && PEEK(Preset) == HIGH)
         {
            POKE_DRV(Output, HIGH, (float)1e-9, (float)1e-9);
         }
         else
            if(PEEK_CHANGE(Clock) && PEEK(Clock) == HIGH)
               POKE_DRV(Output,  PEEK(Input), tLH, tHL);
}

// Multiplexers

void fnVhdlMux2(int Input0, int Input1, int Select, int Output,
                float tLH, float tHL, float selLH, float selHL)
{
   if(PEEK_CHANGE(Select))
   {
      if(PEEK(Select) == LOW) POKE_DRV(Output, PEEK(Input0), selLH, selHL);
      else                    POKE_DRV(Output, PEEK(Input1), selLH, selHL);
   }
   else
   {
      if(PEEK_CHANGE(Input0) || PEEK_CHANGE(Input1))
      {
         if(PEEK(Select) == LOW) POKE_DRV(Output, PEEK(Input0), tLH, tHL);
         else                    POKE_DRV(Output, PEEK(Input1), tLH, tHL);
      }
   }
}

#define defInput(n) if(PEEK_CHANGE(Select0) || \
                       PEEK_CHANGE(Select1))   POKE_DRV(Output, PEEK(Input##n), selLH, selHL); \
                    else                       POKE_DRV(Output, PEEK(Input##n), tLH, tLH)

void fnVhdlMux4(int Input0, int Input1, int Input2, int Input3, int Select0, int Select1,
                int Output, float tLH, float tHL, float selLH, float selHL)
{
   int iSelect  = (PEEK(Select0) == HIGH ? 1 : 0) |
                  (PEEK(Select1) == HIGH ? 2 : 0);

   int iInput   = 1 << iSelect;

   if(iInput & 1) defInput(0);
   else
      if((iInput >> 1) & 1) defInput(1);
      else
         if((iInput >> 2) & 1) defInput(2);
         else
            defInput(3);
}

#ifdef defInput
#undef defInput
#define defInput(n) if(PEEK_CHANGE(Select0) || \
                       PEEK_CHANGE(Select1) || \
                       PEEK_CHANGE(Select2))   POKE_DRV(Output, PEEK(Input##n), selLH, selHL); \
                    else                       POKE_DRV(Output, PEEK(Input##n), tLH, tLH)
#endif

void fnVhdlMux8(int Input0, int Input1, int Input2, int Input3, int Input4, int Input5,
                int Input6, int Input7, int Select0, int Select1, int Select2, int Output,
                float tLH, float tHL, float selLH, float selHL)
{
   int iSelect  = (PEEK(Select0) == HIGH ? 1 : 0) |
                  (PEEK(Select1) == HIGH ? 2 : 0) |
                  (PEEK(Select2) == HIGH ? 4 : 0);

   int iInput   = 1 << iSelect;

   if(iInput & 1) defInput(0);
   else
      if((iInput >> 1) & 1) defInput(1);
      else
         if((iInput >> 2) & 1) defInput(2);
         else
            if((iInput >> 3) & 1) defInput(3);
            else
               if((iInput >> 4) & 1) defInput(4);
               else
                  if((iInput >> 5) & 1) defInput(5);
                  else
                     if((iInput >> 6) & 1) defInput(6);
                     else
                        defInput(7);
}

#ifdef defInput
#undef defInput
#define defInput(n) if(PEEK_CHANGE(Select0) || \
                       PEEK_CHANGE(Select1) || \
                       PEEK_CHANGE(Select2) || \
                       PEEK_CHANGE(Select3))   POKE_DRV(Output, PEEK(Input##n), selLH, selHL); \
                    else                       POKE_DRV(Output, PEEK(Input##n), tLH, tLH)
#endif

void fnVhdlMux16(int Input0,  int Input1,  int Input2,  int Input3,  int Input4,  int Input5,
                 int Input6,  int Input7,  int Input8,  int Input9,  int Input10, int Input11,
                 int Input12, int Input13, int Input14, int Input15, int Select0, int Select1,
                 int Select2, int Select3, int Output, float tLH, float tHL, float selLH, float selHL)
{
   int iSelect  = (PEEK(Select0) == HIGH ? 1 : 0) |
                  (PEEK(Select1) == HIGH ? 2 : 0) |
                  (PEEK(Select2) == HIGH ? 4 : 0) |
                  (PEEK(Select3) == HIGH ? 8 : 0);

   int iInput   = 1 << iSelect;

   if(iInput & 1) defInput(0);
   else
      if((iInput >> 1) & 1) defInput(1);
      else
         if((iInput >> 2) & 1) defInput(2);
         else
            if((iInput >> 3) & 1) defInput(3);
            else
               if((iInput >> 4) & 1) defInput(4);
               else
                  if((iInput >> 5) & 1) defInput(5);
                  else
                     if((iInput >> 6) & 1) defInput(6);
                     else
                        if((iInput >> 7) & 1) defInput(7);
                        else
                           if((iInput >> 8) & 1) defInput(8);
                           else
                              if((iInput >> 9) & 1) defInput(9);
                              else
                                 if((iInput >> 10) & 1) defInput(10);
                                 else
                                    if((iInput >> 11) & 1) defInput(11);
                                    else
                                       if((iInput >> 12) & 1) defInput(12);
                                       else
                                          if((iInput >> 13) & 1) defInput(13);
                                          else
                                             if((iInput >> 14) & 1) defInput(14);
                                             else
                                                defInput(15);

}

// Decoders

void fnVhdlDec1(int Address, int Output0, int Output1, float tLH, float tHL)
{
   if(PEEK(Address) == LOW)
   {
      POKE_DRV(Output0, HIGH, tLH, tHL);
      POKE_DRV(Output1, LOW,  tLH, tHL);
   }
   else
   {
      POKE_DRV(Output0, LOW,  tLH, tHL);
      POKE_DRV(Output1, HIGH, tLH, tHL);
   }
}


#define defOutput(n, v) POKE_DRV(Output##n, v,  tLH, tHL)

void fnVhdlDec2(int Address0, int Address1, int Output0, int Output1, int Output2,
                int Output3, float tLH, float tHL)
{
   int iAddress = (PEEK(Address0) == HIGH ? 1 : 0) |
                  (PEEK(Address1) == HIGH ? 2 : 0);

   int iOutputs = 1 << iAddress;

   defOutput(0,  ( iOutputs        & 1) ? HIGH : LOW);
   defOutput(1,  ((iOutputs >> 1)  & 1) ? HIGH : LOW);
   defOutput(2,  ((iOutputs >> 2)  & 1) ? HIGH : LOW);
   defOutput(3,  ((iOutputs >> 3)  & 1) ? HIGH : LOW);
}

void fnVhdlDec3(int Address0, int Address1, int Address2, int Output0, int Output1, int Output2,
                int Output3, int Output4, int Output5, int Output6, int Output7, float tLH, float tHL)
{
   int iAddress = (PEEK(Address0) == HIGH ? 1 : 0) |
                  (PEEK(Address1) == HIGH ? 2 : 0) |
                  (PEEK(Address2) == HIGH ? 4 : 0);

   int iOutputs = 1 << iAddress;

   defOutput(0,  ( iOutputs        & 1) ? HIGH : LOW);
   defOutput(1,  ((iOutputs >> 1)  & 1) ? HIGH : LOW);
   defOutput(2,  ((iOutputs >> 2)  & 1) ? HIGH : LOW);
   defOutput(3,  ((iOutputs >> 3)  & 1) ? HIGH : LOW);
   defOutput(4,  ((iOutputs >> 4)  & 1) ? HIGH : LOW);
   defOutput(5,  ((iOutputs >> 5)  & 1) ? HIGH : LOW);
   defOutput(6,  ((iOutputs >> 6)  & 1) ? HIGH : LOW);
   defOutput(7,  ((iOutputs >> 7)  & 1) ? HIGH : LOW);
}

void fnVhdlDec4(int Address0, int Address1, int Address2, int Address3, int Output0,  int Output1,
                int Output2,  int Output3,  int Output4,  int Output5,  int Output6,  int Output7,
                int Output8,  int Output9,  int Output10, int Output11, int Output12, int Output13,
                int Output14, int Output15, float tLH, float tHL)
{
   int iAddress = (PEEK(Address0) == HIGH ? 1 : 0) |
                  (PEEK(Address1) == HIGH ? 2 : 0) |
                  (PEEK(Address2) == HIGH ? 4 : 0) |
                  (PEEK(Address3) == HIGH ? 8 : 0);

   int iOutputs = 1 << iAddress;

   defOutput(0,  ( iOutputs        & 1) ? HIGH : LOW);
   defOutput(1,  ((iOutputs >> 1)  & 1) ? HIGH : LOW);
   defOutput(2,  ((iOutputs >> 2)  & 1) ? HIGH : LOW);
   defOutput(3,  ((iOutputs >> 3)  & 1) ? HIGH : LOW);
   defOutput(4,  ((iOutputs >> 4)  & 1) ? HIGH : LOW);
   defOutput(5,  ((iOutputs >> 5)  & 1) ? HIGH : LOW);
   defOutput(6,  ((iOutputs >> 6)  & 1) ? HIGH : LOW);
   defOutput(7,  ((iOutputs >> 7)  & 1) ? HIGH : LOW);
   defOutput(8,  ((iOutputs >> 8)  & 1) ? HIGH : LOW);
   defOutput(9,  ((iOutputs >> 9)  & 1) ? HIGH : LOW);
   defOutput(10, ((iOutputs >> 10) & 1) ? HIGH : LOW);
   defOutput(11, ((iOutputs >> 11) & 1) ? HIGH : LOW);
   defOutput(12, ((iOutputs >> 12) & 1) ? HIGH : LOW);
   defOutput(13, ((iOutputs >> 13) & 1) ? HIGH : LOW);
   defOutput(14, ((iOutputs >> 14) & 1) ? HIGH : LOW);
   defOutput(15, ((iOutputs >> 15) & 1) ? HIGH : LOW);
}

void fnVhdlGnd(int Output, float tLH, float tHL)
{
   POKE_DRV(Output, LOW, tLH, tHL);
}

void fnVhdlVcc(int Output, float tLH, float tHL)
{
   POKE_DRV(Output, HIGH, tLH, tHL);
}
