# Finding a minimal cost function from a Karnaugh Map

Below is a problem I made up and did. Is my solution wrong?

Problem:
Attached is following map for the function $$\f\$$. We want a minimal cost expression using only and, or and not gates. The cost of a gate is the number of inputs it has plus 1. In the above diagram 'd' represents 'don't case' so '0' or '1' would be acceptable.

(original)

We can cover the entire area with three selections.
1.) The four squares in the upper left hand corner.
2.) The two squares in the upper right hand corner.
3.) The squares in the upper right hand corner and lower left hand corner.
$$f = \overline X_1 \overline X_3 + \overline X_0 X_1 \overline X_3 + \overline X_0 X_ 1 \overline X_2$$

Based upon the comments I got, here is an updated solution.
Another approach is to cover it with the following four selections:
1.) The four squares in the upper left hand corner.
2.) The top row.
3.) The top half of the left most column and the top half of the right most column.
4.) The squares in the upper right hand corner and lower right hand corner.
$$f = \overline X_1 \overline X_3 + \overline X_2 \overline X_3 + \overline X_0 \overline X_2 + \overline X_0 X_1 \overline X_2$$

Another approach is to cover it with the following three selections:
1.) The four squares in the upper left hand corner.
2.) The upper two squares in the left most column plus the upper two squares in the right most column.
3.) The bottom square of the right most column and the top square of the right most column.
$$f = \overline X_1 \overline X_3 + \overline X_0 \overline X_3 + \overline X_2 x_1 \overline X_0$$ Is this right?

• How do you define "cost"? If you use a 4-input LUT as is done in an FPGA then all logically equivalent functions will have the same cost. Could you crop your image, by the way? – Elliot Alderson Oct 16 '19 at 23:16
• Term 3 shows you understand that the top of kmap is linked to bottom. That's a clue. – StainlessSteelRat Oct 17 '19 at 1:09
• On your edit, you have 4 terms. Three are correct, 1 is wrong! The wrong term was not in your initial answer. – StainlessSteelRat Oct 18 '19 at 18:14
• Looks good… ... – StainlessSteelRat Oct 19 '19 at 20:38
• What does 'd' represent in the map? Is it 'don't care'? This needs to be in your question in order to answer it. – Warren Hill Oct 20 '19 at 15:08