I have fixed my problem but I don’t entirely understand exactly why one solution worked and the other attempt did not work.
In a testbench I have an initial block that is reading lines out of a command stimulus file and parsing them. In this block I have the following code snippet (the comment is referring to the solution as I’ve had to recreate the original situation for this post, so it’s not applicable in this first snippet):
// Process to the end of the file.
while (!$feof(cmd_fd)) begin
if ($fgets(cmd_str, cmd_fd)) begin
// Original design: Synchronize on slowest clock.
// TODO: May need some other synchronization process.
@(posedge zynq_clk_125);
cmd = parse_cmd_line(cmd_str);
// Have to explicitly cast these as just so happens that the
// same tokens were used in an enumeration in Delegate package.
case (cmd.cmd_type)
TST_LOG_NAME: do_tst_log_name(cmd, tst);
TST_GROUP: do_tst_heading(cmd, tst);
TST_STEP: do_tst_heading(cmd, tst);
TST_INST: do_tst_heading(cmd, tst);
TST_REQ: do_tst_req(cmd, tst);
TST_ASSERT_REQ: do_tst_req(cmd, tst);
DLGT_EQ: do_dlgt_eq(cmd, tst, spi_bfm_mb);
DLGT_EQ_LIST: do_dlgt_eq_list(cmd, tst);
...
Now, by accident, it turns out that some of these tokens were used identically in another package.
I got the following errors:
# ** Error (suppressible): ./../../testbench/src/gra_tb_v2.sv(245): (vlog-2542) Identifier 'TST_GROUP' is not directly visible.
# Found multiple Declaration of 'TST_GROUP' through wildcard imports from these packages : cmd_file_pkg (imported at './../../testbench/src/gra_tb_v2.sv:44'), delegate_intrf_pkg (imported at './../../testbench/src/gra_tb_v2.sv:48')
# If suppressed, the declaration from the first imported package will be used.
# ** Error: ./../../testbench/src/gra_tb_v2.sv(245): (vlog-2730) Undefined variable: 'TST_GROUP'.
Alright, it’s seeing that there have been multiple declarations of the token “TST_GROUP”. So, I tried this. The tokens I want to use are in my cmd_file_pkg in the known_cmds_t enumerated typedef:
case (cmd.cmd_type)
...
known_cmds_t'(TST_GROUP): do_tst_heading(cmd, tst);
...
However this ended up producing the same error. I tried this next:
case (cmd.cmd_type)
...
cmd_file_pkg::TST_GROUP: do_tst_heading(cmd, tst);
...
This works.
So, my question is why did the explicit scope reference work and the explicit typecast did not work? It seems like both resolve the ambiguity of the token name.
Thanks for any thoughts!