I am relatively inexperienced in Verilog and very new to the LFSR construct. What I would like to accomplish is as follows..
If I have a 5 byte array, that would imply max permutations of 5! or 120. What I'd like to be able to do is, have a way to quickly return any permutation of this array. If I init the array to (0,1,2,3,4), then for this 5 deep array, permutation 0 yields the array (1,2,3,4,0). Permutation 40 yields the array (4,0,3,2,1), etc.
So I think a LFSR is the quickest way to accomplish this, and I understand how they work, but I cannot get to a complete understanding of what the taps should be or how to get a particular permutation only.
reg [4:0] vals;
wire feedback
assign feedback = vals[0] ^ vals[1] ^ vals[2] ^ vals[3] ^ vals[4];
always@(posedge clk or negedge reset) begin
if (reset==1'b0) begin
vals[4:0]<=5'hF; //reset condition first
end
else begin
vals[0]<=feedback;
vals[1]<=vals[0];
vals[2]<=vals[1];
vals[3]<=vals[2];
vals[4]<=vals[3];
end
Clearly that feedback is not going to work! I am just stuck trying to get the entire comtext straight in my brain. How do I make it go to a certain permutation? How many taps are needed based on the size of the array? Any help is greatly appreciated!