From agent-almanac
Designs combinational logic circuits from truth tables, Boolean expressions, or specs into gate-level schematics using AND/OR/NOT/XOR and adders; supports NAND/NOR universality and exhaustive simulation verification.
npx claudepluginhub pjt222/agent-almanacThis skill uses the workspace's default tool permissions.
---
Designs sequential logic circuits like latches, flip-flops, registers, counters, and Mealy/Moore FSMs from behavioral specs. Builds state diagrams, excitation equations, gate-level logic, and verifies timing.
Creates comprehensive RTL implementation plans for hardware designs like DMA controllers, UARTs, and memory subsystems, covering blocks, interfaces, clocks, FSMs, and pipelines.
Generates breadboard circuit mockups and diagrams using HTML5 Canvas for retro projects with 6502, 555 timers, logic gates, LEDs, resistors, and wires.
Share bugs, ideas, or general feedback.
Translate a functional specification into a combinational logic circuit by defining inputs and outputs, deriving a minimal Boolean expression, mapping it to a gate-level schematic, optionally converting to a universal gate basis (NAND-only or NOR-only), and verifying correctness through exhaustive simulation against the original truth table.
Define the circuit's interface and behavior completely before any synthesis:
## Circuit Specification
- **Name**: [descriptive name]
- **Inputs**: [list with bit widths]
- **Outputs**: [list with bit widths]
- **Function**: [verbal description]
- **Truth table or minterm list**: [table or Sigma notation]
- **Don't-care set**: [d(...) or "none"]
Expected: A complete, unambiguous specification where every legal input combination maps to exactly one output value.
On failure: If the specification is ambiguous (e.g., missing cases, conflicting outputs for the same input), request clarification. Do not assume don't-care for unspecified inputs unless explicitly told to.
Obtain the simplest expression for each output using the evaluate-boolean-expression skill:
## Minimal Expressions
| Output | Minimal SOP | Literals | Terms |
|--------|-------------|----------|-------|
| F1 | [expression] | [count] | [count] |
| F2 | [expression] | [count] | [count] |
- **Shared sub-expressions**: [list, if any]
Expected: A minimal Boolean expression for each output, with shared sub-expressions identified for multi-output circuits.
On failure: If the expressions appear non-minimal (more literals than expected for the function's complexity), re-run the K-map or Quine-McCluskey step from evaluate-boolean-expression. For functions with more than 6 variables, use Espresso or a similar heuristic minimizer.
Convert the Boolean expressions into a network of logic gates:
## Gate-Level Netlist
| Gate ID | Type | Inputs | Output | Fan-in |
|---------|------|-------------|--------|--------|
| G1 | NOT | A | A' | 1 |
| G2 | AND | A', B | w1 | 2 |
| G3 | AND | A, C | w2 | 2 |
| G4 | OR | w1, w2 | F | 2 |
- **Total gates**: [count]
- **Critical path depth**: [number of gate levels from input to output]
Expected: A complete gate-level netlist where every output can be traced back to primary inputs through a chain of gates, with no floating (unconnected) inputs or outputs.
On failure: If the netlist has dangling wires or feedback loops (which are invalid in combinational circuits), recheck the mapping. Every signal must have exactly one driver and every gate input must connect to either a primary input or another gate's output.
Transform the circuit to use only NAND gates or only NOR gates:
A + B = ((A')*(B'))' = NAND(A', B'), so use NOTs on inputs then NAND.A' = NAND(A, A).A * B = ((A')+(B'))' = NOR(A', B').NOR(A, A).## Universal Gate Conversion
- **Target basis**: [NAND-only / NOR-only]
- **Gates before conversion**: [count]
- **Gates after conversion**: [count]
- **Gates after bubble-push optimization**: [count]
- **Conversion netlist**: [updated table]
Expected: A functionally equivalent circuit using only the target gate type, with redundant inversions eliminated via bubble pushing.
On failure: If the converted circuit has more inversions than expected, re-examine the bubble-pushing step. A common mistake is forgetting that NAND and NOR are self-dual under complementation -- applying De Morgan consistently from outputs back to inputs avoids this.
Confirm the circuit produces correct outputs for every possible input:
## Simulation Results
- **Total test vectors**: [count]
- **Vectors passed**: [count]
- **Vectors failed**: [count, with details if any]
- **Critical path**: [gate sequence, e.g., G1 -> G3 -> G7 -> G9]
- **Critical path depth**: [N gate levels]
- **Estimated worst-case delay**: [N * gate_delay]
Expected: All test vectors pass. The circuit is functionally correct and the critical path depth is documented.
On failure: If any vector fails, trace the signal path for that input combination gate by gate to find the first gate producing an incorrect output. Common causes: a wire connected to the wrong gate input, a missing inversion, or an error in the NAND/NOR conversion.
evaluate-boolean-expression -- derive the minimal Boolean expression used as input to this skillbuild-sequential-circuit -- add state elements (flip-flops) to create sequential circuitssimulate-cpu-architecture -- use combinational blocks (ALU, mux, decoder) as datapath components