nvc icon indicating copy to clipboard operation
nvc copied to clipboard

VHPI: Preserve original name case for CaseNameP and FullCaseNameP

Open Forty-Bot opened this issue 1 year ago • 4 comments

CaseNameP and FullCaseNameP are specified to use "...the case of letters in the identifier of the ... declaration." However, we currently always return these properties as uppercase.

I don't think this is particularly high priority (and would likely take a lot of effort to resolve). However, the cocotb folks requested that a tracking issue be created for this deviation.

Forty-Bot avatar Jun 18 '23 23:06 Forty-Bot

I don't really want to track the original case of identifiers in addition to the normalised uppercase identifier so I've implemented this in a slightly hacky/best-effort way for declarations using the source location to find the original identifier in the file and fall back to the upper-case name if that doesn't work. Seems to work ok in my limited testing.

nickg avatar Jun 24 '23 11:06 nickg

There were two main bugs I saw related to CaseName:

  • Cocotb asks for something in lowercase and is surprised when we give it something in uppercase
  • Cocotb gets a handle via vhpi_scan and gets the same handle later via vhpi_handle_by_name and gets confused when the names aren't the same.

So this really needs to be accompanied by making vhpi_handle_by_name case-sensitive, which also means converting the other (Full)CaseNames (in c_name etc.).


That said I've been pretty happy with my solution of just converting all requested identifiers to uppercase in cocotb.

Forty-Bot avatar Jun 24 '23 14:06 Forty-Bot

That said I've been pretty happy with my solution of just converting all requested identifiers to uppercase in cocotb.

Yes if they can live with that it would be much simpler.

nickg avatar Jun 24 '23 14:06 nickg

Yes if they can live with that it would be much simpler.

Unfortunately we can't since we service SV code as well. We can't know what PLI interface returned an object, nor the original source language of any object, due to the abstraction of the GPI. Nor do we want to know, as that's the whole point of abstracting the interface away.

ktbarrett avatar Jun 27 '24 15:06 ktbarrett