Question: Euclid s Algorithm Euclid s algorithm is an efficient method for computing the greatest common divisor ( GCD ) . It is named after the
Euclids Algorithm
Euclids algorithm is an efficient method for computing the greatest common divisor GCD
It is named after the ancient Greek mathematician Euclid, who first described it in Books
VII and X of his Elements.
The GCD of two numbers is the largest number that divides both of them without leaving a
remainder. Euclids algorithm is based on the principle that the greatest common divisor of
two numbers does not change if the smaller number is subtracted from the larger number.
For example, is the GCD of and which is the
same as the GCD of and since Since the larger number is reduced,
repeating this process gives successively smaller numbers until one of them is zero. When
that occurs, the GCD is the remaining nonzero number.
For instance, consider the inputs x and y
x
y
x y so
x x y
x y so
x x y
y x so
y y x
y x so
y y x
y x so
y y x
y x so
EE Fall
y y x
x y so
x x y
now
x
y
so GCD of and is
Problem
Youll be working with bit integers X X X and Y Y Y
Design a comparator unit. Given input bits Xi
Yi
Ain and Bin, it produces outputs
Aout and Bout such that:
If Ain or Bin then Aout Ain and Bout Bin.
Otherwise
If Xin Yin, Aout Bout
If Xin Yin, Aout Bout
If Xin Yin, Aout Bout
Produce a full design with logic gates.
Using your comparator units, design a full comparator. Given bit inputs X and
Y it produces outputs A and B such that:
If X Y A B
If X Y A B
If X Y A B
Design an bit conditional subtractor unit. Given inputs X X X and Y
Y Y A and B it produces outputs Z Z Z such that
If A B Z Y X
Else, Z X Y
Use full adders and logic gates.
Now design a full circuit that implements Euclids algorithm. Have the circuit load
X and Y when a Load signal is set to ; have the computation begin when the Load
signal is set to ; have the circuit set a Done signal when the computation is complete;
have it produce an output Z equal to the GCD of X and Y when the Done signal is
set.
EE Fall
Your solution must be specified down the level of logic gates and D flipflops. Of course,
you are encouraged to first specify how to build small boxes, such as half and fulladders;
then combine these into large boxes; then those into even larger boxes.
You are encouraged to code up your solution in Verilog and test it with Vivado. Simulate
your circuit for at least three pairs of input values, including and
For a problem like this, you must explain and annotate your circuit schematics, as well as
your simulation results. The grading will be somewhat subjective. If the grader cannot
understand your scribbles, you will not get full points, even if you can argue afterwards
that the circuit works.
Note that much of the challenge of this problem is the iterative nature. The circuit first
computes a set of outputs, then uses these as a new set of input values, and so on You
must include circuitry for starting the computation, ie loading initial values of X and Y
and stopping the calculation when the final value is present on Z
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
