Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Prime Number Identifier Terry Sturtevant Department of Physics and Computer Science, Wilfrid Laurier University Introduction Simplifying Equation Finding prime numbers is a common task in mathematics. This circuit will identify the prime numbers between zero and fifteen. In this case, a Karnaugh map was used to determine simplified sum-of-products logic equations. Definition a3 a2 A number is defined as prime if it has exactly two divisors, itself and one. By definition, the numbers zero and one are neither prime nor composite. 00 01 11 10 a1 a0 00 01 11 10 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 Circuit Drawing and Simulation The circuit looks like this: Another grouping can be used to get the remaining ones. Logic Design For this particular problem, the truth table looks like this: number binary (a3a2a1a0) p/c/n 0 0000 n 1 0001 n 2 0010 p 3 0011 p 4 0100 c 5 0101 p 6 0110 c 7 0111 p 8 1000 c 9 1001 c 10 1010 c 11 1011 p 12 1100 c 13 1101 p 14 1110 c 15 1111 c a3 a2 00 01 11 10 a1a0 00 01 11 10 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 The resulting SOP equation is prime = a3 a2 a1 + a3 a2 a0 + a2 a1 a0 + a2 a1 a0 The simulation output looks like this: Testing Equation Maxima was used to test the equation. 2 3 a3 a2 00 01 11 10 a1 a0 00 01 11 10 0 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 5 7 11 13 You can see that the ouput is only high for the highlighted cases; i.e. where the input number is prime. This verifies that circuit correctly implements the equation. The prime numbers are highlighted in red. There are 6 input combinations that give a TRUE output; for all other input combinations the output is FALSE. A truth table for the output, prime, which is TRUE for a prime number, looks like the following. (The inputs have been grey-coded to produce a Karnaugh map.) The two AND gates which implement the terms highlighted in the Karnaugh can be identified by coloured dots on them. 2 3 5 7 11 13 Testing Note that there are exactly 6 cells in the Karnaugh map with a one, corresponding to the six numbers which are prime. All the other cells are zero. All possibilities were tested to see that prime was only true for 2,3,5,7,11, and 13. This verifies that the equation is correct. Prime should only be true for 2,3,5,7,11, and 13 PC/CP120 Lab 2013