Skip to content

Commit

Permalink
[dv] Add hyperram memory area to verilator simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
GregAC authored and marnovandermaas committed Aug 30, 2024
1 parent 6a547d4 commit 1abbb1b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 5 additions & 2 deletions dv/verilator/sonata_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include "verilator_memutil.h"
#include "verilator_sim_ctrl.h"

SonataSystem::SonataSystem(const char *ram_hier_path, int ram_size_words)
: _ram(ram_hier_path, ram_size_words, 4) {}
SonataSystem::SonataSystem(const char *ram_hier_path, int ram_size_words,
const char *hyperram_hier_path, int hyperram_size_words)
: _ram(ram_hier_path, ram_size_words, 4),
_hyperram(hyperram_hier_path, hyperram_size_words, 4) {}

int SonataSystem::Main(int argc, char **argv) {
bool exit_app;
Expand All @@ -40,6 +42,7 @@ int SonataSystem::Setup(int argc, char **argv, bool &exit_app) {
VerilatorSimCtrlFlags::ResetPolarityNegative);

_memutil.RegisterMemoryArea("ram", 0x100000, &_ram);
_memutil.RegisterMemoryArea("hyperram", 0x40000000, &_hyperram);
simctrl.RegisterExtension(&_memutil);

exit_app = false;
Expand Down
4 changes: 3 additions & 1 deletion dv/verilator/sonata_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

class SonataSystem {
public:
SonataSystem(const char *ram_hier_path, int ram_size_words);
SonataSystem(const char *ram_hier_path, int ram_size_words,
const char *hyperram_hier_path, int hyperram_size_words);
virtual ~SonataSystem() {}
virtual int Main(int argc, char **argv);

Expand All @@ -16,6 +17,7 @@ class SonataSystem {
top_verilator _top;
VerilatorMemUtil _memutil;
MemArea _ram;
MemArea _hyperram;

virtual int Setup(int argc, char **argv, bool &exit_app);
virtual void Run();
Expand Down
5 changes: 4 additions & 1 deletion dv/verilator/sonata_system_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
int main(int argc, char **argv) {
SonataSystem sonata_system(
"TOP.top_verilator.u_sonata_system.u_sram_top.u_ram.gen_generic.u_impl_generic",
1024 * 1024);
32 * 1024, // 32k words = 128 KiB
"TOP.top_verilator.u_sonata_system.g_hyperram.u_hyperram.u_hyperram_model.u_ram.gen_generic.u_impl_generic",
256 * 1024 // 256k words = 1 MiB
);

return sonata_system.Main(argc, argv);
}

0 comments on commit 1abbb1b

Please sign in to comment.