Timing Diagrams

Timing diagrams, based on WaveDrom, are drawn using the schemdraw.logic.timing.TimingDiagram class.

from schemdraw import logic

SRAM read/write cycle

The SRAM examples make use of Schemdraw’s extended ‘edge’ notation for labeling timings just above and below the wave.

../_images/timing_1_01.svg
logic.TimingDiagram(
    {'signal': [
        {'name': 'Address',     'wave': 'x4......x.', 'data': ['Valid address']},
        {'name': 'Chip Select', 'wave': '1.0.....1.'},
        {'name': 'Out Enable',  'wave': '1.0.....1.'},
        {'name': 'Data Out',    'wave': 'z...x6...z', 'data': ['Valid data']},
    ],
     'edge': ['[0^:1.2]+[0^:8] $t_{WC}$',
              '[0v:1]+[0v:5] $t_{AQ}$',
              '[1:2]+[1:5] $t_{EQ}$',
              '[2:2]+[2:5] $t_{GQ}$',
              '[0^:5]-[3v:5]{lightgray,:}',
             ]
    }, ygap=.5, grid=False)
../_images/timing_2_01.svg
logic.TimingDiagram(
    {'signal': [
        {'name': 'Address',      'wave': 'x4......x.', 'data': ['Valid address']},
        {'name': 'Chip Select',  'wave': '1.0......1'},
        {'name': 'Write Enable', 'wave': '1..0...1..'},
        {'name': 'Data In',      'wave': 'x...5....x', 'data': ['Valid data']},
    ],
     'edge': ['[0^:1]+[0^:8] $t_{WC}$',
              '[2:1]+[2:3] $t_{SA}$',
              '[3^:4]+[3^:7] $t_{WD}$',
              '[3^:7]+[3^:9] $t_{HD}$',
              '[0^:1]-[2:1]{lightgray,:}'],
    }, ygap=.4, grid=False)

J-K Flip Flop

Timing diagram for a J-K flip flop taken from here. Notice the use of the async dictionary parameter on the J and K signals, and the color parameters for the output signals.

../_images/timing_3_01.svg
logic.TimingDiagram(
    {'signal': [
        {'name': 'clk', 'wave': 'P......'},
        {'name': 'J', 'wave': '0101', 'async': [0, .8, 1.3, 3.7, 7]},
        {'name': 'K', 'wave': '010101', 'async': [0, 1.2, 2.3, 2.8, 3.2, 3.7, 7]},
        {'name': 'Q', 'wave': '010.101', 'color': 'red', 'lw': 1.5},
        {'name': r'$\overline{Q}$', 'wave': '101.010', 'color': 'blue', 'lw': 1.5}],
    'config': {'hscale': 1.5}}, risetime=.05)

Tutorial Examples

These examples were copied from WaveDrom Tutorial. They use the from_json class method so the examples can be pasted directly as a string. Otherwise, the setup must be converted to a proper Python dictionary.

../_images/timing_4_01.svg
logic.TimingDiagram.from_json('''{ signal: [{ name: "Alfa", wave: "01.zx=ud.23.456789" }] }''')
../_images/timing_5_01.svg
logic.TimingDiagram.from_json('''{ signal: [
  { name: "clk",         wave: "p.....|..." },
  { name: "Data",        wave: "x.345x|=.x", data: ["head", "body", "tail", "data"] },
  { name: "Request",     wave: "0.1..0|1.0" },
  {},
  { name: "Acknowledge", wave: "1.....|01." }
  ]}''')