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.

write a c program to execute x/2^y in single clock cycle

Status
Not open for further replies.

Maharshi

Newbie level 3
Newbie level 3
Joined
Apr 26, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,328
write a c program to execute x/2^y in single clock cycle
 

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:
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top