Hello My que. is I have variable a which is int. and direct give value of 'h2431_6578;
which I have to arrange in ascending order. I blindly know that to arrange this by streaming operator I did use it at once but,I stucked to arrange.So,kidly help to resolve this que.
Need to answer as 'h12345678.
In reply to Davebhai:
I used the below function. I haven’t tried streaming operators. We could use constraints as well; but I haven’t tried it yet.
// Code your testbench here
// or browse Examples
module test();
int a = 32'h2431_6578;
int b;
initial begin
b = sort_64bit(a);
$display("a=%0h",a);
$display("b=%0h",b);
end
function int sort_64bit(input int l_input);
bit [3:0] temp[$];
foreach(l_input[i]) begin
if((i%4)==0) temp.push_back(l_input[i+:4]);
end
temp.sort();
temp.reverse();
foreach(temp[i]) begin
sort_64bit[(i*4)+:4] = temp[i];
end
endfunction
endmodule
In reply to KillSteal:
Thank you so much Brother.