![32 bit alu vhdl code 32 bit alu vhdl code](https://i.ytimg.com/vi/r8xVQ3ThQK8/hqdefault.jpg)
Hi ... Here I pasted a simple ALU , let me know if you need any further help: module alu(a,b,cin,alu,carry,zero,ctl); input [3:0] a,b; // port A,B input cin ; // carry input from carry flag register output [3:0] alu; // the result output carry; // carry output output zero ; // zero output input [3:0] ctl ; // functionality control for ALU wire [4:0] result; // ALU result assign result = alu_out(a,b,cin,ctl); assign alu = result[3:0]; assign carry = result[4] ; assign zero = z_flag(result) ; function [4:0] alu_out; input [3:0] a,b ; input cin ; input [3:0] ctl ; case ( ctl ) 4'b0000: alu_out=b; // select data on port B 4'b0001: alu_out=b+4'b0001 ; // increment data on port B 4'b0010: alu_out=b-4'b0001 ; // decrement data on port B 4'b0011: alu_out=a+b; // ADD without CARRY 4'b0100: alu_out=a+b+cin; // ADD with CARRY 4'b0101: alu_out=a-b ; // SUB without BORROW 4'b0110: alu_out=a-b+(~cin); // SUB with BORROW 4'b0111: alu_out=a&b; // AND 4'b1000: alu_out=a|b; // OR 4'b1001: alu_out=a^b; // EXOR 4'b1010: alu_out={b[3:0],1'b0}; // Shift Left 4'b1011: alu_out={b[0],1'b0,b[3:1]}; // Shift Right 4'b1100: alu_out={b[3:0],cin}; // Rotate Left 4'b1101: alu_out={b[0],cin,b[3:1]}; // Rotate Right default : begin alu_out=9'bxxxxxxxxx; $display('Illegal CTL detected!!'); end endcase /* {...,...,...} is for the concatenation. {ADD_WITH_CARRY,SUB_WITH_BORROW}2'b11 is used to force the CARRY1 for the increment operation */ endfunction // end of function 'result' function z_flag ; input [4:0] a4 ; begin z_flag = ^(a4[0]|a4[1]|a4[2]|a4[3]) ; // zero flag check for a4 end endfunction endmodule ------------------------------------------ VJ
VII 4 Bit ALU Verilog Verification Code 9 VIII 8 Bit ALU Verilog Verification Code 11. THE ECE 547 VLSI design project described in this paper is an 8-bit Arithmetic Logic Unit (ALU). We used the 74S181. ECE 547 - UNIVERSITY OF MAINE 4 Fig. 8 Bit ALU III.
This problem has been solved!
See the answerWrite the VERILOG code and test bench for an 4-bitarithmetic/logic unit (ALU). The ALU inputs are 4-bit logic_vectorsalu_ina and aluin_b. The output is an 4-bit logic_vector alu_out.The ALU should operate on the inputs A and B depending on thecontrol inputs C in the following manner:
This is to be implement on a Spartan 3E-100 CP132
Best Answer
I implementd it in Xilinx 14.2: module alu4bit(alu_out, aluin_a, aluin_b, aluin_c, Cin); input [3:0] aluin_a; input [3:0] aluin_b; input [3:0] aluin_c; input [3:0] Cinview the full answer
Transcribed Image Text from this Question
Design of an 4-bit ALU Write the VERILOG code and test bench for an 4-bit arithmetic/logic unit (ALU). The ALU inputs are 4-bit logic vectors alu ina and aluin b. The output is an 4-bit logic vector alu out. The ALU should operate on the inputs A and B depending on the control inputs C in the following manner: C(3 down to 0) Operation 0001 0010 0011 0100 010 1 0110 011 1 1000 1001 1010 1011 1100 1101 1110 aluout-aluin a +aluin b aluout-aluin a aluin b +Cin alu out-aluin a-aluin b alu out-aluin a-aluin b - Cin alu out=aluin a logical shifted right by alum b alu out-aluin a arithmetic shifted right by aluin b aluout-aluin a rotated right by aluinb alu out all 0's alu out-aluin a OR aluin b (bitwise or) alu out aluin a AND aluin b (bitwise and) alu out-aluin a XOR aluin b (bitwise xor) alu out NOT aluina (bitwise inversion) alu out= undefined alu out= undefined alu out= undefined all out-undefined