[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] Shifting Unit

On Sun, Oct 14, 2001 at 01:56:42AM +0100, Yann Guidon wrote:
> * Michael said he was designing the shifter as two shift
> units, one shifts left (by 32 bits i think) and the other
> shifts right. By playing with the recombinations step
> (yet another mux), we can shift 64-bit words left or right
> by any amount.

That's wrong, unfortunately.  Both left and right shifters are full
64-bit devices (the reason for this is that I didn't want to add two
more rows of 2:1 muxes, for bit reversal).  When the core is a rotator
instead of the shifter, we can probably drop the second subunit and
negate the shift count to reverse the direction.

> * shift and memory : the instruction i recently proposed
> (simply called "sh") has another very important use :
> aligning words before/after memory access (explicitely,
> with explicit instructions). For example, if you want to
> store a 64-bit register to a non-aligned address, use the
> pointer's LSB as the shift amount for the data and issue
> the shift. Because the shift amount is truncated to the
> meaningful LSB (ie : 5 bits are kept if we shift 32-bit
> words), we have to shift the pointer left by 3 to get the byte
> aligned pointer.

You'll still have to do some masking when the value is going to be stored.
This is where the MUX instruction has its use...

On the other hand, this kind of operation can also be done with a rotate
instead of a double shift, at the same cost (or cheaper -- the double
shift variant needs more registers).

> * The instruction i recently proposed was 2r2w : the result
> was an "expanded" version of the source data, without the OR
> of the two shifter's output (it is only swapped depending on
> the shift direction). If we are going to use this instruction
> for helping the store instruction with non-aligned data,
> we can dot the reverse : a 3r1w would do the reverse for
> a load instruction. This version would take two consecutive
> data (got with two consecutive loads), shift and combine the
> result. For example, if a 64-bit word is stored across a
> 8-byte boundary, we can reconstruct it with 2 loads and 1 shift.
> >From this point of view, these shifter instructionw can be
> named "align" and "unalign". What do you think about that ?

It's basically the same operation both times (double width left shift),
with different parameter and result usage.  The only problem is that
we need a third input, and an even bigger (and slower) shifter :( It
makes more sense to do this in software (load two consecutive words,
extract the correct parts with the MUX instruction, rotate the result
into place -- et voilą).

 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/