//
// SRFlipFlop
//


#import "SRFlipFlop.h"


@implementation SRFlipFlop


- initS:snode r:rnode out:outnode
{
    [super init];
    
    state = 0;
    
    INITDEVTYPE("SRFlipFlop");
    
    TESTNODE("S", snode, 1);
    TESTNODE("R", rnode, 1);
    TESTNODE("OUT", outnode, 1);
    
    S = snode;
    R = rnode;
    OUT = outnode;
    
    return self;
}


- cycle
{
    bit		*sval = [S getBits];
    bit		*rval = [R getBits];
    
    if(*sval && !(*rval)) {
        state = 1;
    }
    else if(!(*sval) && *rval) {
        state = 0;
    }
    
    [OUT setBits:&state];
    
    return self;
}


@end


//
// End of file.
//