EdaphicStudio / SystemVerilog

Public issue tracker for Edaphic.Studio/SV
MIT License
0 stars 0 forks source link

Macro issue in UVM ubus example - ubus_example_master_seq_lib.sv #12

Closed EdaphicStudio closed 5 years ago

EdaphicStudio commented 5 years ago

The UBUS example generates an incorrect syntax error(see image):

screen shot 2018-10-08 at 10 45 16 am
class incr_read_byte_seq extends ubus_base_sequence;

  function new(string name="incr_read_byte_seq");
    super.new(name);
  endfunction : new

  `uvm_object_utils(incr_read_byte_seq)

  read_byte_seq read_byte_seq0;

  rand int unsigned count;
    constraint count_ct { (count < 20); }
  rand bit [15:0] start_address;
  rand int unsigned incr_transmit_del = 0;
    constraint transmit_del_ct { (incr_transmit_del <= 10); }

  virtual task body();
    `uvm_info(get_type_name(),
      $sformatf("%s starting with count = %0d", 
      get_sequence_path(), count), UVM_MEDIUM);
    repeat(count) begin : repeat_block
      `uvm_do_with(read_byte_seq0,
        { read_byte_seq0.start_addr == start_address;
          read_byte_seq0.transmit_del == incr_transmit_del; } ); // <-- ERROR HERE
      start_address++;
    end : repeat_block
  endtask : body

endclass : incr_read_byte_seq
EdaphicStudio commented 5 years ago

The issue boils down to the read_byte_seq0.randomize() with ... call inside the expanded macro.

Currently, we do not keep track of the actual text when we expand macros. We "just" work with the underlying types. So read_byte_seq0.randomize () is broken down to IDENTIFIER . IDENTIFIER () making it a generic subroutine call where with is not allowed.

Fixing this is a little tricky as randomize is not a keyword but content dependent.

The longtime solution is to improve macro text expansion to track related text. This solution means a significant rewrite of the code beyond the current scope.

I'm currently working on a short-term solution fix randomize-calls inside macros, but other similar cases might show up.

EdaphicStudio commented 5 years ago

The fix for IDENTIFIER.randomize calls is in. It works for none UVM based project. It seems UVM optimizations breaks correct expansion for another reason as well. See #13 for details.