/*
 * not.c
 *
 *  Created on: 29-04-2014
 *      Author: KJ
 */


#include "tdefs.h"
#include "misc.h"

#include "not.h"

int not_initlog(void *arguments, void *logic)
{
	struct not_args *args = (struct not_args *)arguments;
	struct not_logic *log = (struct not_logic *)logic;

	log->out_ptr = log_manager.nets_data + (args->io.out >> 3);
	log->out_bit_mask = 1<<(args->io.out & 0x07);

	log->in_ptr = log_manager.nets_data + (args->io.in >> 3);
	log->in_bit_mask = 1<<(args->io.in & 0x07);


	if(log->out_ptr >= (log_manager.nets_data+sizeof(log_manager.nets_data)))
		return -1;

	if(log->in_ptr >= (log_manager.nets_data+sizeof(log_manager.nets_data)))
		return -1;

	return 0;
}

void not(void *arguments, void *logic)
{
//	struct not_args *args = (struct not_args *)arguments;
	struct not_logic *log = (struct not_logic *)logic;

	if(*log->in_ptr & log->in_bit_mask)
		*log->out_ptr&=~log->out_bit_mask;
	else
		*log->out_ptr|=log->out_bit_mask;
}
