aboutsummaryrefslogtreecommitdiffstats
path: root/sources/apps/DebugExample
diff options
context:
space:
mode:
authorAtaberk <olgunataberk@gmail.com>2022-09-25 17:22:03 +0200
committerAtaberk <olgunataberk@gmail.com>2022-09-25 17:22:03 +0200
commitdc0b3db1b4f1895a07e5fe280ee3790e87f97b9f (patch)
treeb47203aa281bdd959def4451c84d310cd9cf2e12 /sources/apps/DebugExample
downloaddram-bender-dc0b3db1b4f1895a07e5fe280ee3790e87f97b9f.tar.gz
Initial commit
Diffstat (limited to 'sources/apps/DebugExample')
-rwxr-xr-xsources/apps/DebugExample/Makefile32
-rw-r--r--sources/apps/DebugExample/debug_example.cpp58
-rw-r--r--sources/apps/DebugExample/timings.txt14
3 files changed, 104 insertions, 0 deletions
diff --git a/sources/apps/DebugExample/Makefile b/sources/apps/DebugExample/Makefile
new file mode 100755
index 0000000..13ecbb0
--- /dev/null
+++ b/sources/apps/DebugExample/Makefile
@@ -0,0 +1,32 @@
+program_NAME := Debug_example
+program_CXX_SRCS := debug_example.cpp $(wildcard ../../api/*.c) $(wildcard ../../api/*.cpp)
+program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
+program_CXX_OBJS := ${program_CXX_OBJS:.c=.o}
+program_OBJS := $(program_CXX_OBJS)
+program_INCLUDE_DIRS := ../../api ../../../boost-lib
+program_LIBRARY_DIRS :=
+program_LIBRARIES :=
+CPPFLAGS += -g -std=c++11 -pthread -O3
+
+CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
+LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
+LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
+
+CC=g++
+
+.PHONY: all clean distclean
+
+all: $(program_NAME)
+
+$(program_NAME): $(program_OBJS)
+ $(CC) $(CPPFLAGS) $(program_OBJS) -o $(program_NAME) $(LDFLAGS)
+
+clean:
+ @- $(RM) $(program_NAME)
+ @- $(RM) $(program_OBJS)
+
+parser:
+ $(MAKE) -C ../../api/lexyacc
+ cp ../../api/lexyacc/smc_parser .
+
+distclean: clean
diff --git a/sources/apps/DebugExample/debug_example.cpp b/sources/apps/DebugExample/debug_example.cpp
new file mode 100644
index 0000000..6581354
--- /dev/null
+++ b/sources/apps/DebugExample/debug_example.cpp
@@ -0,0 +1,58 @@
+#include "instruction.h"
+#include "prog.h"
+#include "platform.h"
+#include <fstream>
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <cstring>
+#include <list>
+
+using namespace std;
+
+#define PROJECT_DIRECTORY "<YOUR PROJECT DIRECTORY>"
+
+#define ADD_REG 7
+#define LD_REG 8
+#define STR_REG 9
+
+/**
+ * @return an instruction formed by NOPs
+ */
+Inst all_nops()
+{
+ return __pack_mininsts(SMC_NOP(), SMC_NOP(), SMC_NOP(), SMC_NOP());
+}
+
+int main()
+{
+
+ Program program;
+
+ program.add_inst(SMC_LI(5, 3)); //R3=5
+ program.add_inst(SMC_LI(15, 4)); //R4=15
+ program.add_label("LOOP");
+ program.add_inst(SMC_ADDI(3, 1, 3)); //R3++
+ //If R4>R3, go to LOOP
+ program.add_branch(program.BR_TYPE::BL,3,4, "LOOP");
+ program.add_inst(all_nops()); //R3=R4=15
+ program.add_inst(SMC_LI(121, LD_REG));
+ program.add_inst(SMC_LI(62, STR_REG));
+ program.add_inst(SMC_LI(100, ADD_REG));
+ program.add_inst(SMC_ST(ADD_REG, 0, STR_REG));
+ program.add_inst(all_nops());
+ program.add_inst(SMC_LD(ADD_REG, 0, LD_REG));
+ program.add_inst(all_nops());
+ program.add_inst(SMC_END());
+
+ //DRAM timing parameters are updated with timings.txt
+ program.debug(PROJECT_DIRECTORY, "timings.txt");
+
+ //Load the program to instruction memory
+ program.save_coe(PROJECT_DIRECTORY);
+ program.pretty_print();
+
+ //Start the debugger
+ program.debug(PROJECT_DIRECTORY, false);
+}
diff --git a/sources/apps/DebugExample/timings.txt b/sources/apps/DebugExample/timings.txt
new file mode 100644
index 0000000..8de3bed
--- /dev/null
+++ b/sources/apps/DebugExample/timings.txt
@@ -0,0 +1,14 @@
+tRTP = 7500
+tWTRc_S = 2
+tWTRc_L = 5
+tWR = 15000
+tMOD = 36000
+tRCD = 16000
+tRC = 55000
+tRP = 15000
+tCCDc_S = 4
+tCCDc_L = 5
+tRAS = 39000
+tRRDc_S = 4
+tRRDc_L = 4
+tFAW = 20000