Translating System Verilog code to system C

I am trying to convert the following line of code to system C, any suggestion or clue would be helpful (trying to find exact translation)

l_lcm_num = (buff_id>>8)&2'h3;

  1. verilog bit [DWIDTH-1:0] fdata[longint][$];

  1. verilog void'($ungetc(c,fp));

In reply to Rogers:

These constructs need to be translated to C++; there is nothing directly in SystemC that would help you.

  1. Strange way to write buff_id[9:8] in SystemVerilog, but the equivalent in C++ is
    l_lcm_num = (buff_id>>8)& 0x3;
    or better readability
    l_lcm_num = (buff_id0 & x0180) >> 8;
  2. This is an associative array of queues in SystemVerilog. You will have to translate this using the Standard Template Library(STL) Map and Queue templates. Translating the declaration is trivial—the usage is more effort.
  3. This has a direct translation to C/C++ unget().

In reply to dave_59:
Thank you very much

In reply to dave_59:

And for reporting messages can you please inform me how can we translate for below…? basically I am trying to find the right format to translate them

`uvm_error(get_type_name(), $psprintf("LCM Read Addr x=%0d y=%0d num=%0d greater than size=%0d",x,y,num,sbuff_size));

  1. verilog $write("%d:", y);

  1. verilog `uvm_info(get_type_name(), $psprintf("data[%0x] = 0x%20x",y*h_pitch((x+i)%h_pitch),data[y*h_pitch+((x+i)%h_pitch)]), UVM_HIGH);

  1. verilog $fdisplay(fp, "%08x: %80x %80x %80x %80x", i, data[i*4+3], data[i*4+2], data[i*4+1], data[i*4]);

and this expression

 data[y*h_pitch+((x+i)%h_pitch)] = wdata[(QWWIDTH-1)+QWWIDTH*i -: QWWIDTH];

In reply to Rogers:

`uvm_info/error macro functionary was directly copied from SystemC’s SC_REPORT_INFO/ERROR macros. The first argument is a string ID used to control filtering and actions associated with a particular set of messages. How you convert that depends on how you need to control these messages.

You will need to learn C++ string formatting and file I/O capabilities for converting $psprintf, $write, and $fdisplay. This might also depend on the version of C++ you are using as C++ is always making enhancements here.

Look for the range() method in SystemC to convert the -: index part select.

In reply to dave_59:

I tried to find some examples but could not find any which could help me to translate, how would you have done this from your perspective?

In reply to dave_59:

Ok i manged to solve -: using range operator as follows


long long int temp_idx = (QWWIDTH-1)+QWWIDTH*i ;

data[y*h_pitch+((x+i)%h_pitch)]=wdata.range(temp_idx,temp_idx - (QWWIDTH-1));

But the display statements still I am trying to find the solution …