Logic Gates¶
Logic gate definitions
- class schemdraw.logic.logic.And(*args, **kwargs)¶
AND gate
- Parameters:
inputs – Number of inputs to gate.
nand – Draw invert bubble on output
inputnots – Input numbers (starting at 1) of inputs that have invert bubble
leadin – Length of input leads [default: 0.35]
leadout – Length of output lead [default: 0.35]
- Anchors:
out in[X] - for each input
- class schemdraw.logic.logic.Buf(*args, **kwargs)¶
Buffer
- Anchors:
in out
- class schemdraw.logic.logic.Not(*args, **kwargs)¶
Not gate/inverter
- Anchors:
in out
- class schemdraw.logic.logic.NotNot(*args, **kwargs)¶
Double inverter
- Anchors:
in out
- class schemdraw.logic.logic.Or(*args, **kwargs)¶
OR or XOR gate element.
- Parameters:
inputs – Number of inputs to gate.
nor – Draw invert bubble on output
xor – Draw as exclusive-or gate
inputnots – Input numbers (starting at 1) of inputs that have invert bubble
leadin – Length of input leads [default: 0.35]
leadout – Length of output lead [default: 0.35]
- Anchors:
out in[X] - for each input
- class schemdraw.logic.logic.Schmitt(*args, **kwargs)¶
Schmitt Trigger
- Anchors:
in out
- class schemdraw.logic.logic.SchmittAnd(*args, **kwargs)¶
Schmitt Trigger AND
- Anchors:
in1 in2 out
- class schemdraw.logic.logic.SchmittNot(*args, **kwargs)¶
Inverted Schmitt Trigger
- Anchors:
in out
- class schemdraw.logic.logic.Tgate(*args, **kwargs)¶
Transmission gate.
- Anchors:
in out c cbar
- class schemdraw.logic.logic.Tristate(*args, **kwargs)¶
Tristate inverter :param outputnot: Draw invert bubble on output :param controlnot: Active-low control
- Anchors:
in out c
- logic_parser.logicparse(gateW: float = 2, gateH: float = 0.75, outlabel: str | None = None) Drawing ¶
Parse a logic string expression and draw the gates in a schemdraw Drawing
Logic expression is defined by string using ‘and’, ‘or’, ‘not’, etc. for example, “a or (b and c)”. Parser recognizes several symbols and names for logic functions: [and, ‘&’, ‘∧’] [or, ‘|’, ‘∨’, ‘+’] [xor, ‘⊕’, ‘⊻’] [not, ‘~’, ‘¬’]
- Parameters:
expr – Logic expression
gateH – Height of one gate
gateW – Width of one gate
outlabel – Label for logic output
- Returns:
schemdraw.Drawing with logic tree
- class schemdraw.logic.table.Table(*args, **kwargs)¶
Table Element for drawing rudimentary Markdown formatted tables, such as logic truth tables.
- Parameters:
table – Table definition, as markdown string. Columns separated by |. Separator rows contain — or === between column separators.
colfmt – Justification and vertical separators to draw for each column, similar to LaTeX tabular environment parameter. Justification characters include ‘c’, ‘r’, and ‘l’ for center, left, and right justification. Separator characters may be ‘|’ for a single vertical bar, or ‘||’ or ‘ǁ’ for a double vertical bar, or omitted for no bar. Example: ‘cc|c’.
fontsize – Point size of table font
font – Name of table font
- Example Table:
| A | B | Y | |—|—|—| | 0 | 0 | 1 | | 0 | 1 | 0 | | 1 | 0 | 0 | | 1 | 1 | 0 |
- class schemdraw.logic.kmap.Kmap(*args, **kwargs)¶
Karnaugh Map
Draws a K-Map with 2, 3, or 4 variables.
- Parameters:
names – 2, 3, or 4-character string defining names of the inputs
truthtable – list defining values to display in each box of the K-Map. First element is string of 2, 3, or 4 logic 0’s and 1’s, and last element is the string to display for that input. Example: (‘0000’, ‘1’) displays a ‘1’ when all inputs are 0.
groups – dictionary of style parameters for circling groups of inputs. Dictionary key must be same length as names, and defines which elements are circled using ‘0’, ‘1’, or ‘.’ in each position. For example, ‘1…’ circles every box where A=1, and ‘.11.’ circles every box where both B and C are 1. Value of dictionary pair is another dictionary containing style of box (e.g. color, fill, lw, and ls).
default – string to display in boxes that don’t have a truthtable entry defined
- Anchors:
cellXXXX - Center of each cell in the grid, where X is 0 or 1
- class schemdraw.logic.timing.TimingDiagram(*args, **kwargs)¶
Logic Timing Diagram
Draw timing diagrams compatible with WaveJSON format See https://wavedrom.com/ for details. Use from_json to use WaveJSON strings copied from the site (since they can’t be copied as proper Python dicts due to lack of quoting).
Schemdraw provides a few additional extensions to the WaveJSON dictionary, including asynchronous waveforms and configuration options (color, lw) on each wave. See documentation for full specification.
- Parameters:
wave – WaveJSON as a Python dict
- Keyword Arguments:
yheight – Height of one waveform
ygap – Separation between two waveforms
risetime – Rise/fall time for wave transitions
fontsize – Size of label fonts
nodesize – Size of node labels
namecolor – Color for wave names
datacolor – Color for wave data text
nodecolor – Color for node text
gridcolor – Color of background grid