mrforever Posted January 16, 2013 Report Share Posted January 16, 2013 Hi all, If i want to implement such a reverse function, does anybody have other ways? function bit[WIDTH-1:0] reverse(int WIDTH, bit[WIDTH-1:0] data); bit[WIDTH-1:0] data_rvs; for(int i=0; i<WIDTH; i++ data_rvs = data[WIDTH-1-i]; return data_rvs; endfunction : reverse The code above has vcs compile error because of the return value which cann't have variable expression. Quote Link to comment Share on other sites More sharing options...
dave_59 Posted January 16, 2013 Report Share Posted January 16, 2013 Streaming operator {<<{expression_to_reverse}} Quote Link to comment Share on other sites More sharing options...
adielkhan Posted January 16, 2013 Report Share Posted January 16, 2013 or use SV1800 reverse() array manipulation. program prog; parameter WIDTH=16; bit [WIDTH-1:0] data ; initial begin data = 'h5aa5; $display("%0x",data); data.reverse(); $display("%0x",data); end endprogram Quote Link to comment Share on other sites More sharing options...
dave_59 Posted January 16, 2013 Report Share Posted January 16, 2013 SV1800 LRM defines array manipulation methods to only work on unpacked arrays. One reason for this is when you have multidimensional array with a mixture of unpacked and packed array dimensions, the manipulation does not apply to the packed dimensions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.