Question

Hey i have a project due, and for the life of me i cannot figure out...

Hey i have a project due, and for the life of me i cannot figure out how to do this with the restrictions that are put in place, shiftwise operators such as << and >> <<<< >>>> cannot be used

This is the question that follows:

Shifter
Implement a 32-bit shifter. Input: x (32 bits), c (5 bits), and op (2 bits). Output: y. This shifter should shift the input number x by c bits according to the shift operations indicated by op:
op = 0 left logical shift,
op = 1 right logical shift,
3
op = 2 right arithmetic shift, and
op = 3 left circular shift.
For example, if x=0x80000001 and c=4, the value of y should be 0x00000010 if op=0, 0x08000000 if op=1, 0xF8000000 if op=2, and 0x00000018 if op=3. Notice that you cannot use shift operators in Verilog (including <<, <<<, >>, and >>>) directly in this module.

This is the beginning of the code

//32-bit shifter
//To get all scores, you cannot use shift operators in this module.
module shifter(input [31:0] x,
input [4:0] c,
input [1:0] op,
output reg [31:0] y);
//write your code here
always @(op or x)


0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

In this verilog module based on your input I have used the concatenation operator {}.

By using this and based on the op input in module I have implemented the shifting operations, and here I have used a temp reg for internal operation, at the end I have assigned it to the final output y

Add a comment
Know the answer?
Add Answer to:
Hey i have a project due, and for the life of me i cannot figure out...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Could you write down the answer legible please i cannot read most of the answer sheets. Thank you in advance, professor...

    Could you write down the answer legible please i cannot read most of the answer sheets. Thank you in advance, professor. sir, you said Your question needs more information to be answered. but this question was asked by professor. i sent it in same way directly. Design a t3 bit barrel shifter circuit that shift a 4-bit number both left or right. The control inputs are x (shifts two bits), y (shifts one bit), d (determines the shift direction, 0:...

  • 2. Serial shift registers Draw missing connections to implement various shift registers 1. Shift right: All...

    2. Serial shift registers Draw missing connections to implement various shift registers 1. Shift right: All bits of the register move right by one position, and a new bit value from a serial input is stored in the most significant bit (leftmost flip-flop below). Serial input -02 az 02 a Do ao Serial indino 2. Shift left: All bits of the register move left by one position, and a new bit value from a serial input is stored in the...

  • You will use Quartus II to build an 8 bit arithmetic logic unit that performs the...

    You will use Quartus II to build an 8 bit arithmetic logic unit that performs the following functions: Control Value Function                                000 Copy In1 to theResult unchanged 001 Copy In2 to theResult unchanged 010 Add In1 to In2 011 Subtract In2 from In1 100 And In1 and In2 101 Or In1 and In2 110 Shift left In1 by 1 bit 111 Shift right In1 by 1 bit You are allowed to use either gates/logic schematic, or else Verilog. We suggest...

  • Q2. Design a 8-bit ALU (Arithmetic Logic Unit) supporting the following instructions, Z and C values...

    Q2. Design a 8-bit ALU (Arithmetic Logic Unit) supporting the following instructions, Z and C values should be re-evaluated (updated) ifY changes Instruction type code[2:0] operations Logical Status update 001 010 011 100 101 110 ( Bitwise AND) Y = A & B: | Z (C is always 0) (bitwise OR) Y- A B; (bitwise XOR) Y-A B Z (Cis always 0) (negation) Y =-A; (Addition) Y A + B: (subtraction) Y = A-B: (Increment) Y-A+1 (decrement) Y-A-1 Z (C...

  • Write code to implement the following function: /* * Generate mask indicating leftmost 1 in x....

    Write code to implement the following function: /* * Generate mask indicating leftmost 1 in x. Assume w=32. * For example 0xFF00 -> 0x8000, and 0x6600 --> 0x4000. * If x = 0,then return 0. */ int leftmost_one(unsigned x); Your function should follow the above bit-level integer coding rules, except that you may assume that data type int has w=32 bits. Your code should contain a total of at most 15 arithmetic, bit-wise, and logical operations. In C++ and has...

  • A shift operation is often used to implement either multiply-by-power-of-2 or divide-by power-of-...

    A shift operation is often used to implement either multiply-by-power-of-2 or divide-by power-of-2 operations. For example, 0010 x4 1000. This multiplication can be achieved by shifting 0010 by 2 bits to the left. Likewise, 10004 0010, which can be obtained by shifting 1000 to the right by 2 bits. As multipliers are more "expensive" in terms of area and power consumption, multiplication by shifting is preferred if applicable. Sometime, the multiplier does not have to be power-of-2. For example, 0010...

  • The Arithmetic Logic Unit The first topic for the project is to create an Arithmetic Logic...

    The Arithmetic Logic Unit The first topic for the project is to create an Arithmetic Logic Unit, using a structured approached with a Virtual Hardware Design Language such as Verilog. Mainly, the program is very close to a simulator for a programming calculator. An ALU typically has the following operations Math Functions: Add, Subtract, Multiply, Divide, Modulus Logic Functions: And, Or, XOR, Not, Nand, Nor, XNOR Error Modes: Divide by Zero, Overflow Support Functions: No Operation, Shift Left, Shift Right,...

  • Using Structural Modeling in VHDL write the code for: An Arithmetic Logic Unit (ALU) shown in...

    Using Structural Modeling in VHDL write the code for: An Arithmetic Logic Unit (ALU) shown in the figure below. A (16-bit), B (16-bit), Opcode (3-bit), and Mode (1-bit) are the inputs; and ALUOut (16-bit) and Cout (1-bit) are the outputs of the design. A and B hold the values of the operands. Mode and Opcode together indicate the type of the operation performed by ALU. The ALU components ARE: -Arithmetic Unit that consists of one 16-bit adder, 16-bit subtractor, 16-bit...

  • 1.) a.) Using the simplified instruction set shown for part b, write code for the following....

    1.) a.) Using the simplified instruction set shown for part b, write code for the following. Suppose memory locations 1400 to 1449 contain 16-bit words. Each word represents 2 ASCII characters. Write code to read in and write out these 100 characters. Left-side character from location 1400 should be first, right-side character from location 1400 should be second, and remaining characters follow in numeric order. Assume you have access to 4 registers: R1, R2, R3, R4. Each register holds one...

  • Application Problem: Answer the following questions at the bottom of the worksheet: You are configuring a...

    Application Problem: Answer the following questions at the bottom of the worksheet: You are configuring a microcontroller (uC) to sample a signal connected to an input pin. Part of the initial setup requires that you clear (turn off) bits #17 and #2 in a 32-bit register, while leaving all other bits unchanged. To work with specific bits, we typically use a second number, called a mask, which has the bit positions we need to alter set to 1, and all...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT