summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--Makefile18
-rw-r--r--README.md6
-rw-r--r--src/gui/gui.py0
-rw-r--r--src/memory/driver.cc0
-rw-r--r--src/repl/repl.py10
-rw-r--r--src/rv.cc33
7 files changed, 74 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6b5e70f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+# IDE
+.dir-locals.el
+manifest.scm
+
+# generated
+__pycache__
+rv
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0d06904
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+CXX = g++
+PYTHON_VERSION = 3.10
+
+CXXFLAGS = -I$(shell python$(PYTHON_VERSION)-config --includes)
+LDFLAGS = $(shell python$(PYTHON_VERSION)-config --ldflags --embed)
+
+SRCDIR = src
+
+all: rv
+
+rv: $(SRCDIR)/rv.cc
+ $(CXX) $(CXXFLAGS) -o rv $(SRCDIR)/rv.cc $(LDFLAGS)
+
+test:
+ @echo "foo"
+
+clean:
+ rm -f rv
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e06b7aa
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+# Risc V[ECTOR]
+
+# About
+
+University of Massachusetts, Amherst
+CS535 -- Computer Architecture and ISA Design \ No newline at end of file
diff --git a/src/gui/gui.py b/src/gui/gui.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/gui/gui.py
diff --git a/src/memory/driver.cc b/src/memory/driver.cc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/memory/driver.cc
diff --git a/src/repl/repl.py b/src/repl/repl.py
new file mode 100644
index 0000000..d78986d
--- /dev/null
+++ b/src/repl/repl.py
@@ -0,0 +1,10 @@
+from code import InteractiveConsole
+
+def start(user):
+ header =f"Press C-d to close."
+ footer = f"See you later, {user}!"
+
+ scope_vars = {"cache_size": 12}
+
+ InteractiveConsole(locals=scope_vars).interact(header, "")
+ return footer
diff --git a/src/rv.cc b/src/rv.cc
new file mode 100644
index 0000000..02d95e2
--- /dev/null
+++ b/src/rv.cc
@@ -0,0 +1,33 @@
+#include <Python.h>
+#include <iostream>
+
+int main() {
+ Py_Initialize();
+ PyRun_SimpleString("import sys; sys.path.append('src/')");
+ PyObject *pName = PyUnicode_DecodeFSDefault("repl.repl");
+ PyObject *pModule = PyImport_Import(pName);
+ Py_DECREF(pName);
+
+ if (pModule != nullptr) {
+ PyObject *pFunc = PyObject_GetAttrString(pModule, "start");
+ if (pFunc && PyCallable_Check(pFunc)) {
+ PyObject *pArgs = PyTuple_Pack(1, PyUnicode_FromString("World"));
+ PyObject *pValue = PyObject_CallObject(pFunc, pArgs);
+ Py_DECREF(pArgs);
+ if (pValue != nullptr) {
+ std::cout << PyUnicode_AsUTF8(pValue) << std::endl;
+ Py_DECREF(pValue);
+ } else {
+ PyErr_Print();
+ std::cerr << "Call failed" << std::endl;
+ }
+ Py_DECREF(pFunc);
+ }
+ Py_DECREF(pModule);
+ } else {
+ PyErr_Print();
+ std::cerr << "Failed to load \"hello\"" << std::endl;
+ }
+ Py_Finalize();
+ return 0;
+}