adds trace buffer memory and dumper

This commit is contained in:
2026-02-07 12:30:48 +01:00
committed by Eyck Jentzsch
parent b8b1c236e6
commit 120675cf75
7 changed files with 50 additions and 7 deletions

2
.gitignore vendored
View File

@@ -27,3 +27,5 @@ CMakeSettings.json
.gdb_history .gdb_history
/dbt-rise-custom /dbt-rise-custom
*.pcap *.pcap
*.ihex
*.trx

2
scc

Submodule scc updated: 9fca1a7895...0077bb5c02

View File

@@ -5,9 +5,12 @@
*/ */
#include "system.h" #include "system.h"
#include <filesystem>
#include <minres/timer.h> #include <minres/timer.h>
#include <minres/uart.h> #include <minres/uart.h>
#include <scc/utilities.h> #include <scc/utilities.h>
#include <util/ihex.h>
#include <vector>
namespace vp { namespace vp {
@@ -29,7 +32,7 @@ using namespace vpvper::minres;
system::system(sc_core::sc_module_name nm) system::system(sc_core::sc_module_name nm)
: sc_core::sc_module(nm) : sc_core::sc_module(nm)
, NAMED(ahb_router, 6, 2) , NAMED(ahb_router, 7, 2)
, NAMED(apbBridge, PipelinedMemoryBusToApbBridge_map.size(), 1) { , NAMED(apbBridge, PipelinedMemoryBusToApbBridge_map.size(), 1) {
mtime_clk = (1.0 / 32768) * 1_sec; 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(eth1.socket, 2, 0x11001000, 4_KiB);
ahb_router.bind_target(qspi.xip_sck, 3, 0x20000000, 16_MB); 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_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; size_t i = 0;
for(const auto& e : PipelinedMemoryBusToApbBridge_map) { for(const auto& e : PipelinedMemoryBusToApbBridge_map) {
apbBridge.initiator.at(i)(e.target); apbBridge.initiator.at(i)(e.target);
@@ -111,4 +115,33 @@ void system::gen_reset() {
rst_s = 1; 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 } // namespace vp

View File

@@ -7,7 +7,6 @@
#ifndef SRC_VP_SYSTEM_H_ #ifndef SRC_VP_SYSTEM_H_
#define SRC_VP_SYSTEM_H_ #define SRC_VP_SYSTEM_H_
#include "tlm/scc/quantum_keeper.h"
#include <cci_configuration> #include <cci_configuration>
#include <minres/aclint.h> #include <minres/aclint.h>
#include <minres/ethmac.h> #include <minres/ethmac.h>
@@ -26,6 +25,7 @@
#include <sysc/kernel/sc_module.h> #include <sysc/kernel/sc_module.h>
#include <sysc/kernel/sc_time.h> #include <sysc/kernel/sc_time.h>
#include <sysc/utils/sc_vector.h> #include <sysc/utils/sc_vector.h>
#include <tlm/scc/quantum_keeper.h>
#include <tlm/scc/tlm_signal_sockets.h> #include <tlm/scc/tlm_signal_sockets.h>
namespace vp { namespace vp {
@@ -47,6 +47,8 @@ public:
eth::eth_pkt_initiator_socket<> eth1_tx{"eth1_tx"}; eth::eth_pkt_initiator_socket<> eth1_tx{"eth1_tx"};
eth::eth_pkt_target_socket<> eth1_rx{"eth1_rx"}; 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<sc_core::sc_time> clk_i{"clk_i"};
sc_core::sc_in<bool> erst_n{"erst_n"}; 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<256_kB, scc::LT> mem_ram{"mem_ram"};
scc::memory<1_GB, scc::LT> mem_dram{"mem_dram"}; scc::memory<1_GB, scc::LT> mem_dram{"mem_dram"};
scc::memory<8_kB, scc::LT> boot_rom{"boot_rom"}; 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<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_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_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"}; sc_core::sc_signal<uint64_t> mtime_s{"mtime_s"};
std::vector<uint8_t> trace_buffer;
void gen_reset(); void gen_reset();
void start_of_simulation() override;
void end_of_simulation() override;
}; };
} // namespace vp } // namespace vp

2
vpvper

Submodule vpvper updated: 1f5391b5a3...c2b3ab2962