项目作者: obsfx

项目描述 :
This is a utility function that is using in kmap-solver to solve Karnaugh Maps up to 4 variables.
高级语言: TypeScript
项目地址: git://github.com/obsfx/kmap-solver-lib.git
创建时间: 2020-12-08T15:13:06Z
项目社区:https://github.com/obsfx/kmap-solver-lib

开源协议:GNU General Public License v3.0

下载


kmap-solver-lib

This is a utility function that is using in kmap-solver to solve Karnaugh Maps up to 4 variables.

installation

  1. npm i kmap-solver-lib

usage

kmap-solver-lib takes 3 parameters and returns an object that holds groups and the simplified expression.

  1. type KMapCell = {
  2. binary: string;
  3. decimal: number;
  4. row: number;
  5. col: number;
  6. }
  7. type KMapResult = {
  8. groups: KMapCell[][];
  9. expression: string;
  10. }
  11. solve(variables: string[], minterms: number[], dontcares?: number[]): KMapResult;
  1. const solve = require('kmap-solver-lib');
  2. const variables = ['x', 'y', 'z'];
  3. const minterms = [0, 1, 3, 4, 5, 6];
  4. // placement
  5. // 0 | 1
  6. // 2 | 3
  7. // 6 | 7
  8. // 4 | 5
  9. // optional
  10. // const dontcares = []
  11. solve(variables, minterms);
  12. // output
  13. //{
  14. // groups: [
  15. // [
  16. // { binary: '000', decimal: 0, row: 0, col: 0 },
  17. // { binary: '001', decimal: 1, row: 0, col: 1 },
  18. // { binary: '100', decimal: 4, row: 3, col: 0 },
  19. // { binary: '101', decimal: 5, row: 3, col: 1 }
  20. // ],
  21. // [
  22. // { binary: '011', decimal: 3, row: 1, col: 1 },
  23. // { binary: '001', decimal: 1, row: 0, col: 1 }
  24. // ],
  25. // [
  26. // { binary: '110', decimal: 6, row: 2, col: 0 },
  27. // { binary: '100', decimal: 4, row: 3, col: 0 }
  28. // ]
  29. // ],
  30. // expression: `y'+x'z+xz'`
  31. //}