In below code i want to get value of my_data[startbit:endbit] and store in dt. i dont want to hardcode
bit [31:0] my_data = 32'h23456789;
bit [31:0] dt = 0;
int startbit = 31; //not constant 31 ..may change this is only example
int endbit = 28;
dt = my_data[startbit:endbit]; //dont want to hardcode this as my_data[31:28]
$display("dt= %0h",dt1);
above code gave error.
So tried to replace the dt assign statement as below using $sformatf but didnt work.Can anybody help me how can i do this?
dt = $sformatf(“my_data[startbit:endbit]”);