CPR E 281x/282x - Lab 12b

 

 

Designing a Shifter for Signed Multiplication

 

 

1.   Objectives

 

This lab will develop shifters which will be used in signed multiplication. We’ve designed a shifter in last week’s lab. In this lab you will be designing a slightly different one.

 

1.1           Reference Files for Lab

 

Lab Evaluation Form

 

1.   Prelabs

 

Before you come to lab, get familiar with shifters.  You will find information on shifters in section 7.8 of your text: “Fundamentals of Digital Logic with Verilog Design” by Brown and Vranesic.

 

 

2.   Design Shifter

 

Shift registers are a type of sequential logic circuit, mainly for storage of digital data.  They are a group of flip-flops connected in a chain so that the output from one flip-flop becomes the input of the next flip-flop.

 

Shift instructions move a bit string (or operand treated as a bit string) to the right or left, with excess bits discarded. In arithmetic shift left (ASL) or logical shift left (LSL) zeros are shifted into the low-order bit. In arithmetic shift right (ASR) the sign bit (most significant bit) is retained into the most significant bit. In logical shift right (LSR) zeros are shifted into the high-order bit. In multiply shift right (MSR), a multiplying bit is shifted into the high-order bit. In divide shift left (DSL), a dividing bit is shifted into the low-order bit. In rotate right (ROR), the least significant bit is shifted into the high-order bit. In rotate left (ROL), the most significant bit is shifted into the low-order bit.

 

Suppose you have two 16-bit registers and you want to implement a 32-bit shifter using these two 16-bit registers. The following figures show how the above functions work:

 

 

Original Registers:

LSR: logic shift right:                                    

 

b1

 

ASR: arithmetic shift right:  

 

b1

 

MSR: multiply shift right:                              

 

b1

 

ROR: rotate right:

 

b0

 

 

LSL: logic shift left:                           

 

0

 

ASL: arithmetic shift left:     

 

0

 

 

DSL: Divide shift left:                                   

 

div

 

ROL: rotate left:

 

 

 

 

Make sure you create the folder in your home directory U:\CPRE281\Lab12b and then two sub-folders ~\shift_1bit, ~\shift_16bit, and ~\shift_32bit. 

 

 

Step 1: Design a 1-bit shifter

 

Create a new text file in Quartus II and save it as shift1bit.v in your ~\shift_1bit folder.

 

Your 1 bit shift should be able to take three 1-bit inputs, In, Left, and Right. One 2-bit input, selector.  And one 1-bit output, out. The selector decides what function the shifter is performing. When selector is 1, it shifts left. When selector is 2, it shifts right. Otherwise, it does not shift.

 

Run the waveform editor, make sure your 1-bit shifter working properly, then ask your TA to initial the answer sheet.

 

 

Step 2: Design a 16-bit shifter

 

For this step in the lab, you need to create a 16-bit shifter using the 1-bit shifter you created in last step. Create a new text editor file and save as shifter16bit.v in the corresponding folder. The 16-bit shifter has five inputs: 16-bit In, 1-bit ShiftIn, ms, and dv, and 4-bit sel. The outputs should have a 16-bit Out, and a 1-bit ShiftOut.  The shifter should be able to perform the following functions.

 

 

 

an-1

a0

sel[3:0]

Out[15:0]

Left Shift

an-2

ShiftIn

0000

Logic shift left with ShiftIn bit

an-2

0

0001

Logic shift left

an-2

an-1

0010

Rotate left

an-2

dv

0011

Divide shift left

an-1

ShiftIn

0100

Arithmetic shift left with ShiftIn bit

an-1

0

0101

Arithmetic shift left

an-1

a0

0110

No shift

an-1

a0

0111

No shift

Right Shift

an-1

a1

1000

Arithmetic shift right

an-1

a1

1001

Arithmetic shift right

an-1

a1

1010

Arithmetic shift right

an-1

a1

1011

Arithmetic shift right

ShiftIn

a1

1100

Shift Right with ShiftIn bit

0

a1

1101

Logic Shift Right

a0

a1

1110

Rotate right

ms

a1

1111

Multiply shift right

 

You’ll need 16 copies of the 1-bit shifter. The inputs of the least significant bit and most significant bit vary depending on the selector according to the table above. The inputs of the other bits should remain the same.

 

Use waveform to verify your result, and then ask your TA for the initials.

 

 

Step 3: Design a 32-bit shifter

 

In this step, you will create a 32-bit wide shifter which should be able to perform the shift functions as described in previous steps for a 32-bit wide register. You can follow the same way in step 2 to create it.

 

Use waveform to verify your result, and then ask your TA for the initials.