0
\$\begingroup\$

I have a four-bit input pattern. I have 16 distinct 12-bit output patterns. Many of these output patterns have a bits which are set in 2 or 4 of patterns.

If I (arbitrarily) assign each pattern to a four-bit number, I can use various online Karnaugh map tools to generate logic circuits.

This arbitrary assignment of patterns to four-bit numbers adds unnecessary constraints to the problem.

Is there a way of solving this, to give the best pattern<->number assignments, other than by brute-forcing all 16! orderings?

(Where "best" is the pattern<->number assignment which requires least logic to decode the four-bit input one of the 12 bit output patterns.)

Update:

Here are the bit patterns I want to decode a 4-bit numbers to:

0  0  0  1  0  0  0  0  1  0  0  0
0  1  0  1  0  0  0  0  1  0  0  0
0  0  0  0  0  0  1  0  1  0  0  0
0  0  0  0  0  1  0  0  0  0  0  1

0  0  0  0  1  0  0  0  0  1  0  0
0  1  0  0  1  0  0  0  0  1  0  0
1  0  1  0  1  0  0  0  0  1  0  0
0  0  0  0  0  0  1  0  0  1  0  0

0  0  0  0  0  1  0  0  0  0  1  0
1  0  0  0  0  1  0  0  0  0  1  0
0  0  0  0  0  1  1  0  0  0  1  0
0  0  0  0  0  0  1  0  0  0  1  0

0  0  0  0  0  1  0  1  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  1  1  1  0  0  0  0
0  0  0  0  0  0  1  1  0  0  0  0

It does not matter which four-bit number decodes to which 12-bit pattern, provided there is a one-to-one relationship.

What are the fewest logic gates which will do the job?

While solving the above may be marginally useful, it is the general solution that I am looking for.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Use a lookup table. \$\endgroup\$ Commented Apr 25, 2016 at 11:26
  • \$\begingroup\$ If you want some help with the specific problem, post the table and what you did so far. If you want to use logic gates, the answer for a generic problem is 'brute force it', the answer for your specific problem is 'maybe there's a pattern you overlooked'. \$\endgroup\$ Commented Apr 25, 2016 at 11:32
  • \$\begingroup\$ Use a 4 (in) to 16 line (out) decoder to gate the appropriate 12-bit patterns to the output. \$\endgroup\$
    – Andy aka
    Commented Apr 25, 2016 at 11:54

2 Answers 2

3
\$\begingroup\$

You can use an SRAM or a PROM for this. 4 input bits, 12 bits wide. Store your patterns in the memory, use the 4 input bits as the address.

There are 16 word SRAM ICs for this purpose. They would be useless to store "real" data, but are designed for arbitrary lookup tables and implementing simple logic.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks, I've considered this idea, but I'd like to solve it with logic. I want to know how to solve the optimisation problem. \$\endgroup\$
    – fadedbee
    Commented Apr 25, 2016 at 11:23
  • \$\begingroup\$ @chrisdew Alright! I've tried searching for the ICs I mentioned, and they seem to be very rare these days anyway. \$\endgroup\$
    – pipe
    Commented Apr 25, 2016 at 11:24
  • \$\begingroup\$ @chrisdew it's either a simple ROM as suggested (which is by far the most optimal!), or you will need to make twelve karnaugh maps, each with 4 inputs and then solve them. You may end up with many, many gates, and it will take up far more room and cost far more than a simple ROM - nothing about it would be considered optimal. Only you know your output patterns. \$\endgroup\$ Commented Apr 25, 2016 at 11:52
2
\$\begingroup\$

You have three options:

  1. Use a Lookup Table, as pointed out by @Olin and @Pipe. Given how small it is (16 words) you could easily do it with one or two parallel memory ICs. For example an EEPROM would work.

  2. Determine the logic required. This would be done by building 12 Karnaugh maps, each of which has four inputs (your 4bit number), and determines the logic required for 1 of the output bits (hence you need to make 12 maps). You can then do simplification of the logic and see what you can come up with. However in all likelihood you will need many more ICs then just a simple memory. I can't give you an estimate of how many it would be as you haven't posted what your output patterns look like.

  3. Use a microcontroller. Yes it seems like a weird idea, but if you are running something slowly and don't mind a high propagation time it can work. MCUs are so cheap nowadays and have everything they need to run built in (internal oscillator, etc.). You would only need one with 16 I/O pins (4 for inputs, 12 for outputs), and then write a simple program which constantly reads the inputs, converts it using a lookup table and writes it to the outputs. That would be a single 20 pin IC - ATTiny2313's for example cost barely $2. I'm sure there are cheaper ones too.

\$\endgroup\$
2
  • \$\begingroup\$ Updated with output values. \$\endgroup\$
    – fadedbee
    Commented Apr 25, 2016 at 12:12
  • \$\begingroup\$ Number 2 is what I want to do - it's educational, not practical. Your answer doesn't explain how to choose the optimal ordering of the 16 12-bit output states to minimise the logic required (each one is assigned a four bit id). \$\endgroup\$
    – fadedbee
    Commented May 24, 2016 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.