sim: glue: implement or/xor funcs

The glue device has a bunch of "todos" for the misc bitwise devices.
So implement two for fun -- the glue-or and glue-xor.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger 2011-05-23 22:59:54 +00:00
parent c50491a797
commit 0e31da218e
2 changed files with 34 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2011-05-23 Mike Frysinger <vapier@gentoo.org>
* dv-glue.c (hw_glue_finish): Set type to glue_or when name is
glue-or, and set type to glue_xor when name is glue-xor.
(hw_glue_port_event): Return immediately when type is glue_io
or unmatched. Handle glue_or and glue_xor types. Move HW_TRACE
and hw_port_event calls from glue_and to end of function.
2011-05-11 Mike Frysinger <vapier@gentoo.org>
* callback.c, dv-pal.c, dv-sockser.c, hw-base.c, hw-device.c,

View File

@ -274,6 +274,10 @@ hw_glue_finish (struct hw *me)
glue->type = glue_io;
else if (strcmp (name, "glue-and") == 0)
glue->type = glue_and;
else if (strcmp (name, "glue-or") == 0)
glue->type = glue_or;
else if (strcmp (name, "glue-xor") == 0)
glue->type = glue_xor;
else
hw_abort (me, "unimplemented glue type");
}
@ -358,26 +362,41 @@ hw_glue_port_event (struct hw *me,
my_port,
(unsigned long) glue->address + port * sizeof (unsigned_word),
level));
break;
return;
}
case glue_and:
{
glue->output[0] = glue->input[0];
for (i = 1; i < glue->nr_inputs; i++)
glue->output[0] &= glue->input[i];
HW_TRACE ((me, "and - port %d, level %d arrived - output %d",
my_port, level, glue->output[0]));
hw_port_event (me, 0, glue->output[0]);
break;
}
case glue_or:
{
glue->output[0] = glue->input[0];
for (i = 1; i < glue->nr_inputs; i++)
glue->output[0] |= glue->input[i];
break;
}
case glue_xor:
{
glue->output[0] = glue->input[0];
for (i = 1; i < glue->nr_inputs; i++)
glue->output[0] ^= glue->input[i];
break;
}
default:
{
hw_abort (me, "operator not implemented");
break;
return;
}
}
/* If we fell through, we want to generate a port event. */
HW_TRACE ((me, "port %d, level %d arrived - output %d",
my_port, level, glue->output[0]));
hw_port_event (me, 0, glue->output[0]);
}