This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] sim: glue: implement or/xor funcs
- From: Mike Frysinger <vapier at gentoo dot org>
- To: gdb-patches at sourceware dot org
- Cc: toolchain-devel at blackfin dot uclinux dot org
- Date: Sat, 2 Apr 2011 02:52:21 -0400
- Subject: [PATCH] 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>
2011-04-02 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.
---
sim/common/dv-glue.c | 33 ++++++++++++++++++++++++++-------
1 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/sim/common/dv-glue.c b/sim/common/dv-glue.c
index 4085801..b99487d 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]);
}
--
1.7.4.1