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.
You're always dividing by a power of 2. This is equivalent to right shifting in a binary arithmetic processor.
Consider the following values of Y and resultant outputs:
Y = 0, OUT = X / 1; X >> 0
Y = 1, OUT = X / 2; X >> 1
Y = 2, OUT = X / 4; X >> 2
Y = 3, OUT = X / 8; X >> 3
Y = Y, OUT = X / 2^Y; X >> Y
(Recalling that X / POW( Y, 2 ) is X >> Y)
The code is: OUT = X >> Y;
Of course, this question is poorly worded in that it assumes that a barrel shifter is present. On older processors (such as the 6502) a variable shift could take multiple single cycle shifts due to the absence of a barrel shifter. Semantics aside... this is probably what you're looking for. :wink:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.