Skip to content

Commit

Permalink
Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
dreylago committed Mar 23, 2024
1 parent 896502c commit ca0b2db
Showing 1 changed file with 33 additions and 40 deletions.
73 changes: 33 additions & 40 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
LogicMin: Logic Minimization in Python
======================================
# LogicMin: Logic Minimization in Python


Minimize logic functions.


Description
-----------
## Description

LogicMin is a Python package that minimize boolean functions using the tabular method of minimization (Quine-McCluskey). An object represent a truth table to which rows are added. After all rows are added, call a solve function.The solve function returns the minimized Sum of Products. The sum of products can be printed or analyzed.

Expand All @@ -15,10 +14,9 @@ For more information, look into references:
- John F. Wakerly. 1989. Digital Design Principles and Practices. Prentice-Hall, Inc., Upper Saddle River, NJ, USA.


Full-adder
----------
## Full-adder

.. code:: python
```python

# Full-adder
import logicmin
Expand All @@ -40,36 +38,34 @@ Full-adder
# print solution mapped to var names (xnames=inputs, ynames=outputs)
# add debug information
print(sols.printN(xnames=['Ci','a','b'],ynames=['s','Co'], info=True))
```


Output:

.. code::
```txt
Co <= a.b + Ci.b + Ci.a
s <= Ci'.a'.b + Ci'.a.b' + Ci.a'.b' + Ci.a.b
```


Get expression in VHDL syntax:

.. code:: python
```python
print(sols.printN(xnames=['Ci','a','b'],ynames=['s','Co'], syntax='VHDL'))
```

Output:

.. code::
```txt
Co <= a and b or Ci and b or Ci and a
s <= not(Ci) and not(a) and b or not(Ci) and a and not(b) or Ci and not(a) and not(b) or Ci and a and b
```

BCD to 7 segment converter
--------------------------
## BCD to 7 segment converter

.. code:: python

```python
# BCD-8421 to 7 segment
import logicmin
t = logicmin.TT(4,7);
Expand All @@ -93,32 +89,34 @@ BCD to 7 segment converter
# Outputs minimized independently
sols = t.solve()
print(sols.printN( xnames=['b3','b2','b1','b0'], ynames=['a','b','c','d','e','f','g']))
```

Output:


.. code::
```txt
g <= b2'.b1 + b2.b1' + b2.b0' + b3
f <= b1'.b0' + b2.b1' + b2.b0' + b3
e <= b2'.b0' + b1.b0'
d <= b2.b1'.b0 + b2'.b0' + b2'.b1 + b1.b0'
c <= b1' + b0 + b2
b <= b1'.b0' + b1.b0 + b2'
a <= b2'.b0' + b1.b0 + b2.b0 + b3
```

## Finite-state machines

For finite-state machines, a FSM object is provided.

Finite-state machines
---------------------
The advantages of FSM objects are:

For finite-state machines, use the FSM object.
1. States can have meaningful names.
2. It is possible to try different state code assignments to evaluate result complexity.

Binary counter with hold
------------------------

.. code:: python
### Binary counter with hold

```python
# Finite-state machine
# x=0 => hold
# x=1 => binary up count
Expand Down Expand Up @@ -146,30 +144,25 @@ Binary counter with hold
sols = m.solveD()
# print solution with input and output names
print(sols.printN(xnames=['X','Q1','Q0'], ynames=['D1','D0','Y']))
```

Output:

.. code::
```txt
Y <= Q0
D0 <= X'.Q0 + X.Q0'
D1 <= X.Q1'.Q0 + X'.Q1 + Q1.Q0'
```

The advantages of FSM objects are

1. Names for the states
2. Decouple state code assignment from table initialization.

Other examples
--------------
### Other examples

Look into examples directory.
Look into `examples` directory.

Install
-------
### Install

.. code::

```sh
pip install logicmin
```

0 comments on commit ca0b2db

Please sign in to comment.