Skip to content

Commit b301deb

Browse files
authored
Update README.md
1 parent b13faf0 commit b301deb

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
1-
# Shift-and-Add-Multiplication-RISC-V
2-
Code on Shift-and-Add Multiplication on RISC-V using Ripes simulator
1+
# Multiplication with Shift and Add
2+
3+
## Overview:
4+
This project explores multiplication using the shift-and-add technique, a method comparable to traditional pencil-and-paper multiplication. In this procedure, the multiplier (Y) is added to the multiplicand (X) Y times.
5+
6+
## Methodology:
7+
The multiplication process involves taking the multiplier's digits one at a time, working from right to left. For each digit, the multiplicand is multiplied by the digit, and the intermediate product is positioned to the left of the previous results.
8+
9+
## Flow Chart:
10+
A detailed flow chart illustrating the multiplication process is available in the accompanying PDF file.
11+
12+
## Implementation:
13+
```python
14+
# Sample code
15+
def multiply_with_shift_and_add(X, Y):
16+
result = 0
17+
while Y > 0:
18+
if Y % 2 == 1:
19+
result += X
20+
X <<= 1 # Left shift by 1 (multiply by 2)
21+
Y >>= 1 # Right shift by 1 (divide by 2)
22+
return result
23+

0 commit comments

Comments
 (0)