mirror of
https://github.com/verilator/verilator.git
synced 2025-01-01 04:07:34 +00:00
Fix vpiInertialDelay for memories (#5113)
This commit is contained in:
parent
d99c8f5d44
commit
19cccd170e
@ -631,16 +631,14 @@ public:
|
||||
};
|
||||
|
||||
class VerilatedVpiPutHolder final {
|
||||
const VerilatedVar* m_varp;
|
||||
const VerilatedScope* m_scopep;
|
||||
VerilatedVpioVar m_var;
|
||||
s_vpi_value m_value;
|
||||
std::string m_str;
|
||||
std::vector<s_vpi_vecval> m_vector;
|
||||
|
||||
public:
|
||||
VerilatedVpiPutHolder(const VerilatedVpioVar* vop, p_vpi_value valuep)
|
||||
: m_varp(vop->varp())
|
||||
, m_scopep(vop->scopep()) {
|
||||
: m_var(vop) {
|
||||
m_value.format = valuep->format;
|
||||
switch (valuep->format) {
|
||||
case vpiBinStrVal:
|
||||
@ -691,8 +689,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
const VerilatedVar* varp() { return m_varp; }
|
||||
const VerilatedScope* scopep() { return m_scopep; }
|
||||
VerilatedVpioVar* varp() { return &m_var; }
|
||||
p_vpi_value valuep() { return &m_value; }
|
||||
|
||||
static bool canInertialDelay(p_vpi_value valuep) {
|
||||
@ -912,8 +909,7 @@ public:
|
||||
}
|
||||
static void doInertialPuts() {
|
||||
for (auto it : s().m_inertialPuts) {
|
||||
VerilatedVpioVar vo(it.varp(), it.scopep());
|
||||
vpi_put_value(vo.castVpiHandle(), it.valuep(), nullptr, vpiNoDelay);
|
||||
vpi_put_value(it.varp()->castVpiHandle(), it.valuep(), nullptr, vpiNoDelay);
|
||||
}
|
||||
s().m_inertialPuts.clear();
|
||||
}
|
||||
|
@ -700,6 +700,14 @@ int _mon_check_delayed() {
|
||||
vpi_get_value(vh, &v);
|
||||
CHECK_RESULT(v.value.integer, 0);
|
||||
|
||||
TestVpiHandle vhMem = VPI_HANDLE("delayed_mem");
|
||||
CHECK_RESULT_NZ(vhMem);
|
||||
TestVpiHandle vhMemWord = vpi_handle_by_index(vhMem, 7);
|
||||
CHECK_RESULT_NZ(vhMemWord);
|
||||
v.value.integer = 456;
|
||||
vpi_put_value(vhMemWord, &v, &t, vpiInertialDelay);
|
||||
CHECK_RESULT_Z(vpi_chk_error(nullptr));
|
||||
|
||||
// test unsupported vpiInertialDelay cases
|
||||
v.format = vpiStringVal;
|
||||
v.value.str = nullptr;
|
||||
|
@ -42,6 +42,7 @@ extern "C" int mon_check();
|
||||
reg [31:0] count /*verilator public_flat_rd */;
|
||||
reg [31:0] half_count /*verilator public_flat_rd */;
|
||||
reg [31:0] delayed /*verilator public_flat_rw */;
|
||||
reg [31:0] delayed_mem [16] /*verilator public_flat_rw */;
|
||||
|
||||
reg [7:0] text_byte /*verilator public_flat_rw @(posedge clk) */;
|
||||
reg [15:0] text_half /*verilator public_flat_rw @(posedge clk) */;
|
||||
@ -104,6 +105,7 @@ extern "C" int mon_check();
|
||||
|
||||
if (count == 1000) begin
|
||||
if (delayed != 123) $stop;
|
||||
if (delayed_mem[7] != 456) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
@ -57,6 +57,7 @@ extern "C" int mon_check();
|
||||
/*verilator public_off*/
|
||||
/*verilator public_flat_rw_on*/
|
||||
reg [31:0] delayed;
|
||||
reg [31:0] delayed_mem [16];
|
||||
/*verilator public_off*/
|
||||
reg invisible2;
|
||||
|
||||
@ -124,6 +125,7 @@ extern "C" int mon_check();
|
||||
|
||||
if (count == 1000) begin
|
||||
if (delayed != 123) $stop;
|
||||
if (delayed_mem[7] != 456) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
@ -42,6 +42,7 @@ extern "C" int mon_check();
|
||||
reg [31:0] count;
|
||||
reg [31:0] half_count;
|
||||
reg [31:0] delayed;
|
||||
reg [31:0] delayed_mem [16];
|
||||
|
||||
reg [7:0] text_byte;
|
||||
reg [15:0] text_half;
|
||||
@ -104,6 +105,7 @@ extern "C" int mon_check();
|
||||
|
||||
if (count == 1000) begin
|
||||
if (delayed != 123) $stop;
|
||||
if (delayed_mem[7] != 456) $stop;
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user