{"id":17769824,"url":"https://github.com/wojciechmula/ternarylogiccli","last_synced_at":"2025-03-15T14:30:53.429Z","repository":{"id":66099980,"uuid":"223995859","full_name":"WojciechMula/ternarylogiccli","owner":"WojciechMula","description":"CLI utilty to work out proper constants for vpternlogic instruction","archived":false,"fork":false,"pushed_at":"2023-01-22T14:02:32.000Z","size":5,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T03:11:18.324Z","etag":null,"topics":["assembly","avx512","cli","tools"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WojciechMula.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-25T16:41:44.000Z","updated_at":"2024-03-10T08:35:36.000Z","dependencies_parsed_at":"2023-07-07T17:32:54.263Z","dependency_job_id":null,"html_url":"https://github.com/WojciechMula/ternarylogiccli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fternarylogiccli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fternarylogiccli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fternarylogiccli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WojciechMula%2Fternarylogiccli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WojciechMula","download_url":"https://codeload.github.com/WojciechMula/ternarylogiccli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243742701,"owners_count":20340689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","avx512","cli","tools"],"created_at":"2024-10-26T21:19:18.272Z","updated_at":"2025-03-15T14:30:53.420Z","avatar_url":"https://github.com/WojciechMula.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"================================================================================\n                        Ternary logic CLI\n================================================================================\n\nAVX512__ has got the instruction ``VPTERN`` (``_mm512_ternarylogic_epi{32,64}``\nwhich evaluates arbitrary `three-argument boolean`__ function. A programmer\ngives three input argument and an 8-bit constant which defines the function.\n\nThis CLI program lets you provide a function in textual form and obtain\nappropriate constant.  C++ programmers may use `contsexpr-based library`__\nby **Samuel Neves**.\n\n__ https://en.wikipedia.org/wiki/AVX-512\n__ http://0x80.pl/articles/avx512-ternary-functions.html\n__ https://github.com/sneves/avx512-utils\n\nExpressions may contain parentheses and operators ``and``/``\u0026``, ``or``/``|``,\n``xor``/``^``, ``not``/``~``. There might be up to three variables, their\nnames are derived from the expression. By default, the first variable that\nappears in an expression becomes the most significant; the order of variables\ncan be explicitly set with ``--vars`` argument (see example 5).\n\nSee also a `programming library \u003chttps://github.com/WojciechMula/ternary-logic\u003e`_\nthat gives similar API, but works with SSE, AVX, AVX2 and x86 instruction sets.\n\n\nExample 1\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTautology::\n\n    $ ./ternarylogiccli.py \"x \u0026 ~x\"\n     # | x | - | - | x \u0026 ~x\n    ---+---+---+---+--------\n     0 | 0 | 0 | 0 |    0   \n     1 | 0 | 0 | 1 |    0   \n     2 | 0 | 1 | 0 |    0   \n     3 | 0 | 1 | 1 |    0   \n     4 | 1 | 0 | 0 |    0   \n     5 | 1 | 0 | 1 |    0   \n     6 | 1 | 1 | 0 |    0   \n     7 | 1 | 1 | 1 |    0   \n\n    _mm512_ternarylogic_epi32(x, -, -, 0x00)\n\n\nExample 2\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nCondition expression::\n\n    $ ./ternarylogiccli.py \"(cond and true_val) or (~cond and false_val)\"\n     # | cond | true_val | false_val | (cond \u0026 true_val) | (~cond \u0026 false_val)\n    ---+------+----------+-----------+-----------------------------------------\n     0 |  0   |    0     |     0     |                    0                    \n     1 |  0   |    0     |     1     |                    1                    \n     2 |  0   |    1     |     0     |                    0                    \n     3 |  0   |    1     |     1     |                    1                    \n     4 |  1   |    0     |     0     |                    0                    \n     5 |  1   |    0     |     1     |                    0                    \n     6 |  1   |    1     |     0     |                    1                    \n     7 |  1   |    1     |     1     |                    1                    \n\n    _mm512_ternarylogic_epi32(cond, true_val, false_val, 0xca)\n\n\nExample 3\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n    $ ./ternarylogiccli.py \"a and b or c\"\n     # | a | b | c | a \u0026 b | c\n    ---+---+---+---+-----------\n     0 | 0 | 0 | 0 |     0     \n     1 | 0 | 0 | 1 |     1     \n     2 | 0 | 1 | 0 |     0     \n     3 | 0 | 1 | 1 |     1     \n     4 | 1 | 0 | 0 |     0     \n     5 | 1 | 0 | 1 |     1     \n     6 | 1 | 1 | 0 |     1     \n     7 | 1 | 1 | 1 |     1     \n\n    _mm512_ternarylogic_epi32(a, b, c, 0xea)\n\n\nExample 4\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n    ./ternarylogiccli.py \"x ^ (y \u0026 ~z)\"\n     # | x | y | z | x ^ (y \u0026 ~z)\n    ---+---+---+---+--------------\n     0 | 0 | 0 | 0 |       0      \n     1 | 0 | 0 | 1 |       0      \n     2 | 0 | 1 | 0 |       1      \n     3 | 0 | 1 | 1 |       0      \n     4 | 1 | 0 | 0 |       1      \n     5 | 1 | 0 | 1 |       1      \n     6 | 1 | 1 | 0 |       0      \n     7 | 1 | 1 | 1 |       1      \n\n    _mm512_ternarylogic_epi32(x, y, z, 0xb4)\n\n\nExample 5 --- variables order\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n::\n\n\t$ ternary \"a or b and c\" --vars b,c,a\n\t # | b | c | a | a | b \u0026 c\n\t---+---+---+---+-----------\n\t 0 | 0 | 0 | 0 |     0     \n\t 1 | 0 | 0 | 1 |     1     \n\t 2 | 0 | 1 | 0 |     0     \n\t 3 | 0 | 1 | 1 |     1     \n\t 4 | 1 | 0 | 0 |     0     \n\t 5 | 1 | 0 | 1 |     1     \n\t 6 | 1 | 1 | 0 |     1     \n\t 7 | 1 | 1 | 1 |     1     \n\n\t_mm512_ternarylogic_epi32(b, c, a, 0xea)\n\n\t$ ternary \"a or b and c\" --vars c,a,b\n\t # | c | a | b | a | b \u0026 c\n\t---+---+---+---+-----------\n\t 0 | 0 | 0 | 0 |     0     \n\t 1 | 0 | 0 | 1 |     0     \n\t 2 | 0 | 1 | 0 |     1     \n\t 3 | 0 | 1 | 1 |     1     \n\t 4 | 1 | 0 | 0 |     0     \n\t 5 | 1 | 0 | 1 |     1     \n\t 6 | 1 | 1 | 0 |     1     \n\t 7 | 1 | 1 | 1 |     1     \n\n\t_mm512_ternarylogic_epi32(c, a, b, 0xec)\n\n\t$ ternary \"a or b and c\" --vars a,c,b\n\t # | a | c | b | a | b \u0026 c\n\t---+---+---+---+-----------\n\t 0 | 0 | 0 | 0 |     0     \n\t 1 | 0 | 0 | 1 |     0     \n\t 2 | 0 | 1 | 0 |     0     \n\t 3 | 0 | 1 | 1 |     1     \n\t 4 | 1 | 0 | 0 |     1     \n\t 5 | 1 | 0 | 1 |     1     \n\t 6 | 1 | 1 | 0 |     1     \n\t 7 | 1 | 1 | 1 |     1     \n\n\t_mm512_ternarylogic_epi32(a, c, b, 0xf8)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojciechmula%2Fternarylogiccli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwojciechmula%2Fternarylogiccli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwojciechmula%2Fternarylogiccli/lists"}