ftp.nice.ch/pub/next/developer/resources/classes/CompSim.s.tar.gz#/CompSim/TriStateBuffer.m

This is TriStateBuffer.m in view mode; [Download] [Up]

//
// TriStateBuffer
//
// Used to gate things onto busses (nodes).
//


#import "TriStateBuffer.h"


@implementation TriStateBuffer


- initNumBits:(int)nbits			// Number of bits.
	in:innode				// Node from which we take value.
	out:outnode				// Node to take if signal is high.
	gate:gatenode				// 1-bit signal node.
{
    [super init];
    
    numbits = nbits;				// Remember the size.
    
    INITDEVTYPE("TriStateBuffer");
    
    TESTNODE("IN", innode, numbits);		// Make sure nodes are of correct sizes.
    TESTNODE("OUT", outnode, numbits);
    TESTNODE("GATE", gatenode, 1);
    
    IN = innode;				// Remember Nodes for later.
    OUT = outnode;
    GATE = gatenode;
    
    return self;
}


- cycle
{
    if(*([GATE getBits]))			// If GATE is high,
        [OUT setBits:[IN getBits]];		//   copy input to output.

    return self;
}


@end


//
// End of file.
//

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.