I am new to VHDL, working on assignment for my Computer architecture class:
implement 32 bit ALU using VHDL, that performs only certain operations: and
, shift left
, shift right
, complementing one of the input
, rest of operations will do simple addition
. Trick is, code needs to be structured, since instructor provided bitshifter and adder.
I have googled for examples, but all of them use straightforward code(such as result <= a + b
). What would be a good way to implement ALU using above requirements ???
Thanks !
Best Answer
If the bitshifter and adder are already provided for you, it seems all you have left to do is connect them together. Build a module that directs the proper inputs given a control signal. If you have six possible operations you'll need at least three bits for a control signal, right? You might want to choose the various operations to have a similar bit in common, and you can use that bit to mux the outputs from each component block to the output of the block you're building. I'm going to use some pseudo code because, first, this is your homework and, second, I haven't written VHDL in years.
So, it's you're basically creating a mux that switches the inputs depending on the operation being performed. Obviously, I have no idea what your current blocks look like and how they're implemented, but I think the general concept should still apply.