Is there a way to truncate leading 0s of data, automatically without using any manipulation?
So if design read out data is ‘h006f834e, and it is being stored in a variable, is there a way to automatically omit the leading 0s and store as ‘h6f834e?
i don’t think i understand question properly, but consider for any variable for example bit[31:0] val = 'hFFFF; we didn’t assign any value to upper 16 bits val[31:16] and the value val[31:16] is 'h0000 which default in nature, but design has to read total bit width to get any variable total value…
suppose if we know the total bits that design can use then val_1[15:0] = 'hFFFF; (i.e. use bit slicing to truncate leading 0’s)
I’m not sure what you mean by “read out”. Variables in digital logic have a fixed number of binary digits. Each digit must be a 0 or 1. If by read out you mean $display, then the “%0h” display formant suppresses the 2 leading 0’s, and “%0b” would suppress 9 leading 0’s.
In reply to UVM_learner6:
I’m not sure what you mean by “read out”. Variables in digital logic have a fixed number of binary digits. Each digit must be a 0 or 1. If by read out you mean $display, then the “%0h” display formant suppresses the 2 leading 0’s, and “%0b” would suppress 9 leading 0’s.
I read data from the fifo 4 times using this :
mtu_out_fifo.get(dout_tx);
I concatenate the 4 readouts like this :
full_256b_o_pcie_pkt_wr_data = {fourth_64b_o_pcie_pkt_wr_data, third_64b_o_pcie_pkt_wr_data, second_64b_o_pcie_pkt_wr_data, first_64b_o_pcie_pkt_wr_data};
In this “full_256b_o_pcie_pkt_wr_data”, if I get data that has leading 0s like this :
full_256b_o_pcie_pkt_wr_data after the get is 00006a8e056c1fde6a8e056c1fde34bb2610f33f7e7f6905f018bf9d8385d82e
I would like to truncate the 4 leading 0s.
Is there any function call or any other automatic way to do it? Otherwise, I would have to detect number of leading 0s and bit shift them out or manipulate some other way.