Discussion:
HW 5 shift testing
(too old to reply)
[Instr] Albert Chae
2008-07-30 06:31:28 UTC
Permalink
You can use multipliers and dividers from the Arithmetic library, with
a constant 2 fed in as input. This doesn't handle the sra case though
but don't worry too much about it.

Albert
So, assuming we're building a test circuit using our ALU compared with
another
ALU built from library subcircuits, I have no idea what to test my shifters
against, other than building my own shifter circuits again. Is there an
easy
way to build _input_*2^shamt and _input_/2^shamt that I'm not seeing? Any
other
ideas?
This may not work for all cases, but you could use the multiplier circuit
included in arithmetic to simulate shifting by multiplying by 2 each time,
and
dividing to shift in the opposite direction. You might get some weird results
though when digits start to drop off the ends...
I was thinking of doing that, but I couldn't figure out how to multiply by 2 a
variable number of times (*2^x) in a way that was less convoluted than my own
shifter already was.
[Instr] Albert Chae
2008-07-30 06:33:09 UTC
Permalink
Oops, I missed part of this thread. Well you can multiply a
variable (the shamt) by a constant 2, and then feed that into
a multiplier/divider to do the shifting.

Albert
Post by [Instr] Albert Chae
You can use multipliers and dividers from the Arithmetic library, with
a constant 2 fed in as input. This doesn't handle the sra case though
but don't worry too much about it.
Albert
So, assuming we're building a test circuit using our ALU compared with
another
ALU built from library subcircuits, I have no idea what to test my shifters
against, other than building my own shifter circuits again. Is there an
easy
way to build _input_*2^shamt and _input_/2^shamt that I'm not seeing? Any
other
ideas?
This may not work for all cases, but you could use the multiplier circuit
included in arithmetic to simulate shifting by multiplying by 2 each time,
and
dividing to shift in the opposite direction. You might get some weird results
though when digits start to drop off the ends...
I was thinking of doing that, but I couldn't figure out how to multiply by 2 a
variable number of times (*2^x) in a way that was less convoluted than my own
shifter already was.
Loading...