I want to convert the data in a wire to an integer. For instance:
wire [2:0] w = 3'b101;
I need a method that converts it to "5" and stores it in integer form. How can I do this better than this:
j=1; for(i=0; i<=2; i=i+1) begin a=a+(w[i]*j); j=j*2; end
Also, how do I convert it back to binary as soon as I have a value in an integer? It seems awkward. Thanks.
source share