Elegant way to define range of bits

In reply to Michael54:
May not be what you exactly want, but it’s a step in the right direction.


//xpected_txn.raw_data[rgb_pos-:5] = data_range_bus[28:24];
//expected_txn.raw_data[rgb_pos+6-:6] = data_range_bus[17:12];
module m;
  bit[31:0] v;
  let FIRST_RANGE =v[28:24];
  let SECOND_RANGE=v[17:12];
  
  initial begin
    FIRST_RANGE= 5'b11111;
    SECOND_RANGE=6'b110011;
    $display("v= %b", v);
  end
endmodule
// run 1ns
// # v= 00011111000000110011000000000000

    //expected_txn.raw_data[rgb_pos-:5] = data_range_bus[FIRST_RANGE];
    // expected_txn.raw_data[rgb_pos+6-:6] = data_range_bus[SECOND_RANGE];

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
** SVA Handbook 4th Edition, 2016 ISBN 978-1518681448

  1. SVA Package: Dynamic and range delays and repeats SVA: Package for dynamic and range delays and repeats | Verification Academy
  2. Free books: Component Design by Example FREE BOOK: Component Design by Example … A Step-by-Step Process Using VHDL with UART as Vehicle | Verification Academy
    Real Chip Design and Verification Using Verilog and VHDL($3) https://rb.gy/cwy7nb
  3. Papers:

Udemy courses by Srinivasan Venkataramanan (http://cvcblr.com/home.html)
https://www.udemy.com/course/sva-basic/
https://www.udemy.com/course/sv-pre-uvm/