2024-04-03 14:39:33 +00:00
|
|
|
#include "components.hpp"
|
|
|
|
#include "config.hpp"
|
|
|
|
#include "vl_wrapper.hpp"
|
2024-03-29 02:35:49 +00:00
|
|
|
#include <VFlow.h>
|
2024-03-13 06:53:31 +00:00
|
|
|
|
2024-04-03 14:39:33 +00:00
|
|
|
using VlModule = VlModuleInterfaceCommon<VFlow>;
|
|
|
|
using Registers = _RegistersVPI<uint32_t, 32>;
|
2024-03-29 02:35:49 +00:00
|
|
|
|
2024-04-02 08:15:16 +00:00
|
|
|
extern "C" {
|
2024-04-03 14:39:33 +00:00
|
|
|
void *pmem_get() {
|
|
|
|
static auto pmem = new Memory<int, 128 * 1024>(config.memory_file,
|
|
|
|
config.memory_file_binary);
|
|
|
|
return pmem;
|
|
|
|
}
|
2024-04-02 08:15:16 +00:00
|
|
|
|
2024-04-03 14:39:33 +00:00
|
|
|
int pmem_read(int raddr) {
|
|
|
|
void *pmem = pmem_get();
|
|
|
|
auto mem = static_cast<Memory<int, 128 * 1024> *>(pmem);
|
|
|
|
return mem->read(raddr);
|
|
|
|
}
|
2024-04-02 06:30:14 +00:00
|
|
|
|
2024-04-03 14:39:33 +00:00
|
|
|
void pmem_write(int waddr, int wdata, char wmask) {
|
|
|
|
void *pmem = pmem_get();
|
|
|
|
auto mem = static_cast<Memory<int, 128 * 1024> *>(pmem);
|
|
|
|
return mem->write((std::size_t)waddr, wdata, wmask);
|
|
|
|
}
|
|
|
|
}
|
2024-03-29 02:35:49 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv, char **env) {
|
2024-04-03 14:39:33 +00:00
|
|
|
config.cli_parse(argc, argv);
|
|
|
|
auto top = std::make_shared<VlModule>(config.do_trace, config.wavefile);
|
2024-04-02 05:35:29 +00:00
|
|
|
Registers regs("TOP.Flow.reg_0.regFile_");
|
2024-03-29 02:35:49 +00:00
|
|
|
|
2024-04-02 06:30:14 +00:00
|
|
|
top->reset_eval(10);
|
2024-04-03 14:39:33 +00:00
|
|
|
for (int i = 0; i < config.max_sim_time; i++) {
|
|
|
|
if (top->is_posedge()) {
|
2024-03-29 02:35:49 +00:00
|
|
|
// Posedge
|
2024-04-02 05:35:29 +00:00
|
|
|
regs.update();
|
|
|
|
regs.print_regs();
|
2024-03-13 06:53:31 +00:00
|
|
|
}
|
2024-04-02 05:35:29 +00:00
|
|
|
top->eval();
|
2024-03-29 02:35:49 +00:00
|
|
|
}
|
2024-04-02 06:30:14 +00:00
|
|
|
return 0;
|
2024-03-13 06:53:31 +00:00
|
|
|
}
|