From: Mike Frysinger Date: Mon, 23 May 2011 22:59:54 +0000 (+0000) Subject: sim: glue: implement or/xor funcs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0e31da218e04915bca80802b87fa418b49780378;p=binutils-gdb.git 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 --- diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 7db35bcfb18..bd6a7eecbbb 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,11 @@ +2011-05-23 Mike Frysinger + + * 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 * callback.c, dv-pal.c, dv-sockser.c, hw-base.c, hw-device.c, diff --git a/sim/common/dv-glue.c b/sim/common/dv-glue.c index 40858010283..b99487dbd78 100644 --- a/sim/common/dv-glue.c +++ b/sim/common/dv-glue.c @@ -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]); }