Add CRTL templates
authorMikolaj Wielgus <wielgusmikolaj@gmail.com>
Thu, 23 Dec 2021 01:59:13 +0000 (01:59 +0000)
committerMikolaj Wielgus <wielgusmikolaj@gmail.com>
Thu, 23 Dec 2021 01:59:13 +0000 (01:59 +0000)
Forgot to add them in the previous commit.

src/openpower/decoder/test/crtl_template.c [new file with mode: 0644]
src/openpower/decoder/test/crtl_template.h [new file with mode: 0644]

diff --git a/src/openpower/decoder/test/crtl_template.c b/src/openpower/decoder/test/crtl_template.c
new file mode 100644 (file)
index 0000000..e10e25e
--- /dev/null
@@ -0,0 +1,41 @@
+#include <stdint.h>
+#include "common.h"
+
+state_t slots[%d];
+uint64_t pending[%d];
+uint64_t pending_count;
+
+void add_pending(uint64_t index)
+{
+    pending[pending_count++] = index;
+}
+
+void clear_pending(void)
+{
+    pending_count = 0;
+}
+
+uint64_t capture(uint64_t index)
+{
+    if (slots[index].curr == slots[index].next)
+        return 0;
+
+    slots[index].curr = slots[index].next;
+    return 1;
+}
+
+uint64_t get_curr(uint64_t index)
+{
+    return slots[index].curr;
+}
+
+uint64_t get_next(uint64_t index)
+{
+    return slots[index].next;
+}
+
+void set(uint64_t index, uint64_t value)
+{
+    slots[index].next = value;
+    add_pending(index);
+}
diff --git a/src/openpower/decoder/test/crtl_template.h b/src/openpower/decoder/test/crtl_template.h
new file mode 100644 (file)
index 0000000..e714d26
--- /dev/null
@@ -0,0 +1,17 @@
+typedef struct state_t
+{
+    uint64_t curr;
+    uint64_t next;
+} state_t;
+
+extern state_t slots[%d];
+extern uint64_t pending[%d];
+extern uint64_t pending_count;
+
+void add_pending(uint64_t index);
+void clear_pending(void);
+
+uint64_t capture(uint64_t index);
+uint64_t get_curr(uint64_t index);
+uint64_t get_next(uint64_t index);
+void set(uint64_t index, uint64_t value);