From dc0b3db1b4f1895a07e5fe280ee3790e87f97b9f Mon Sep 17 00:00:00 2001 From: Ataberk Date: Sun, 25 Sep 2022 17:22:03 +0200 Subject: Initial commit --- sources/apps/DebugExample/debug_example.cpp | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 sources/apps/DebugExample/debug_example.cpp (limited to 'sources/apps/DebugExample/debug_example.cpp') 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 +#include +#include +#include +#include +#include +#include + +using namespace std; + +#define 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); +} -- cgit v1.2.3