Understanding Barrel Shifting in VHDL: A 16-bit Implementation

  • Thread starter Thread starter EvLer
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the implementation of a 16-bit barrel shifter in VHDL, focusing on understanding the mechanics of shifting bits through a series of stages as described in a lab document. Participants explore the concept of barrel shifting, its structure, and the logic behind enabling different stages to achieve various shift amounts.

Discussion Character

  • Homework-related, Technical explanation, Conceptual clarification

Main Points Raised

  • One participant describes the barrel shifter as a combinational logic device with four stages, where each stage can either shift or not shift, allowing for a total shift amount based on the binary representation of the shift value.
  • Another participant proposes a configuration of four shifters wired in series, each followed by a multiplexer (mux) to enable or bypass shifting, allowing for shifts from zero to fifteen bits.
  • A participant confirms their understanding of the shifting process by providing an example of shifting left by 10, detailing the intermediate results after each stage.
  • There is a question raised about the maximum number of shifts possible, specifically whether it is limited to 15 shifts.

Areas of Agreement / Disagreement

Participants generally agree on the mechanics of how the barrel shifter operates, but there is some uncertainty regarding the maximum number of shifts and the interpretation of the lab document's description.

Contextual Notes

The discussion reflects varying levels of understanding of the barrel shifter concept, with some assumptions about the operation of the shifters and the role of the muxes that may not be fully clarified.

EvLer
Messages
454
Reaction score
0

Homework Statement


A, and B both are 16 bits wide; A is entity to shift and B is by how much;
we are supposed to implement a BARREL shifter. And here's the explanation (which does not make much sense to me, esp. the example) given in lab document:

A barrel shifter is a combinational logic device that incrementally shifts in stages. In our barrel shifter, we will have 4 stages. Each stage can choose to shift or not to shift, giving any total shift amount. For example, to shift an input by 9, stages one and four will shift 1 time and 8 times, respectively. Stages two and three will not shift. Notice that the binary number 9 is "1001". How convenient that the fourth bit and the first bit are 1 and the second and the third bits are 0.

The Attempt at a Solution


ok, I know how to write the shift register, a regular without the "barrel", and after some googling, I found that barrel basically shifts by the amounts of bits specified at once. If someone could explain how the description from the lab document makes sense that is all i need to understand... thanks in advance.
 
Physics news on Phys.org
I presume you have four shifters wired up in series, the output of one connected to the input of the next. Each shifter is also followed by a mux, so that you can bypass each shifter if you do not wish to use it.

The first shifter shifts only one bit position. If the value put into the first shifter is 10010010, you'll get out 00100100.

The second shifter shifts two bit positions. If you put in 10010010, you'll get out 01001000.

The third shifter shifts four bit positions, and the fourth shifter shifts eight bit positions.

By "enabling" some combination of these individual shifters (i.e. by not bypassing them with a mux), any total shift from zero bits to fifteen bits is possible. Note that this device is really nothing more than muxes and wires.

- Warren
 
Last edited:
ok, that makes a bit more sense...
so, just to make sure, let's say he wants us to shift left by 10, which is "1010" then shifter 2 and 4 are enabled, so I will shift by 2 first and then by 8, right?
So if the input is "1010 0111 0001"
then I will have after shifter 2: "1001 1100 0100"
then after shifter 4: "0100 0000 0000 0000"

edit: one more thing: it seems like I will be able to shift only 15 times is that how it's supposed to work out?:rolleyes:

thanks sooo much...
 
Last edited:
that looks correct to me :smile:
 

Similar threads

  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
1
Views
3K
Replies
9
Views
37K
Replies
7
Views
15K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
Replies
1
Views
5K
Replies
17
Views
7K