Author : Kishore Papisetty //verilog code for the arithmatic logocal unit // module ALU( output [7:0]f, input [3:0] a, input [3:0] b, input [1:0] s ); wire [3:0]q,r; wire [7:0]p,z,l,k; wire cout,br,cin,c; assign cin=1'd0; assign c=1'd0; assign z=8'd0; ripple A1(r,cout,a,b,cin); subtractor A2(q,br,a,b,c); binarymul A3(p,a,b); assign k={3'd0,cout,r[3:0]}; assign l={4'd0,q[3:0]}; mux_21 A5(f,s,p,l,k,z); endmodule //TEST BENCH// module ALU_TB; // Inputs reg [3:0] a; reg [3:0] b; reg [1:0] s; // Outputs wire [7:0] f; // Instantiate the Unit Under Test (UUT) ALU uut ( .f(f), .a(a), .b(b), .s(s) ); initial begin // Initialize Inputs a <=4'd0; b <=4'd0; s <=2'd0; // Wait 100 ns for global reset to finish #100; #100 s<=2'b00; a<=4'd5; b<=4'd4; #100 s<=2'b01; a<=4'd4; b<=4'd4...
This is the blog where you can find the verilog/vhdl code. we are here give the best results in coding what ever you want. had a look the page regularly and follow me for new codes if you need any new code we are here to help you. just give a comment below we can help you a maximum.