Verilog Code | Datapath and Controller Design | Design 2 | GCD of two numbers
Problem Statement : In the previous blog, we discussed on how data path and control paths can be together designed in complex digital systems. We take up one more design example in this blog to get better understanding of the design procedure . We shall be taking another example, namely that of computing the GCD of two numbers (greatest common divisor , also known as HCF) . Note that the GCD of two numbers is defined as the largest integer that divides both of them. For example if you have one number as 26 one number as 39 and if you compute the GCD of them. GCD will be 13, because 13 is the largest number which divides 26 as well as 39. Algorithm Designed : The method we follow is the method of repeated subtraction so the algorithm is depicted in this flowchart . Fig 1 : Algorithm being implemented The algorithm i s very simple. If you are given two numbers A and B , for which you are trying to compute the GCD. Then you compare A and B. If A is less than B, then subt...