Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to achieve bit shift by logic gates

Status
Not open for further replies.

s0g0

Newbie level 5
Joined
Jun 30, 2006
Messages
8
Helped
24
Reputation
48
Reaction score
25
Trophy points
1,283
Activity points
1,358
e.g. I have a binary number 11001001 -> now, i want it to be divided by 16, then i have to shift it to right (LSB) by 4 bits (2^4=16) ->so I get 00001100, but how can i achieve it in hardware via logic gates?
 

Re: How to achieve bit shift by logic gates?

You don't need any logic gates, just connect the bits shifted. The bit assignment for the high bits shifted in is different for a number representation of unsigned or signed. Either '0' or replicating the MSB.
 

    s0g0

    Points: 2
    Helpful Answer Positive Rating
Re: How to achieve bit shift by logic gates?

Hi,
Do you actually want to just have a hard wired result that always divides an input byte by 16, which is what FvM has given you, or do you want to do actual mathmatical manipulation in the hardware? If for example you wanted to switch between the number or the number divided by 16 you would have to use a multiplexer circuit that selected the top 4 bits of your number and swapped them into the four lower bits and set the four upper bits were to zeros.

I am not quite sure quite what you really want to do? Please give us more details.

Bob
 

    s0g0

    Points: 2
    Helpful Answer Positive Rating
How to achieve bit shift by logic gates?

Many thanks for FvM and DrBob13, I need to divide my binary signal by 16, so can I know more details for FvM's operation? How to replicate the MSB and What the wiring exactly looks like for "shift in" ? I am really new for elec design.
 

//unsigned
o[7] = 0;o[6] = 0;o[5] = 0;o[4] = 0;o[3] = i[7];o[2] = i[6];o[1] = i[5];o[0] = i[4];

//signed
o[7] = i[7];o[6] = i[7];o[5] = i[7];o[4] = i[7];o[3] = i[7];o[2] = i[6];o[1] = i[5];o[0] = i[4];
 

Thanks for your great help, FvM.
Now I am able to shift the bits now. Here I want to ask some questions regarding floating point algorithm for binary numbers. I hope you can guide me again by your profound learning.
Currently, I am working on a prediction circuit design for ADC. Some of binary algorithms are involved.
Consider this example. Take A negative: A= 1100 1010. Now to divide by 16 we do right shift again (but we also have to replicate the sign bit in the left as you said). So now A/16 = 1111 1100. So base on my design, the next operation is to subtract: A-A/16=1100 1010 - 1111 1100. Now if you noted before we are throwing the 4 least significant bits, which is rounding the result division to nearest integer. If you don't want this then you can consider 4 bits associated to 2^{-1}, 2^{-2}, 2^{-3} and 2^{-4} as well, and we need 12-bit subtraction. In the examples given above you will do the following:
example 1: 0110 1101.0000 - 0000 0110.1101
example 2: 1100 1010.0000 - 1111 1100.1010

Thanks for you patience to read my long crap description, how to implement floating point in hardware practice? I have really no idea how to deal with those decimal points binary number…
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top