16x1 Mux Barrel Shifter

Status
Not open for further replies.

ss_engg

Member level 5
Joined
Mar 9, 2011
Messages
81
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Pakistan
Activity points
1,854
hi
Plz help me to construct a 16x1 Mux barrel Shifter code in verilog.
The given data is that we want to move the output data
Shift left
Shift Right
Rotate Left
Rotate Right
 

Code of barrel shifter:

Type 00 for left Shift
Type 01 for right Shift
Type 10 for left Rotate
Type 11 for right Rotate

Code:

module barrel_shifter(data, type, amount, out);
input [3:0] data;
input [1:0] type;
input [1:0] amount;
output [3:0] out;
endmodule

module barrel(u, y, t, out);
input [3:0] u; %data
input [1:0] y; %type
input [1:0] t; %amount
output [3:0] out;
assign zero=(0);
MUX0 m1(u[0],zero,zero,zero,a[0],a[1],a[2],a[3],a[0],a[3],a[2],a[1],a[0],a[1],a[2],a[3],t[0],t[1], y[0],y[1],out[0]);
MUX1 m2(u[1],u[0],zero,zero,u[1],u[2],u[3],zero,u[1],u[0],u[3],u[2],u[1],u[2],u[3],u[0],u[0],u[1], y[0],y[1],out[1]);
MUX2 m3(u[2],u[1],u[0],zero,u[2],u[3],zero,zero,u[2],u[1],u[0],u[3],u[2],u[3],u[0],u[1],u[0],u[1], y[0],y[1],out[2]);
MUX3 m4(u[3],u[2],u[1],u[0],u[3],zero,zero,zero,u[3],u[2],u[1],u[0],u[3],u[0],u[1],u[2],t[0],t[1], y[0],y[1],out[3]);
endmodule
 
I didn't check all the 4 bit output, but at least, out[0] in your code is correct and I think the line of your thinking is right. There are some typo where a[0], a[1].... should be u[0], u[1]....
 

well i don't understand the input 16 bit combinations. how it would be settle there??
 

y=00 for left Shift
y=01 for right Shift
y=10 for left Rotate
y=11 for right Rotate

t[1:0] shft amount
Since it seems a homework or some sort, I'll give you only a hint.

y[1:0] and t[1:0] give you 16 different types of shift operation. Each shift operation is assigned to one of the 16 inputs of MUX16.

for example, y=01, and t=10, it's a right-shift by 2. By this operation, out[0] gets u[2], out[1] gets u[3] and out[3:2] gets zeros. Make a truth table to all the 16 different patterns for all the 4 bit outputs.
 
Last edited:

We create it by using 4 no of 16x1 Muses.. if we apply one operation e.g shift right than apply 16 bit combinations to all 4 16x1 muses..?????/
and what is meant by u[0], u[1] etc????

---------- Post added at 07:08 ---------- Previous post was at 06:18 ----------

and how the bits shifted or rotated??
 

We create it by using 4 no of 16x1 Muses.. if we apply one operation e.g shift right than apply 16 bit combinations to all 4 16x1 muses..?????/
i don't get what you mean.
and what is meant by u[0], u[1] etc????
huh ? did you not make that code you posted ?


and how the bits shifted or rotated??
Read a digital design book.
 

sir we connected 4 Mux of 16x1 and then create a barrel shifter..
Actually i want to confirm it that if we use a[3] what is meant by that??/
is it a third bit or anything else?
 

I may help you if you show some more effort rather than keep asking the questions for every tiny things that you can easily find the answer for by a simple analysis of the code.
Till then, good luck.
 
Well Sir i completed the barrel shifter code.. Thankyou very much for the Help...
well 1 thing can you know any site where we get the Xilinx ISE 8.2i software..
 

Probably in the archives on xilinx.com? As in download ISE 13, and then go to older version...
 
plz help me in constructing 16-bit barrel shifter using mux.................
 

Step 1: google
Step 2: do homework

Come on, at least pretend to be doing a little effort. If you are stuck, show the code you have so far so people can help you. If you don't have any code yet, goto 1.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…