Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ compile_commands.json
/src/project_info.h
# Local settings template
.dev-config.mk
/cmake-build-debug-wsl/
/cmake-build-release-wsl/
Comment on lines +19 to +20
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I do this on my machine is that I configure the files to be build/Debug and build/Release. You can also ignore thise files localy. It should not be here.

641 changes: 641 additions & 0 deletions CMakeLists.txt.user
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the accidentally committed files.

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/assembler/simpleasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ void SimpleAsm::clear() {

void SimpleAsm::setup(
machine::FrontendMemory *mem,
machine::MachineConfig config,
SymbolTableDb *symtab,
machine::Address address,
machine::Xlen xlen) {
this->mem = mem;
this->config = config;
this->symtab = symtab;
this->address = address;
this->symtab->setSymbol("XLEN", static_cast<uint64_t>(xlen), sizeof(uint64_t));
Expand Down Expand Up @@ -286,7 +288,12 @@ bool SimpleAsm::process_line(
if (error_ptr != nullptr) { *error_ptr = error; }
return false;
}
address = machine::Address(value);
qint64 offset = qint64(value);
qint64 base = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please prefer standard cpp types over qt ones whenever possible.

if (config.get_vm_enabled() && config.get_vm_mode() == machine::MachineConfig::VM_SV32) {
base = config.get_va_base_addr();
}
address = machine::Address(base + offset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now looking at this, wouldn't it be simpler to just pass the base to the assembler constructor and keep this logic outside?

return true;
}
if ((op == ".space") || (op == ".skip")) {
Expand Down
2 changes: 2 additions & 0 deletions src/assembler/simpleasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SimpleAsm : public QObject {
void clear();
void setup(
machine::FrontendMemory *mem,
machine::MachineConfig config,
SymbolTableDb *symtab,
machine::Address address,
machine::Xlen xlen);
Expand All @@ -79,6 +80,7 @@ class SimpleAsm : public QObject {
private:
QStringList include_stack;
machine::FrontendMemory *mem {};
machine::MachineConfig config {};
machine::RelocExpressionList reloc;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a pointer - it feels weirt to have multiple copies of machine config in the program.


Expand Down
53 changes: 25 additions & 28 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include "common/logging.h"
#include "common/logging_format_colors.h"
#include "machine/machineconfig.h"
#include "os_emulation/ossyscall.h"
#include "msgreport.h"
#include "os_emulation/ossyscall.h"
#include "reporter.h"
#include "tracer.h"

Expand Down Expand Up @@ -83,9 +83,12 @@ void create_parser(QCommandLineParser &p) {
p.addOption(
{ { "serial-out", "serout" }, "File connected to the serial port output.", "FNAME" });
p.addOption({ { "os-emulation", "osemu" }, "Operating system emulation." });
p.addOption({ { "std-out", "stdout" }, "File connected to the syscall standard output.", "FNAME" });
p.addOption({ { "os-fs-root", "osfsroot" }, "Emulated system root/prefix for opened files", "DIR" });
p.addOption({ { "isa-variant", "isavariant" }, "Instruction set to emulate (default RV32IMA)", "STR" });
p.addOption(
{ { "std-out", "stdout" }, "File connected to the syscall standard output.", "FNAME" });
p.addOption(
{ { "os-fs-root", "osfsroot" }, "Emulated system root/prefix for opened files", "DIR" });
p.addOption(
{ { "isa-variant", "isavariant" }, "Instruction set to emulate (default RV32IMA)", "STR" });
p.addOption({ "cycle-limit", "Limit execution to specified maximum clock cycles", "NUMBER" });
}

Expand Down Expand Up @@ -202,19 +205,18 @@ void configure_machine(QCommandLineParser &parser, MachineConfig &config) {
int siz = parser.values("os-fs-root").size();
if (siz >= 1) {
QString osemu_fs_root = parser.values("os-fs-root").at(siz - 1);
if (osemu_fs_root.length() > 0)
config.set_osemu_fs_root(osemu_fs_root);
if (osemu_fs_root.length() > 0) config.set_osemu_fs_root(osemu_fs_root);
}
siz = parser.values("isa-variant").size();
for (int i = 0; i < siz; i++) {
int pos = 0;
bool first = true;
bool subtract = false;
QString isa_str = parser.values("isa-variant").at(i).toUpper();
if (isa_str.startsWith ("RV32")) {
if (isa_str.startsWith("RV32")) {
config.set_simulated_xlen(machine::Xlen::_32);
pos = 4;
} else if (isa_str.startsWith ("RV64")) {
} else if (isa_str.startsWith("RV64")) {
config.set_simulated_xlen(machine::Xlen::_64);
pos = 4;
}
Expand All @@ -228,10 +230,10 @@ void configure_machine(QCommandLineParser &parser, MachineConfig &config) {
continue;
}
auto flag = machine::ConfigIsaWord::byChar(ch);
if (flag.isEmpty())
continue;
if (flag.isEmpty()) continue;
if (first)
config.modify_isa_word(~machine::ConfigIsaWord::empty(), machine::ConfigIsaWord::empty());
config.modify_isa_word(
~machine::ConfigIsaWord::empty(), machine::ConfigIsaWord::empty());
if (subtract)
config.modify_isa_word(flag, machine::ConfigIsaWord::empty());
else
Expand All @@ -253,7 +255,7 @@ void configure_tracer(QCommandLineParser &p, Tracer &tr) {
if (p.isSet("trace-gp")) { tr.trace_regs_gp = true; }

QStringList gps = p.values("trace-gp");
for (const auto & gp : gps) {
for (const auto &gp : gps) {
if (gp == "*") {
tr.regs_to_trace.fill(true);
} else {
Expand All @@ -262,8 +264,7 @@ void configure_tracer(QCommandLineParser &p, Tracer &tr) {
if (res && num <= machine::REGISTER_COUNT) {
tr.regs_to_trace.at(num) = true;
} else {
fprintf(
stderr, "Unknown register number given for trace-gp: %s\n", qPrintable(gp));
fprintf(stderr, "Unknown register number given for trace-gp: %s\n", qPrintable(gp));
exit(EXIT_FAILURE);
}
}
Expand All @@ -277,8 +278,7 @@ void configure_tracer(QCommandLineParser &p, Tracer &tr) {
bool ok;
tr.cycle_limit = clim.at(clim.size() - 1).toLong(&ok);
if (!ok) {
fprintf(
stderr, "Cycle limit parse error\n");
fprintf(stderr, "Cycle limit parse error\n");
exit(EXIT_FAILURE);
}
}
Expand All @@ -296,7 +296,7 @@ void configure_reporter(QCommandLineParser &p, Reporter &r, const SymbolTable *s
if (p.isSet("dump-cycles")) { r.enable_cycles_reporting(); }

QStringList fail = p.values("fail-match");
for (const auto & i : fail) {
for (const auto &i : fail) {
for (int y = 0; y < i.length(); y++) {
enum Reporter::FailReason reason;
switch (tolower(i.toStdString()[y])) {
Expand Down Expand Up @@ -413,17 +413,18 @@ void configure_osemu(QCommandLineParser &p, MachineConfig &config, Machine *mach
exit(EXIT_FAILURE);
}
}
const static machine::ExceptionCause ecall_variats[] = {machine::EXCAUSE_ECALL_ANY,
machine::EXCAUSE_ECALL_M, machine::EXCAUSE_ECALL_S, machine::EXCAUSE_ECALL_U};
const static machine::ExceptionCause ecall_variats[]
= { machine::EXCAUSE_ECALL_ANY, machine::EXCAUSE_ECALL_M, machine::EXCAUSE_ECALL_S,
machine::EXCAUSE_ECALL_U };

if (config.osemu_enable()) {
auto *osemu_handler = new osemu::OsSyscallExceptionHandler(
config.osemu_known_syscall_stop(), config.osemu_unknown_syscall_stop(),
config.osemu_fs_root());
if (std_out) {
machine::Machine::connect(
osemu_handler, &osemu::OsSyscallExceptionHandler::char_written,
std_out, QOverload<int, unsigned>::of(&CharIOHandler::writeByte));
osemu_handler, &osemu::OsSyscallExceptionHandler::char_written, std_out,
QOverload<int, unsigned>::of(&CharIOHandler::writeByte));
}
/*connect(
osemu_handler, &osemu::OsSyscallExceptionHandler::rx_byte_pool, terminal,
Expand Down Expand Up @@ -468,9 +469,7 @@ void load_ranges(Machine &machine, const QStringList &ranges) {
Address addr = start;
for (std::string line; getline(in, line);) {
size_t end_pos = line.find_last_not_of(" \t\n");
if (std::string::npos == end_pos) {
continue;
}
if (std::string::npos == end_pos) { continue; }

size_t start_pos = line.find_first_not_of(" \t\n");
line = line.substr(0, end_pos + 1);
Expand Down Expand Up @@ -498,11 +497,9 @@ bool assemble(Machine &machine, MsgReport &msgrep, const QString &filename) {

SimpleAsm::connect(&assembler, &SimpleAsm::report_message, &msgrep, &MsgReport::report_message);

assembler.setup(mem, &symbol_table_db, 0x00000200_addr, machine.core()->get_xlen());
assembler.setup(mem, TODO, &symbol_table_db, 0x00000200_addr, machine.core()->get_xlen());

if (!assembler.process_file(filename)) {
return false;
}
if (!assembler.process_file(filename)) { return false; }

return assembler.finish();
}
Expand Down
4 changes: 3 additions & 1 deletion src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ add_executable(gui
${gui_SOURCES}
${gui_HEADERS}
${gui_UI}
${gui_RESOURCES})
${gui_RESOURCES}
dialogs/new/bigslider.h
dialogs/new/bigslider.cpp)
target_include_directories(gui PUBLIC . windows/coreview)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this to the lists above.

target_link_libraries(gui
PRIVATE ${QtLib}::Core ${QtLib}::Widgets ${QtLib}::Gui
Expand Down
Loading
Loading