1
0
Baglio Tabifata 5 жил өмнө
parent
commit
091a6c9f17

+ 0 - 78
docs/Black_Box_Analysis.md

@@ -1,78 +0,0 @@
-# Black Box Analisys of a Registered PAL
-
-## Introduction
-
-### Combinatorial PALs and bruteforcing
-
-Combinatorial PALs are built around an internal network of wires, whose interconnections are broken at flashing time. These wires connect the inputs to an array of AND gates, whose outputs are in turn connected to an array of OR gates (implementing a sum of products).
-
-Even when the chip lock is set (thus blocking direct reading via a programmer), recovering the functions that map the internal connections is relatively easy: the output state is dependant only on the current state of the inputs and nothing else, making the creation of a truth table trivial: just feed the PAL every combination of inputs and record the outputs.
-
-### Registered PALs
-
-Things get a bit harder when we consider registered PALs: these ICs add an array of flip-flops to the network.
-These flip-flops have one of their outputs connected to a pin and the other feeding back into the internal network. A **clock** pin is also brought out to an external pin so that the flip-flops can be toggled.
-
-When toggling the clock, the flip flop take their new value not only from a combinations of the inputs, but also from the feedback lines coming from out of the flip-flops themselves, i.e. when the clock is pulsed, the PAL changes its internal state, and **the new state is dependant on the previous one**.
-
-## Analyzing a registered PAL device
-
-### The Not-So-Black Box
-
-From what I wrote in the introduction follows that a registered PAL device can be viewed as a stateful system whose current state is dependant on the previous one combined the state of the inputs at the moment the state is changed.
-
-Luckily for us, the number of the possible states is known and dependant on the number of flip-flops inside the device (and, as every flip-flop is connected to a specific output, equal to the number of possible combinations that can be taken by the so-called **registered outputs**). Being connected directly to output pins, these flip-flop give us an important insight on the status of the PAL: *we are able to identify exactly in which state it is at the moment*.
-
-To summarize and simplify, a registered PAL has the following types of outputs:
-
-- **Combinatorial outputs**: their state is dependant on the current state of the inputs and on the current state of the registered outputs (via their feedbacks).
-- **Registered outputs**: these only change when the clock pin is pulsed, and their new state depends on the state of the inputs and on their own feedback before the pulsing.
-
-### Unboxing the PAL
-
-It is now clear that a registered PAL is a state machine whose current state is tied to the flip-flops, in turn connected to the registered outputs.
-
-The number of these registered outputs depends on the PAL model, but is fixed and known and cannot be changed via programming. From this we can gather that **a registered PAL device has 2^X possible states**, where **X is the number of registered outputs for that model**.
-
-I will call these states defined by the registered outputs "**MacroStates**", to distinguish them from another type of state, the **SubStates**, which I'll describe below.
-
-While the **MacroState** is defined by the status of the registered outputs, we also need to take into account the state of the combinatorial outputs. The combinatorial outputs state is dependant only on the inputs and the registered outputs, and changes without the need of pulsing the clock (we can think each MacroState in a registered PAL as a single simple combinatorial PAL).
-
-From this we get that for every MacroState we need to test all the input combinations in order to calculate their corresponding SubStates. For every MacroState we'll have 2^Y possible substates, where Y is the number of the combinatorial outputs, but we need to map them to 2^Z combinations of inputs (Z is the number of the input pins).
-
-#### Some simple math
-
-We can see that for a registered PAL we have:
-
-- 2^X theoretically possible MacroStates.
-- 2^Z combinations of inputs for every MacroState, every combination maps to one of the 2^Y possible SubStates of that specific MacroState.
-- 2^Z combination of inputs that could bring forth a movement to another MacroState when coupled with a clock pulse.
-
-Where:
-
-- X is the number of registered output pins.
-- Y is the number of combinatorial output pins.
-- Z is the number of input pins.
-
-#### PAL as a Graph
-
-The inner workings of a registered PAL can then be represented by a **directed graph** (or **digraph**), where every **vertex** is a **MacroState**, every **edge** is a link between a "starting" and a "destination" MacroState, and this link (which I'll call **StateLink**) is defined by the state of the inputs and the state of the registered outputs from the starting MacroState.
-
-- Every MacroState will have 2^Z StateLinks (edges) coming out of it, some pointing to another MacroState, some pointing back at itself.
-- We will have 2^X MacroStates (vertices) in the graph. Some will be connected to others, some will not be connected at all, depending on the programming of the device.
-- Every MacroState will contain an array of 2^Z SubStates inside, defining all the possible states that the combinatorial outputs can take within that MacroState, while receiving different input combinations.
-
-Reversing the inner working of the PAL device means that we need to find every possible StateLink (edge) in the digraph, and calculate all the SubStates for every MacroState (vertex) we can visit.
-
-One this is done, we can use the graph we built to print out a truth table that represents all the possible states of the PAL, and from that, recover the logic equations.
-
-##### Mapping the Graph
-
-We can summarize the algorithm to build the graph this way:
-
-1. Read the current state of the registered outputs: this will identify our MacroState
-2. If the state was not yet visited, build the array of its substates by trying all the input combinations and registering the outputs.
-3. Check if we have still unvisited StateLinks for this MacroState
-    - If we have unvisited links, pick the first and visit it. Go back to 1.
-    - If we have no unvisited links, search a path in the graph to a visited MacroState with yet unvisited links and follow it. Go back to 3 after following the path and feeding the PAL the input combinations.
-        - If no visited MacroStates with unvisited links are found, we completed our mapping.

+ 0 - 162
docs/Minimize_Equations_with_feedbacks.md

@@ -1,162 +0,0 @@
-# Additional minimization of PAL equations by using feedback outputs
-
-## Introduction
-
-Sometimes, truth tables brute-forced from a PAL and minimized with espresso contain expressions that are too long to fit into a newly programmed GAL/PAL device, which has limits in the number of usable terms.
-This is because the brute-forcing and minimization do not take into account the possibility to use feedback outputs (outputs the values of which are used as inputs to other equations) included in a PAL device to further reduce the number of necessary terms.
-The equations generated by brute-forcing and espresso are equivalent to the originals, but additional simplification making use feedback outputs can be occasionally required. In this case, we can use **Logic Friday** to help us in the procedure.
-
-## The Procedure
-
-The procedure can be summarized by the following steps:
-
-1. Minimize the truth table and obtain the equations.
-2. Scan the equations to find ones that appear long and have many terms shared with others.
-    - You should also identify equations that are possible feedbacks you can use to simplify the other equations.
-3. Extract the equations, put them in **Logic Friday**, minimize and turn them into __Products of Sums__.
-4. Massage the equations to find how to replace terms by using the feedbacks.
-5. Repeat 2-4 as needed.
-
-### Example
-
-#### Step 1
-
-After going through the automatic analisys and bruteforcing of a *PAL16L8* IC, we end up with a truth table that put through **espresso** minimizes to the following equations:
-
-```text
-!io18 = (!i2&i3&!i4&i5&!i8&!io13) | (!i2&i3&!i4&!i6&i8&!io13) | (!i2&i3&!i4&!i5&i6&!io13) | (!i2&i3&!i4&!i7&!io13) | (i1&!i2&i3&!i4&!io13);
-
-!io17 = (i2&!i3&i4&i5&!i8&!io13) | (i2&!i3&i4&!i6&i8&!io13) | (i2&!i3&i4&!i5&i6&!io13) | (i2&!i3&i4&!i7&!io13) | (i1&i2&!i3&i4&!io13);
-
-!io16 = (i2&!i3&!i4&i5&!i8&!io13) | (i2&!i3&!i4&!i6&i8&!io13) | (i2&!i3&!i4&!i5&i6&!io13) | (i2&!i3&!i4&!i7&!io13) | (i1&i2&!i3&!i4&!io13);
-
-!io15 = (!i1&i5&i6&i7&i8&!io13);
-
-!io14 = (!i7&!io13) | (i1&!io13) | (i8&!io13) | (i6&!io13) | (i5&!io13);
-
-!o19 = (!i2&!i3&!i4&i5&!i8&!io13) | (!i2&!i3&!i4&!i6&i8&!io13) | (!i2&!i3&!i4&!i5&i6&!io13) | (!i2&!i3&!i4&!i7&!io13) | (i1&!i2&!i3&!i4&!io13);
-
-!o12 = (!i1&!i5&!i6&i7&!i8&!i9&!i11);
-```
-
-Notice that **espresso** will NOT put the exclamation mark at the beginning of every equation. But as the PAL16L8 is an active-low device, and the minimized equations are representative of the OFF-set of the truth table, I added it myself for clarity.
-
-#### Step 2
-
-Notice how many of the equations that we obtained in the previous step are sharing a lot of similar terms with `!io14` and `!io15`.
-We'll randomly pick `!io16` to simplify in the following steps.
-
-#### Step 3
-
-Let's fire up **Logic Friday** and put the equations in.
-
-Below you can see the equation for `!io16`, minimized and converted into a **Product of Sums** (let’s replace the negation at the beginning of the equation with an `n` for the sake of simplicity and because Logic Friday would error out with such syntax: we’ll just add it back when preparing the equations to program on a new chip).
-
-```text
-Entered:
-nio16 = (i2&!i3&!i4&i5&!i8&!io13) | (i2&!i3&!i4&!i6&i8&!io13) | (i2&!i3&!i4&!i5&i6&!io13) | (i2&!i3&!i4&!i7&!io13) | (i1&i2&!i3&!i4&!io13);
-
-Minimized:
-nio16 = i2 i3' i4' io13' i7'  + i2 i3' i4' io13' i1 + i2 i3' i4' i5' i8 io13'  + i2 i3' i4' i8' io13' i6  + i2 i3' i4' i5 io13' i6' ;
-
-Minimized Product of Sums:
-nio16 = (io13')(i4')(i3')(i2)(i5'+i8'+i6'+i7'+i1)(i5+i8+i6+i7'+i1);
-```
-
-Then we do the same for the equation of `!io14`:
-
-```text
-Entered:
-nio14 = (!i7&!io13) | (i1&!io13) | (i8&!io13) | (i6&!io13) | (i5&!io13);
-
-Minimized:
-nio14 = i7' io13'  + io13' i1  + io13' i8  + io13' i6  + io13' i5;
-
-Minimized Product of Sums:
-nio14 = (io13')(i7'+i1+i8+i6+i5);
-```
-
-Begin to notice similarities?
-
-Let's do the same for `!io15`:
-
-```text
-Entered:
-nio15 = (!i1&i5&i6&i7&i8&!io13);
-
-Minimized:
-nio15 = i1' i5 i6 i7 i8 io13';
-```
-
-We don't need to turn this into a **Product of Sums** as we have no sums here.
-
-#### Step 4
-
-We can see that all of `!io14` appears in the equation of `!io16`. And we can also notice that a term very similar
-to `!io15` is also in `!io16`.
-
-First, we simply replace `!io14` in `!io16` and get:
-
-```text
-nio16 = (io14')(i4')(i3')(i2)(i5'+i8'+i6'+i7'+i1);
-```
-
-Note how the term `io14` is negated in the equation : remember what You read above, that every equation is of the OFF-set of the truth table and that we’ve replaced the negation with an `n` for simplicity when working with **Logic Friday**. Now we just added it back.
-
-Then, let’s look at `!io15` and what happens if we invert it:
-
-```text
-Entered:
-io15 = !(!i1&i5&i6&i7&i8&!io13);
-
-Minimized:
-io15 = i1  + i5'  + i6'  + i7'  + i8'  + io13;
-```
-
-This time it's no longer `nio15`, because, having inverted it, it now represents the ON-set of the truth table, and as such it's just `io15`.
-
-So, looking at `!io16`, we see there is a group of terms almost identical to `io15` (`(i5'+i8'+i6'+i7'+i1)`), but lacking `io13`, so we’ll simply have to add it back in negated form to counter the one we’re adding by replacing the group with `io15`:
-
-```text
-nio16 = (io14')(i4')(i3')(i2)(i5'+i8'+i6'+i7'+i1);
-```
-
-becomes:
-
-```text
-nio16 = (io14')(i4')(i3')(i2)(io15 & io13');
-```
-
-Notice that in this case `io15` is not negated: we already inverted it, remember?
-
-We can now minimize `!io16` again and see what we get:
-
-```text
-Entered:
-io16 = (io14')(i4')(i3')(i2)(io15 & io13');
-
-Minimized:
-io16 = i4' i3' i2 io15 io13' io14';
-
-```
-
-##### Note
-
-So, You might be wondering
-> why you replaced a term with `io13` in OR and added `io13’` in AND?”
-
-Just think about it this way: you had a condition inside the parentheses, that condition was not dependent on the status of `io13` (it was `i1 | !i5 | !i6 | !i7 | !i8`), but we replaced it with a condition that depended on `io13` (`io15` included that term in OR, so it is sufficient for it to be **true** to turn **true** the whole term between parentheses).
-
-To counter it, we need to make sure that, if the condition is verified, it is so **without** `io13` being **true**, and we can do it by adding an AND condition that checks for this.
-
-It’s perhaps clearer by looking at the expanded equation
-
-```text
-nio16 = (io14')(i4')(i3')(i2)(io15 & io13');
-nio16 = (io14')(i4')(i3')(i2)((i1 + i5' + i6' + i7' + i8' + io13) & io13');
-```
-
-## Links & References
-
-- A modern and compilable re-host of the [Espresso](https://github.com/classabbyamp/espresso-logic) heuristic logic minimizer.
-- [Logic Friday](https://download.cnet.com/developer/logic-friday/i-10268041) 1.1.4