Accessing Environment Variable in rom1p1r.sv
Created by: europe2024
Below is the platform.
Verilator 5.025 devel rev v5.024-5-g1012c054e
variant of Debian (version 12) on ARM
The following line
$readmemh("$WALLY/fpga/src/boot.mem", ROM, 0);
in
$WALLY/src/generic/mem/rom1p1r.sv
uses environment-variable $WALLY, but Verilator does not automatically generate code to get its value.
Below is one way to access $WALLY.
rom1p1r.sv
----------
import "DPI-C" function string getenvval(input string env_name);
$readmemh({getenvval("WALLY"), "/fpga/src/boot.mem"}, ROM, 0);
clangwrapper.c
--------------
#include <stdio.h>
#include <stdlib.h>
#include "Vtestbench__Dpi.h"
const char *getenvval(const char *pszName) {
return ((const char *) getenv(pszName));
}