(#  COPYRIGHT 1989  --  The Board of Trustees of the Leland Stanford Junior
 #  University.  All rights reserved.
 #) 

(# File: hexin.m
 #
 # Bernhard Boser
 # Louis Williams - 13-June-1989
 # Sha Rabii 15-Oct-1997, modified initialize statements to allow re-reading
 #                        of the file when a FOR statement is used.
 #)

MODEL hexin

    stream parameter file;
    double output y;
    long InputBits;
    int BitCount;

INITIALIZE

    rewind (file);
    BitCount = 0;
    Enable();

EXECUTE

    if (BitCount <= 0) {
        if (fscanf(file, " 0x%lx\n", &InputBits) < 0) return;
	BitCount = 32;
    }
    BitCount--;
    y = (InputBits & 1) ? 0.5 : -0.5;
    InputBits >>= 1;
    ContinueSimulation();
    Enable();

END
