You are on page 1of 5

Project

Digital Systems Laboratory

Lab Project
Shift-and-Add Multiplication Circuit with Storage
Objectives This assignment is a Project assignment for the Digital Systems Laboratory. You are asked to design a circuit that performs multiplication using the shift-and-add algorithm. Moreover, your design should provide basic storage options in a predefined way. The main difference from the previous lab exercises is that you are not given detailed implementation guidelines. Instead, you are given a specification description that your design should meet. Finally, you are going to download the design in the Spartan 3 board and demonstrate its correct operation during the Project Exam. The project exam will take place during the week 17-21 May 2010. You have to arrange a 30 minutes slot (per team) during that week with the lab instructor for the examination. You have to support the project report, at least 24 hours before the examinations date/time.

1 Preliminaries/Preparatory Work
The multiplication operation is a very critical operation in a computer system. Apart from the obvious uses of the multiplication in performing mathematic operations, it is has a variety of other uses, the most important of which is in physical address calculation. Most of the modern systems have dedicated hardware for the multiplication, while older computers were using algorithmic procedures in software to provide the multiplication operation. Naturally, the multiplication hardware is based on using similar concepts as the software procedures. One of the most popular multiplication algorithm used in hardware design is the shiftand-add (SaA) algorithm that imitates the longhand multiplication procedure. Most of the todays multiplication designs are variations or extensions of the SaA algorithm which has been proved to been one of the most efficient way of building a multiplication circuit with minimum hardware using simple components. The SaA method adds the multiplicand X to itself Y times, where Y denotes the multiplier. To multiply two numbers by paper and pencil, the algorithm is to take the digits of the multiplier one at a time from right to left, multiplying the multiplicand by a single digit of the multiplier and placing the intermediate product in the appropriate positions to the left of the earlier results. As an example, consider the multiplication of two unsigned 4-bit numbers, 8 (1000) and 9 (1001) in Figure 1 . 1000 1001 1000 0000 0000 1000 01001000 x

Figure 1 A binary multiplication example

University of Nicosia/Engineering Dept.

1/4

Project

Digital Systems Laboratory

In the case of binary multiplication, since the digits are 0 and 1, each step of the multiplication is simple. If the multiplier digit is 1, a copy of the multiplicand (1 multiplicand) is placed in the proper positions; if the multiplier digit is 0, a number of 0 digits (0 multiplicand) are placed in the proper positions. Consider the multiplication of positive numbers. The first version of the multiplier circuit, which implements the shift-and-add multiplication method for two n-bit numbers, is shown in Figure 2.

Figure 2 A sample multiplication circuits demonstrating the SaA process

The 2n-bit product register (A) is initialized to 0. Since the basic algorithm shifts the multiplicand register (B) left one position each step to align the multiplicand with the sum being accumulated in the product register, we use a 2n-bit multiplicand register with the multiplicand placed in the right half of the register and with 0 in the left half.

Figure 3 shows the basic steps needed for the multiplication. The algorithm starts by loading the multiplicand into the B register, loading the multiplier into the Q register, and initializing the A register to 0. The counter N is initialized to n. The least significant bit of the multiplier register (Q0) determines whether the multiplicand is added to the product register. The left shift of the multiplicand has the effect of shifting the intermediate products to the left, just as when multiplying by paper and pencil. The right shift of the multiplier prepares the next bit of the multiplier to examine in the following iteration.
Figure 3 The SaA algorithm's flowchart

University of Nicosia/Engineering Dept.

2/4

Project

Digital Systems Laboratory


Table 1 A SaA example on 4-bit numbers.

shows an execution of a SaA algorithm on two 4-bit numbers, namely 9 (1001) and 12 (1100). Each row of the table shows a step of the algorithm while the last value of A shows the final result i.e. 108 (0110 1100). Thoroughly study this example to understand the algorithms details. Before you start designing your circuit you are advised to apply your own examples on paper. You have to include one such example in the final report, following the design you have implemented to prove its correctness.
Table 1

2 Design Description and Specifications


As mentioned above, in this lab you are asked to design a digital circuit that performs multiplication between two 4-bit numbers that will be provided by the user. Your design should follow the SaA algorithmic approach and the basic concept shown in Figure 2. Attention: your design is not similar to that of Figure 2. Rather, it is an elaboration of it. Moreover, your design must provide storage operation using a build-in memory. Specifically, you must give the user the option to store up to 16 different multiplication results which can be retrieved any time from the memory. You have to design a circuit with control logic (Main Control Unit - MCU) which will be responsible for coordinating the two main operations (multiplication and storage). You are free to use any design approach you want, provided that your design does not consist of more that 20% of behavioral VHDL code. You are advised to use behavioral VHDL for the control logic of your circuit (both the MCU and the Multiplier controller). You may want to overview the following build-in components provided by the ISE software using the ISEs help: shift registers(e.g. sr4cled), adders(e.g. add4), ram (e.g. ram32x4s), counters (e.g. cb4ce)

University of Nicosia/Engineering Dept.

3/4

Project

Digital Systems Laboratory

Of course you are free to use any logic component (symbol) you want, except from a multiplier component. Your design should be thoroughly simulated in order to demonstrate all the operations described here. Finally, you have to download your design in the Spartan 3 board using any pin combination you want provided that the results of the multiplication is displayed in the SSD either in decimal or in hexadecimal form. You can find more details for the implementation on the Spartan board in the following section.

3 Downloading on Spartan 3 board


According to the specifications of this project you are free to select the configuration of the inputs and the outputs of your design in the Spartans board PINs. This section provides a number of restrictions that can be viewed as the minimum requirements and a few guidelines that can be proved helpful. Required Operations The implementation you are going to make should provide at least the following operations using distinct inputs pins/switches: Clear all the registers values (not the memory contents), in order to start a new multiplication. Load the two 4-bit numbers and execute the multiplication. Store a multiplication result to the memory. Show all the contents of the memory in order, and clear the memory.

Numbers Illustration Your design must display at least the results of the multiplication using the seven segment displays (SSDs) provided on the board. Moreover, in the memory retrieval operation all the values should be illustrated using the on-board SSDs, in a specific order. You can choose to illustrate the values in decimal or in hexadecimal form. The latter is a much easier way since you will need fewer digits. Comment on your report for the decision you have made giving the appropriate reasoning. Recall that you the SSDs share the same inputs and you must use time multiplexing in order to display more than one digit at the same time. Use the internal clock of the Spartan 3 (pin T9) and remember that you have to use a counter to divide the clock driving the SSDs. You may refer to the laboratory 3 assignment for further information. You may put any additional input/output you find helpful but you should be able to explain what they mean.

4 Final Note
In order to successfully complete this project assignment, you have to submit a report that clearly describes your design, the implementation details, the design processes and a brief description for each component you have designed and for each component you have used. The report should include simulations at least for the top design and provide information on any difficulties you faced during the implementation of the project.

University of Nicosia/Engineering Dept.

4/4

Project

Digital Systems Laboratory

Finally, you have to take a Project Examination that you have to arrange with the lab instructor during the predefined period.

University of Nicosia/Engineering Dept.

5/4

You might also like