mirror of
https://github.com/Minres/RISCV-VP.git
synced 2026-02-27 19:01:42 +00:00
adds trace buffer memory and dumper
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -27,3 +27,5 @@ CMakeSettings.json
|
||||
.gdb_history
|
||||
/dbt-rise-custom
|
||||
*.pcap
|
||||
*.ihex
|
||||
*.trx
|
||||
Submodule dbt-rise-core updated: 9b1791a9b7...52b3ed8f04
Submodule dbt-rise-riscv updated: aaa922e2cc...90c58e7102
2
scc
2
scc
Submodule scc updated: 9fca1a7895...0077bb5c02
@@ -5,9 +5,12 @@
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
#include <filesystem>
|
||||
#include <minres/timer.h>
|
||||
#include <minres/uart.h>
|
||||
#include <scc/utilities.h>
|
||||
#include <util/ihex.h>
|
||||
#include <vector>
|
||||
|
||||
namespace vp {
|
||||
|
||||
@@ -29,7 +32,7 @@ using namespace vpvper::minres;
|
||||
|
||||
system::system(sc_core::sc_module_name nm)
|
||||
: sc_core::sc_module(nm)
|
||||
, NAMED(ahb_router, 6, 2)
|
||||
, NAMED(ahb_router, 7, 2)
|
||||
, NAMED(apbBridge, PipelinedMemoryBusToApbBridge_map.size(), 1) {
|
||||
mtime_clk = (1.0 / 32768) * 1_sec;
|
||||
|
||||
@@ -44,7 +47,8 @@ system::system(sc_core::sc_module_name nm)
|
||||
ahb_router.bind_target(eth1.socket, 2, 0x11001000, 4_KiB);
|
||||
ahb_router.bind_target(qspi.xip_sck, 3, 0x20000000, 16_MB);
|
||||
ahb_router.bind_target(mem_ram.target, 4, 0x30000000, mem_ram.getSize());
|
||||
ahb_router.bind_target(mem_dram.target, 5, 0x40000000, mem_dram.getSize());
|
||||
ahb_router.bind_target(mem_trace.target, 5, 0x31000000, mem_trace.getSize());
|
||||
ahb_router.bind_target(mem_dram.target, 6, 0x40000000, mem_dram.getSize());
|
||||
size_t i = 0;
|
||||
for(const auto& e : PipelinedMemoryBusToApbBridge_map) {
|
||||
apbBridge.initiator.at(i)(e.target);
|
||||
@@ -111,4 +115,33 @@ void system::gen_reset() {
|
||||
rst_s = 1;
|
||||
}
|
||||
|
||||
void system::start_of_simulation() {
|
||||
if(trace_dump_file.get_value().size()) {
|
||||
trace_buffer.resize(1_MiB);
|
||||
tlm::tlm_generic_payload gp;
|
||||
gp.set_address(0);
|
||||
gp.set_command(tlm::TLM_IGNORE_COMMAND);
|
||||
gp.set_data_length(trace_buffer.size());
|
||||
gp.set_streaming_width(trace_buffer.size());
|
||||
scc::host_mem_map_extension ext{trace_buffer.data()};
|
||||
gp.set_extension(&ext);
|
||||
mem_trace.target.get_base_interface().transport_dbg(gp);
|
||||
gp.set_extension<scc::host_mem_map_extension>(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void system::end_of_simulation() {
|
||||
auto& file_name = trace_dump_file.get_value();
|
||||
if(file_name.size()) {
|
||||
std::filesystem::path p(file_name);
|
||||
if(p.extension().string() == ".ihex") {
|
||||
std::ofstream out(file_name);
|
||||
util::ihex::dump(out, trace_buffer, 0, 64);
|
||||
} else {
|
||||
std::ofstream out(file_name, std::ios::binary);
|
||||
out.write(reinterpret_cast<const char*>(trace_buffer.data()), trace_buffer.size() * sizeof(uint8_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vp
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#ifndef SRC_VP_SYSTEM_H_
|
||||
#define SRC_VP_SYSTEM_H_
|
||||
|
||||
#include "tlm/scc/quantum_keeper.h"
|
||||
#include <cci_configuration>
|
||||
#include <minres/aclint.h>
|
||||
#include <minres/ethmac.h>
|
||||
@@ -26,6 +25,7 @@
|
||||
#include <sysc/kernel/sc_module.h>
|
||||
#include <sysc/kernel/sc_time.h>
|
||||
#include <sysc/utils/sc_vector.h>
|
||||
#include <tlm/scc/quantum_keeper.h>
|
||||
#include <tlm/scc/tlm_signal_sockets.h>
|
||||
|
||||
namespace vp {
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
eth::eth_pkt_initiator_socket<> eth1_tx{"eth1_tx"};
|
||||
eth::eth_pkt_target_socket<> eth1_rx{"eth1_rx"};
|
||||
|
||||
cci::cci_param<std::string> trace_dump_file{"trace_dump_file", ""};
|
||||
|
||||
sc_core::sc_in<sc_core::sc_time> clk_i{"clk_i"};
|
||||
|
||||
sc_core::sc_in<bool> erst_n{"erst_n"};
|
||||
@@ -68,13 +70,19 @@ private:
|
||||
scc::memory<256_kB, scc::LT> mem_ram{"mem_ram"};
|
||||
scc::memory<1_GB, scc::LT> mem_dram{"mem_dram"};
|
||||
scc::memory<8_kB, scc::LT> boot_rom{"boot_rom"};
|
||||
scc::memory<1_MiB, scc::LT> mem_trace{"mem_trace"};
|
||||
|
||||
sc_core::sc_signal<sc_core::sc_time> mtime_clk{"mtime_clk"};
|
||||
sc_core::sc_signal<bool, sc_core::SC_MANY_WRITERS> rst_s{"rst_s"};
|
||||
|
||||
sc_core::sc_vector<sc_core::sc_signal<bool, sc_core::SC_MANY_WRITERS>> clint_int_s{"clint_int_s", 0};
|
||||
sc_core::sc_signal<uint64_t> mtime_s{"mtime_s"};
|
||||
|
||||
std::vector<uint8_t> trace_buffer;
|
||||
|
||||
void gen_reset();
|
||||
void start_of_simulation() override;
|
||||
void end_of_simulation() override;
|
||||
};
|
||||
|
||||
} // namespace vp
|
||||
|
||||
2
vpvper
2
vpvper
Submodule vpvper updated: 1f5391b5a3...c2b3ab2962
Reference in New Issue
Block a user