Unformatted text preview:

Creating the Shifter Sub-Block The Shifter block, as the name implies, is responsible for taking the input operand, A, and shifting it either left or right by a number of bits specified by the SHAMT input. SHAMT is interpreted as a five-bit unsigned integer, thus allowing us to shift the input by 0 to 31 bits. The direction is specified by the higher order control bit. When ALUOp(1) is set to „1‟, it is a shift right operation. Otherwise, it is a shift left operation. In addition to direction, we must also specify whether the shift is arithmetic or logical, but this is only meaningful for right shifts. A logical shift fills the bits vacated at the end with zeros. An arithmetic shift fills the bits vacated at the left end on a right shift with copies of the sign bit, since for signed two‟s complement integers all bits to the left of the represented number are considered to be the same as the sign. Arithmetic right shifts allow a right shift on a signed integer to be interpreted as a division by 2**(SHAMT). There is no special arithmetic left shift (corresponding to a multiply by 2**(SHAMT)) because all of the bits to the right of the binary point are considered to be zeros. The type of shift is specified by the ALUOp(0) control bit. It is logical shift when ALUOp(0) is zero and arithmetic shift when it is one. Note ALUOp(0) should never be equal to one at the same time as ALUOp(1) is equal to zero. This will be ensured by the control unit. Operation ALUOp(1) ALUOp(0) Shift Left Logical 0 0 N/A 0 1 Shift Right Logical 1 0 Shift Right Arithmetic 1 1 Implementing the Shifter with a Flowchart We will be implementing the Shifter block with a Flowchart view. A flowchart view creates a VHDL process block containing sequential statements to describe the behavior. Sequential VHDL statements can only be found within special constructs called processes. Within a process, these statements are executed, as the name implies, sequentially. They consist of such statements as if..then..else, case, and wait. To begin, first we need to create a Flowchart View for the Shifter sub-block in the ALU block diagram. Do this by double-clicking on the Shifter sub-block in the ALU design window and select Flowchart in the window that appears. Click Next and then Finish. An empty flowchart will be created similar to the diagram below:Notice that there are no ports or signals visible on the flowchart. This is because it is a purely behavioral description of the block, with no structural elements as in the block diagram view. All of the signals which are connected to the sub-block in the ALU block diagram will be visible within the process. You will have to remember them though. At the top of the design area, there are four boldface headings:  Architecture Declarations is for adding additional internal signals which are visible in the entire architecture.  Concurrent Statements is for adding concurrent VHDL statements to the architecture outside of the process. The logic of these statements will be in parallel with the process logic.  Sensitivity List is for declaring which signals, if any, the process will be sensitive to. Sensitivity to a signal means that the process is "activated" by a change in that signal.  Process Declarations is for declaring signals or variables which exist only within the scope of the process. Thus, these signals can only be referenced from within the process. Since a process is sequential, it lends itself to a flowchart representation. The first step in creating the flowchart is to place a Start block on the design area by clicking on the Add Start Point button, . Then click on the flowchart to add the start point.The first thing we need to do is add the process declarations necessary for our shifter. We add the process declarations by right-clicking over an empty spot of the flowchart and selecting Flow Chart Properties from the pop-up menu. Select the Process Declarations tab and type the declaration in the white text area: variable shift_temp : std_logic_vector(31 downto 0); variable fill : std_logic_vector(15 downto 0); Click the OK button when you are done. Note: You can also double-click on the bold Process Declarations title at the top of your flowchart in order to add/remove declarations.These variables are an integral part of our flow chart's operation. Variable shift_temp will be used to store any intermediate results during the shift operation and will contain the final result at the end of the shifting. The fill variable will contain the proper bit that will be shifted into the shift_temp variable. The next thing we want to do is to create an action box so that we may initialize our variables that we created. To do this we click on the Add Action Box button, . This will create a blue box that will allow us to enter the actions we wish to execute. We want to initially set our shift_temp variable to input A and the fill variable to all 0's in order to satisfy a logical shift operation. To do this, double-click the actions text and type in the actions required. Also, rename the default name a0 to Initialize.Note: It is important to remember that variables have a different operator symbol “:=” unlike the “<=” operator symbol that signals use. The next thing that we want to do is to decide whether we are shifting left or shifting right. To do this, we will need to place a decision box into the design just below the action block using the Add Decision Box tool, . This will add a yellow diamond to the flowchart with reddish triangles at two of its points labeled T for TRUE and F for FALSE. The flowchart will now look like the figure below: We have added a decision box, but we haven't yet told it which decision to make. To do this, we need to enter an expression which evaluates to TRUE or FALSE inside the decision box in place of the text labelled condition. Since ALUOp(1) specifies the Left/Right shifting, we will enter ALUOp(1) = '0' as the condition. Now if we are shifting left, and ALUOp(1) = '0', we will follow the TRUE branch, otherwise we will be following the FALSE branch which will perform a right shift. To even things out visually, we will also move the TRUE branch source, the small reddishtriangle labelled T, to the left corner of the yellow diamond. Finally, rename the decision box by highlighting the default name d0 and entering LeftorRight Your flowchart should look like figure below: Left Shift


View Full Document

SC CSCE 611 - Creating the Shifter Sub-Block

Download Creating the Shifter Sub-Block
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Creating the Shifter Sub-Block and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Creating the Shifter Sub-Block 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?