/* =============================================================== (C) 2006 Robert Finch All rights reserved. rob@birdcomputer.ca rolx1.v Rotate or shift to the left by zero, one, two or three bits. This source code is free for use and modification for non-commercial or evaluation purposes, provided this copyright statement and disclaimer remains present in the file. If the code is modified, please state the origin and note that the code has been modified. NO WARRANTY. THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED. The user must assume the entire risk of using the Work. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES WHATSOEVER RELATING TO THE USE OF THIS WORK, OR YOUR RELATIONSHIP WITH THE AUTHOR. IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU TO USE THE WORK IN APPLICATIONS OR SYSTEMS WHERE THE WORK'S FAILURE TO PERFORM CAN REASONABLY BE EXPECTED TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN LOSS OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK, AND YOU AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS FROM ANY CLAIMS OR LOSSES RELATING TO SUCH UNAUTHORIZED USE. Rotate or shift left by 0 to 3 bits. Parameterized with a default width of 32 bits. Resource Usage Samples: Ref. SpartanII 64 LUTs Webpack 7.1i xc3s1000-4ft256 64 LUTs / 32 slices / 11 ns (32 bits) =============================================================== */ module rolx1 #(parameter WID = 32) ( input op, // 0=shift, 1= rotate input [WID:1] a, input [1:0] b, output reg [WID:1] o ); wire [2:0] opx = {3{op}}; always @(a, b, opx) begin case(b) 2'd0: o <= a; 2'd1: o <= {a[WID-1:1],a[WID]&opx[0]}; 2'd2: o <= {a[WID-2:1],a[WID:WID-1]&opx[1:0]}; 2'd3: o <= {a[WID-3:1],a[WID:WID-2]&opx[2:0]}; endcase end endmodule