Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a simulation program for the 32-bit ALU. The ALU uses 32-bit ripple-carry

ID: 3635801 • Letter: W

Question

Write a simulation program for the 32-bit ALU. The ALU uses 32-bit ripple-carry adder, and performs six operations; i.e., logic AND, logic OR, addition subtration, set on less than(slt), and logic NOR. In addition to the results (32 bits wide), the ALU should also return signals for overflow(1 bit)and zero(1bit).

i've got it started but am lost as to where do i go from here. any help would be greatly appreciated

Explanation / Answer

unsigned char ALU_Add(unsigned char bit1, unsigned char bit2, unsigned char & carry) { unsigned char sum = bit1 + bit2 + carry; carry = (sum > 1) & 1; return sum; } unsigned char ALU_Equal(unsigned char bit1, unsigned char bit2) { return (bit1 == bit2) ? 1 : 0; } unsigned char ALU_Or(unsigned char bit1, unsigned char bit2) { return (bit1 | bit2) & 1; } unsigned char ALU_Operation(unsigned char bit1, unsigned char bit2, const std::string& operation, unsigned char& carry_bit = 0) { unsigned char result(0); if (operation == "add") { result = ALU_Add(bit1, bit2, carry_bit); } else if (operation == "or") { result = ALU_Or(bit1, bit2); } else if (operation == "equal") { result = ALU_Equal(bit1, bit2); } else { result = 0; } return result; } I just showed an example of three of the functions. The others should be similar.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote