Starting from:
$35

$29

Project 4 Multiplication and Division Hardware Solution




The purpose of this project is for you to build 16-bit multiplication and 16-bit division hardwares as we discussed in class in logisim.




Introduction to the Multiplication Hardware




The 16-bit multiplication hardware that we discussed in class is shown below:




16




Multiplicant
32
16 Multiplication Product

Multiplier
1
Hardware M_Ready
Mul







Clock




You can consider the above circuit as a sub-circuit named multiplication which contains the following input/output:




Multiplicand: a 16-bit input




Multiplier: a 16-bit input




Mul (1-bit input): This input will be one if the instruction is the multiplication instruction Clock (1-bit input)




Product (32-bit output)




M Ready (1-bit output): This output will be 1 if the product is ready







Note that we require to have the output M Ready because the multiplication instruction will take multiple clock cycles to produce a result. Ideally, if a CPU see the instruction mul, it will set the appropriate Multiplicant and Multiplier. Then, it will set Mul to 1 and wait until the signal M Ready to turn to 1 before it continues to the next instruction. The circuit inside will be the same as the multiplication hardware discussed in class as shown below:







Multiplicand




Shift left
32 bits


32−bit Adder
Multiplier


Shift right




16 bits




Product

Control test

Write




32 bits







1



Inside the multiplication hardware, you need three registers, Multiplicand (32-bit), Multiplier (16-bit), and Product (32-bit). For these registers, you do not have build them from scratch. Simply use the register component under \Memory". Similarly, for the 32-bit adder, simply use the one supplied by the logisim. Note that the above hardware is for multiplying two 16-bit numbers and produce a 32-bit result. The owchart of this hardware is shown below:







Start










Multiplier0 = 1 1. Test Multiplier0 = 0

Multiplier0










1a. Add multiplicand to product and

place the result in Product register










Shift the Multiplicand register left 1 bit



Shift the Multiplier register right 1 bit






No: < 16 repetitions

16nd rep?







Yes: 16 recetitions




Done




Recall that in the rst step, this hardware have to load the top 16-bit of the multiplicand register with 0s and the bottom 16-bit with Multiplicand, load the product register with 0s, and load the multiplier register with the Multiplier. After all three registers are loaded with proper values, then the algorithm can start as follows.




product = product + (multiplicand multiplier0): In this step, if multiplier0 is 0, we actually perform product = product + 0. But if multiplier0 is 1, we perform product = product + multiplicand. This can be done by adding a 32-bit (2-input) multiplexer. This



multiplexer has two inputs, one from the multiplicand and another one is imply a 32-bit con-stant 0. Simply use the Least Signi cant Bit (LSB) of the multiplier register (multiplier0) to choose which one to go to the output as shown below:













Multiplicand
m
Product


u




x






multiplier0




Note that before the algorithm starts, you must clear the product register which can be done in two ways:







2



by writing 0. So, you also need another multiplexer to choose whether you want to write



0 or output from 32-bit adder to the product register as shown below:










Multiplicand
m


m




u








u
Product
0
x


0
x



















multiplier0

Clear

Product




use the Clear input pin of the register. Simply set it to 1 and the content will be cleared.



Shift multiplicand register left one bit: This step is simply update the multiplicand reg-ister by its data that has been shifted left by 1. Simply use a Shifter provided by logisim under Arithmetic. Note at the rst step before the algorithm starts, you need to update multiplicand register by the input Multiplicand. So, you need a multiplexer to select which data should go to the multiplicand register (Multiplicand input or multiplicand << 1. The block diagram of the circuit is shown below:









m

0 16 32 u Multiplicand

x




Multiplicand

1
16




Shift multiplier register right one bit: This step is pretty much the same as in previous step. You need to be able to load the content of the multiplier or update it with multiplier 1



Note that we need an ability to control what to do at each clock cycle. For example, in the rst clock cycle, we need to load contents of all registers. The next clock cycle, we need to perform product = product + (multiplicand multiplier0). The third clock cycle, we need to perform multiplicand = multiplicand << 1. The fourth clock cycle, we need to perform multiplier = multiplier 2, and so on. To be able to control each clock cycle, we will use a combination of counter and Read Only Memory (ROM) as shown below:









Counter
















Mul




Clock







ROM










M Ready






When Mul is 1, it will clear the Counter to 0. At the same time, it will allow the clock signal to go to the Counter. So, the Counter will start counting up until its desired maximum value which can be set. When it reaches its maximum value, its Carry signal will be 1 which can be used for



3



the signal M Ready. The output of the Counter will be use as the address of a ROM. The content of the ROM will be control signal for each clock cycle. In other words, you can program what do you want to do at each clock cycle by content of the ROM.







Note that you MUST set the maximum value of the counter to stay at a speci c value based on the number of clock cycles that your hardware uses. MAKE SURE that the last output value of the ROM should maintain the output of your product register. When we grade your circuit, we will simply put value of multiplicand and multiplier, and let the clock tick until M Ready turn green without stopping the clock and check the result.







Introduction to the Division Hardware




The 16-bit division hardware that we discussed in class is shown below:




16


16
Dividend


Quotient
16
Division
16
Divisor


Remainder
1
Hardware
1
Div


D Ready









Clock




You can consider the above circuit as a sub-circuit named division which contains the following input/output:




Dividend: a 16-bit input




Divisor: a 16-bit input




Div (1-bit input): This input will be one if the instruction is the division instruction Clock (1-bit input)




Quotient (16-bit output) Remainder (16-bit output)




D Ready (1-bit output): This output will be 1 if the product is ready







The division hardware that we discussed in class is shown below:







Divisor




Shift right




32 bits




Quotient

32−bit Adder

Shift left




16 bits




Remainder

Control test

Write




32 bits




Again, the above hardware is for dividing two 16-bit numbers and produce a 16-bit quotient and 16-bit remainder. The owchart of this hardware is shown below:










4



Start







Subtract the Divisor register from the Remainder register and place the result in the Remainder register






Remainder = 0
Test
Remainder < 0






Remainder



























2a. Shift the Quotient register to the left, setting the new least significant bit 1




2b. Restore the original value by adding

the Divisor register to the Remainder

register and placing the sum in the

Remainder register. Also shift the

Quotient register to the left, setting the

new least significant bit to 0









3. Shift the Divisor register right 1 bit







17rd No: < 17 repetitions

repetition?




Yes: 17 repetitions




Done




The design concept of this division circuit will be pretty much the same as in multiplication circuit but it requires more steps. For example, when the subtraction result is less than 0, you have to restore to its original value by adding it back. Another di erent is the quotient, sometime we shift it left and insert a 0 but sometime we insert a 1.




What to Do?




For this project, start with the given starter le named muldiv.circ. This starter le contains two sub-circuits, 16-bit multiplication and 16-bit division. In both sub-circuit, the counter and ROM are provided. Simply build your multiplication and division circuits there. Once you are nish, put your circuits in the main and connect them with appropriate input/output. We will test your circuit from the main circuit.




Again, you MUST set the maximum value of the counter to stay at a speci c value based on the number of clock cycles that each of your hardwares use. We will not stop the clock when we check your results.




Submission




The due date of this project is stated in the CourseWeb under this project. Late submissions will not be accepted. You should submit the le muldiv.circ via CourseWeb.
























5

More products