hello how to write code ?
This code provides a C++ program that implements a Karnaugh map (k-map) minimizer with an algorithm that can get a solution for all k-map's types, i.e., for k-maps with any number of variables, but it has been implemented in this program for 26 variables only as much as the number of letters in the English alphabet.
The reader should have the basics of Boolean algebra and k-map usage in order to get the most benefit from this article.
To use this program, you need to follow the next steps:
Enter k-map type (Number of variables)
Enter ones' positions (-1 for stopping)
Enter don't-care positions (-1 for stopping)
Choose result's type (SOP or POS)
Getting the solutions of your k-map
This algorithm has 3 steps. A special class is used to implement each:
Setting k-map by getting its information from user (type ones' and don't care's positions) and saving ones' and don't care's positions with its Binary values.
Comparing ones' and don't care's positions to get all possible minimums.
Filtering the comparison result to eliminate unessential terms, take essential ones and provide all possible solutions.
In this step, k-map's type is entered by the user (ones' and don't care's positions). Then it's converted to its binary equivalent, i.e., its binary representation according to the k-map type. Then it's saved in a vector, so if we have a 4-var k-map, its ones' positions are 0,1,3,4 and 11 and its don't care position is 5, this leads to:
type will be: 4
ones' positions will be saved as: 0000 , 0001, 0011, 0100 and 1011
don't care position will be saved as: 0101
In this step, ones and don't cares are compared by their equivalent binary values one by one:
If there are two Binary values matched in type - 1 digits, save this value and consider the different condition = -1.
Consider all these semi-matched values as dashed values.
Do this process type times as if we have n-var k-map and this k-map is full, we need to do comparison n times in order to consider 1 var as -1 in each circle and at last solve this k-map with a full k-map.