Prev Problem
Next Problem

14. Logical Shifter

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

// ============================================================
// Module: shift8
// Description: 8-bit logical shifter (left and right)
// ============================================================
module shift8 (
    input  [7:0] A,         // Input data
    input  [2:0] shamt,     // Shift amount (0–7)
    output [7:0] SHL,       // Logical left shift result
    output [7:0] SHR        // Logical right shift result
);

    // Logical shift operations
    assign SHL = A << shamt;   // Logical left shift
    assign SHR = A >> shamt;   // Logical right shift

endmodule

 

Was this helpful?
Upvote
Downvote