Skip to content

Commit

Permalink
Make dump VCD levels configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnbastiaan committed Jan 10, 2025
1 parent 5123912 commit 42f1582
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions clash-vexriscv/src/VexRiscv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ data CpuOut = CpuOut
}
deriving (Generic, NFDataX, ShowX, Eq, BitPack)

data DumpVcd = DumpVcd FilePath | NoDumpVcd
data DumpVcd = DumpVcd { vcdPath :: FilePath, vcdLevels :: Int } | NoDumpVcd


data Jtag (dom :: Domain)
Expand Down Expand Up @@ -532,9 +532,9 @@ vexCPU dumpVcd = do
v <- vexrInit
vcd <- case dumpVcd of
NoDumpVcd -> pure nullPtr
DumpVcd path -> do
DumpVcd path levels -> do
vcdPath <- newCString path
vexrInitVcd v vcdPath
vexrInitVcd v vcdPath levels

let
{-# NOINLINE initStage1 #-}
Expand Down
2 changes: 1 addition & 1 deletion clash-vexriscv/src/VexRiscv/FFI.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data VerilatedVcdC
data VexRiscvJtagBridge

foreign import ccall unsafe "vexr_init" vexrInit :: IO (Ptr VexRiscv)
foreign import ccall unsafe "vexr_init_vcd" vexrInitVcd :: Ptr VexRiscv -> CString -> IO (Ptr VerilatedVcdC)
foreign import ccall unsafe "vexr_init_vcd" vexrInitVcd :: Ptr VexRiscv -> CString -> Int -> IO (Ptr VerilatedVcdC)
foreign import ccall unsafe "vexr_shutdown" vexrShutdown :: Ptr VexRiscv -> IO ()

foreign import ccall unsafe "vexr_init_stage1" vexrInitStage1 :: Ptr VerilatedVcdC -> Ptr VexRiscv -> Ptr NON_COMB_INPUT -> Ptr OUTPUT -> IO ()
Expand Down
8 changes: 3 additions & 5 deletions clash-vexriscv/src/ffi/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef struct {

extern "C" {
VVexRiscv *vexr_init();
VerilatedVcdC *vexr_init_vcd(VVexRiscv *top, const char *path);
VerilatedVcdC *vexr_init_vcd(VVexRiscv *top, const char *path, int levels);
void vexr_shutdown(VVexRiscv *top);

void vexr_init_stage1(VerilatedVcdC *vcd, VVexRiscv *top,
Expand Down Expand Up @@ -61,12 +61,10 @@ VVexRiscv *vexr_init() {
return v;
}

VerilatedVcdC *vexr_init_vcd(VVexRiscv *top, const char *path) {
VerilatedVcdC *vexr_init_vcd(VVexRiscv *top, const char *path, int levels) {
VerilatedVcdC *vcd = new VerilatedVcdC;
Verilated::traceEverOn(true);
// Trace 99 levels of the hierarchy. We only have one level AFAIK, so this
// should be enough :-).
top->trace(vcd, 99);
top->trace(vcd, levels);
vcd->open(path);
return vcd;
}
Expand Down

0 comments on commit 42f1582

Please sign in to comment.