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

Simple Structural Verilog (Named alu4_s2): Design an ALU (see Figure 1) using st

ID: 1715100 • Letter: S

Question

Simple Structural Verilog (Named alu4_s2): Design an ALU (see Figure 1) using structural Verilog. You should design 4-bit behavioral components for: inverter, adder, subtractor, doubler, and MUX. Combine these components to make a 4-bit ALU.

Design Constraints: The design must properly function given the following constraints:

- The A input is named A_in and is 4 bits wide.

- The B input is named B_in and is 4 bits wide.

- The Select input is named SEL_in and is 2 bits wide.

- For the Structural models, you may only use the behavioral components you created (adder, inverter, mux, etc) or Verilog Primitives.

I am using Verilog code software, so if possible I would like the answer to be in that format. Thanks

Explanation / Answer

module alu (ans,a,b,sel);

output reg [3:0] ans;     //output of alu
   input [3:0]        a,b;    //inputs to alu
   input [1:0] sel;//control signal for arithmatic operation

   always @(*)
    begin
    case (sel)
    2'b00 : begin op = ~a; $display("Not operation"); end
    2'b01 : begin op = a + b; $display("Addition operation"); end
    2'b10 : begin op = a - b; $display("Subtraction operation"); end
    2'b11 : begin op = a<<1; $display("1 bit shift left operation or multiple by 2"); end
    endcase
    end
endmodule

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