Commentary: Add some more details to the vpi example (#3925)
This commit is contained in:
parent
82f450d838
commit
d2aff13402
|
|
@ -374,9 +374,11 @@ changed on the specified clock edge.
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
cat >our.v <<'EOF'
|
cat >our.v <<'EOF'
|
||||||
module our (input clk);
|
module our #(
|
||||||
reg readme /*verilator public_flat_rd*/;
|
parameter WIDTH /*verilator public_flat_rd*/ = 32
|
||||||
reg writeme /*verilator public_flat_rw @(posedge clk) */;
|
) (input clk);
|
||||||
|
reg [WIDTH-1:0] readme /*verilator public_flat_rd*/;
|
||||||
|
reg [WIDTH-1:0] writeme /*verilator public_flat_rw @(posedge clk) */;
|
||||||
initial $finish;
|
initial $finish;
|
||||||
endmodule
|
endmodule
|
||||||
EOF
|
EOF
|
||||||
|
|
@ -398,12 +400,14 @@ accesses the above signal "readme" would be:
|
||||||
vpiHandle vh1 = vpi_handle_by_name((PLI_BYTE8*)"TOP.our.readme", NULL);
|
vpiHandle vh1 = vpi_handle_by_name((PLI_BYTE8*)"TOP.our.readme", NULL);
|
||||||
if (!vh1) vl_fatal(__FILE__, __LINE__, "sim_main", "No handle found");
|
if (!vh1) vl_fatal(__FILE__, __LINE__, "sim_main", "No handle found");
|
||||||
const char* name = vpi_get_str(vpiName, vh1);
|
const char* name = vpi_get_str(vpiName, vh1);
|
||||||
printf("Module name: %s\n", name); // Prints "readme"
|
const char* type = vpi_get_str(vpiType, vh1);
|
||||||
|
const int size = vpi_get(vpiSize, vh1);
|
||||||
|
printf("register name: %s, type: %s, size: %d\n", name, type, size); // Prints "register name: readme, type: vpiReg, size: 32"
|
||||||
|
|
||||||
s_vpi_value v;
|
s_vpi_value v;
|
||||||
v.format = vpiIntVal;
|
v.format = vpiIntVal;
|
||||||
vpi_get_value(vh1, &v);
|
vpi_get_value(vh1, &v);
|
||||||
printf("Value of v: %d\n", v.value.integer); // Prints "readme"
|
printf("Value of %s: %d\n", name, v.value.integer); // Prints "Value of readme: 0"
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue