summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/tikz-timing/tikz-timing.dtx
blob: 3f2780ec51eed7deee3458fabca1f895a0161bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
% \iffalse meta-comment
%
% Copyright (C) 2009 by Martin Scharrer <martin@scharrer-online.de>
% -----------------------------------------------------------------
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.
% The latest version of this license is in
%
%   http://www.latex-project.org/lppl.txt
%
% and version 1.3c or later is part of all distributions of LaTeX
% version 2008/05/04 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Martin Scharrer.
%
% This work consists of the files tikz-timing.dtx, tikz-timing.ins
% and the derived file tikz-timing.sty.
%
% $Id: tikz-timing.dtx 1132 2009-05-15 15:23:50Z martin $
% \fi
%
% \iffalse
%<*driver>
\makeatletter
%</driver>
\RequirePackage{svn-prov}[2009/05/03]
%<package>\ProvidesPackageSVN
%<examplecode>\ProvidesPackageSVN[tikz-timing-examplecode]
%<ydoc>\ProvidesPackageSVN[ydoc]
%<*driver>
\ProvidesFileSVN
%</driver>
  {$Id: tikz-timing.dtx 1132 2009-05-15 15:23:50Z martin $}
  [v0.5
%<package>   Digital Timing Diagrams using TikZ]
%<examplecode>   Macros to produce examples for the tikz-timing package]
%<ydoc>   Documentation Macros for tikz-timing package]
%<*driver>
  DTX-File of 'tikz-timing' package.]
%</driver>
%<*package|driver>
\DefineFileInfoSVN[tikztiming]
%</package|driver>
%<!package>\DefineFileInfoSVN
%<examplecode>\RequirePackage{tikz-timing}%
%<examplecode>\RequirePackage{pgffor}%
%<examplecode>\usetikzlibrary{calc}%
%<*driver>
\documentclass{ltxdoc}
\usepackage{tikz-timing}[\tikztiming@date]
\makeatother
\usepackage[electronic]{ifsym}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{ifpdf}
\usepackage{xcolor}
\usepackage{tabularx}
\usepackage{array}
\usepackage{flafter,fnpos}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{placeins}
\makeFNbottom
\makeFNbelow
\usepackage{microtype}
\DisableLigatures{encoding = T1, family = tt* }%

\makeatletter
%</driver>
%<*ydoc>
% Restore article settings:
\textwidth 345.0pt
\marginparwidth 65.0pt
\oddsidemargin 62.0pt
\evensidemargin 62.0pt\relax

% use hypdoc if you have it, hyperref else
\IfFileExists{hypdoc.sty}
  {\RequirePackage{hypdoc}}
  {\RequirePackage{hyperref}}
\RequirePackage{embedfile}
\hypersetup{bookmarksopen=true,bookmarksopenlevel=2}
\RequirePackage{xspace}
\newcommand{\ie}{i.e.\@\xspace}
\newcommand{\eg}{e.g.\@\xspace}

\RequirePackage{xspace}
\@namedef{seen@package@latex}{1} %^^A avoid footnotes for 'latex'
\newcommand*{\pkgctanurl}[1]{%
  CTAN: \url{http://www.ctan.org/pkg/#1}%
}
\newcommand*{\pkg}[2][\@tempa]{%
  \begingroup
  \def\@tempa{#2}%
  \let\@tempb\empty
  \ifx\@tempa#1%
    \def\@tempb{}%
  \else
    \def\@tempb{Part of the \texttt{#1} package,\ }%
  \fi
  \href{http://www.ctan.org/pkg/#1}{\texttt{\@tempa}}%
  % URL footnote (for print-out) on first appearance:
  \@ifundefined{seen@package@#2}{%
    \footnote{\@tempb\pkgctanurl{#1}}%
    \expandafter\gdef\csname seen@package@#2\endcsname{}%
  }{}%
  \endgroup
  \xspace
}
\newcommand*{\pkgnoctan}[3][]{%
  \href{#3}{\texttt{#2}}%
  % URL footnote (for print-out) on first appearance:
  \@ifundefined{seen@package@#2@#3}{%
    \footnote{#1\url{#3}}%
    \@namedef{seen@package@#2@#3}{1}%
  }{}%
  \xspace
}

\newcommand*{\itempkg}[2][]{%
  \item[\pkg{#2}#1]\footnotetext{\pkgctanurl{#2}}%
}

\newcommand*{\itempkgnoctan}[3][]{%
  \item[\pkgnoctan{#2}{#3}#1]\footnotetext{Location: \url{#3}}%
}

% link \cs to macro definitions
\let\ydoc@origmacro\macro
\let\ydoc@origendmacro\endmacro
\let\ydoc@origStopEventually\StopEventually
\let\ydoc@origPrintDescribeMacro\PrintDescribeMacro
\RequirePackage{xcolor}
\definecolor{darkred}{rgb}{0.333.0.0,0.0}
\hypersetup{colorlinks=true,linkcolor=darkred,urlcolor=darkred}
\definecolor{macrodesccolor}{rgb}{0.0,0.0,0.8}
\definecolor{macroimplcolor}{rgb}{0.0,0.0,0.4}
\definecolor{metacolor}{rgb}{0.0,0.4,0.4}
\definecolor{scriptcolor}{rgb}{0.2,0.6,0.2}
\definecolor{optioncolor}{rgb}{0.3.0.2,0}

\let\macroline\\
\newlength{\macrosep}
\setlength{\macrosep}{-3em}
\renewcommand{\meta@font@select}{\color{metacolor}\itshape}
\newcommand{\macroformat}[1]{\textbf{\ttfamily #1}}
\newcommand{\optionformat}[1]{\textbf{\sffamily #1}}
\newcommand{\scriptformat}[1]{\textbf{\ttfamily #1}}
\newcommand{\macroargformat}[1]{\texttt{#1}}
\newcommand{\scriptargformat}[1]{\textbf{#1}}
\newcommand{\macrohlinkprefix}{desc}
\newcommand{\macrolink}{}

\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\IfFileExists{lmodern.sty}{\RequirePackage{lmodern}}{}%

\def\DescribeMacro{\@ifnextchar*{\DescribeMacroS}{\DescribeMacroN}}
\def\DescribeMacroN{%
  \bigskip\pagebreak[3]\par\noindent\DescribeMacroS*%
}
\def\DescribeMacroS*#1#2{%
  \begingroup
  \g@namedef{href@desc@#1}{}%
  \immediate\write\@mainaux{%
    \noexpand\g@namedef{href@desc@#1}{}%
  }%
  \@ifundefined{href@impl@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{impl@#1.3}}}%
  \hypersetup{linkcolor=macrodesccolor}%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{\textbackslash #1}{desc@#1}}%
  \macrolink{\macroformat{\textcolor{macrodesccolor}{\textbackslash #1}}}%
  \noindent\mbox{}\macroargformat{#2}\nopagebreak
  \macroline*[0.2\baselineskip]%
  \endgroup
  \nopagebreak
  \ignorespaces
}

\def\DescribeMacro{\@ifnextchar*{\DescribeMacroS}{\DescribeMacroN}}
\def\DescribeMacroN{%
  \bigskip\pagebreak[3]\par\noindent\DescribeMacroS*%
}
\def\DescribeMacroS*#1#2{%
  \begingroup
  \g@namedef{href@desc@#1}{}%
  \immediate\write\@mainaux{%
    \noexpand\g@namedef{href@desc@#1}{}%
  }%
  \@ifundefined{href@impl@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{impl@#1.3}}}%
  \hypersetup{linkcolor=macrodesccolor}%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{\textbackslash #1}{desc@#1}}%
  \macrolink{\macroformat{\textcolor{macrodesccolor}{\textbackslash #1}}}%
  \noindent\mbox{}\macroargformat{#2}\nopagebreak
  \macroline*[0.2\baselineskip]%
  \endgroup
  \nopagebreak
  \ignorespaces
}

\def\DescribeEnv{\@ifnextchar*{\DescribeEnvS}{\DescribeEnvN}}
\def\DescribeEnvN{%
  \bigskip\pagebreak[3]\par\noindent\DescribeEnvS*%
}
\def\DescribeEnvS*#1#2{%
  \begingroup
  \g@namedef{href@desc@#1}{}%
  \immediate\write\@mainaux{%
    \noexpand\g@namedef{href@desc@#1}{}%
  }%
  \@ifundefined{href@impl@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{impl@#1.3}}}%
  \hypersetup{linkcolor=macrodesccolor}%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{#1}{desc@#1}}%
  \css{begin}%
  \{\macrolink{\macroformat{\textcolor{macrodesccolor}{#1}}}\}%
  \noindent\mbox{}\macroargformat{#2}\\*\relax
  \hspace*{\macrosep}%
  \css{end}%
  \{\macrolink{\macroformat{\textcolor{macrodesccolor}{#1}}}\}%
  \nopagebreak
  \macroline*[0.2\baselineskip]%
  \endgroup
  \nopagebreak
  \ignorespaces
}

\def\DescribeScript{\@ifnextchar*{\DescribeScriptS}{\DescribeScriptN}}
\def\DescribeScriptN{%
  \bigskip\par\pagebreak[2]\noindent\DescribeScriptS*%
}
\def\DescribeScriptS*#1#2{%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{Script #1}{script@#1}}%
  \scriptformat{\textcolor{scriptcolor}{#1}}%
  \noindent\mbox{}\scriptargformat{\ {#2}}\macroline*[0.2\baselineskip]%
  \nopagebreak
}
\def\DescribeOption{\@ifnextchar*{\DescribeOptionS}{\DescribeOptionN}}
\def\DescribeOptionN{%
  \bigskip\par\noindent\DescribeOptionS*%
}
\def\DescribeOptionS*#1{%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{Option #1}{option@#1}}%
  \optionformat{\textcolor{optioncolor}{#1}}%
  \noindent\mbox{}\macroline*[0.2\baselineskip]%
  \nopagebreak
}
\newcounter{macrolevel}
\renewenvironment{macro}[1]{%
  \addtocounter{macrolevel}{1}%
  \expandafter\macroX\expandafter{\expandafter\@gobble\string#1}%
}{%
  \addtocounter{macrolevel}{-1}%
}
\providecommand*{\g@namedef}[1]{%
  \expandafter\gdef\csname #1\endcsname
}
\newcommand*{\macroX}[1]{%
  \ifnum\c@macrolevel<2
    \smallskip
  \fi
  \par\noindent
  \g@namedef{href@impl@#1}{}%
  \immediate\write\@mainaux{%
    \noexpand\g@namedef{href@impl@#1}{}%
  }%
  \@ifundefined{href@desc@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{desc@#1.3}}}%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{\textbackslash #1}{impl@#1}}%
  \macrolink{\macroformat{%
    \textcolor{macroimplcolor}{\textbackslash #1}}}%
  \\*[\smallskipamount]%
  \@ifnextchar\begin{\vspace*{-\baselineskip}}{\imacroarg}%
}

\renewenvironment{environment}[1]{%
  \addtocounter{macrolevel}{1}%
  \environmentX{#1}%
}{%
  \addtocounter{macrolevel}{-1}%
}
\newcommand*{\environmentX}[1]{%
  \ifnum\c@macrolevel<2
    \smallskip
  \fi
  \par\noindent
  \g@namedef{href@impl@#1}{}%
  \immediate\write\@mainaux{%
    \noexpand\g@namedef{href@impl@#1}{}%
  }%
  \@ifundefined{href@desc@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{desc@#1.3}}}%
  \hspace*{\macrosep}%
  \raisebox{\baselineskip}[\baselineskip]{\pdfbookmark[3]{#1}{impl@#1}}%
  \macrolink{\macroformat{%
    \textcolor{macroimplcolor}{#1}}}%
  \\*[\smallskipamount]%
  \@ifnextchar\begin{\vspace*{-\baselineskip}}{\imacroarg}%
}

\newcounter{macroargs}
\newcounter{nmacroarg}

\newcommand*{\imacroarg}[1][0]{%
  \setcounter{macroargs}{#1}%
  \setcounter{nmacroarg}{1}%
  \ifnum\c@macroargs>0
    \expandafter\imacroargX
  \fi
}
\newcommand*{\aftermacroargs}{%
  \@ifnextchar\begin
    {\\*[-2ex]\ignorespaces}%
    {\\*[\smallskipamount]\ignorespaces}%
}
\newcommand*{\imacroargX}[1]{%
  \ifnum\c@macroargs>1
    \newline
  \fi
  \addtocounter{nmacroarg}{1}%
  \addtocounter{macroargs}{-1}%
  \ifnum\c@macroargs>0
    \expandafter\imacroargX
  \else
    \expandafter\aftermacroargs
  \fi
}


\def\karg#1{\{\$\textcolor{metacolor}{#1}\$\}}
\def\kmarg#1{\{\$\meta{#1}\$\}}

\DeclareRobustCommand{\csi}[1]{%
  \begingroup
  \hypersetup{linkcolor=macroimplcolor}%
  \renewcommand{\macrohlinkprefix}{impl}%
  \@ifundefined{href@impl@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{impl@#1.3}}}%
  \csX{#1}%
  \endgroup
}
\DeclareRobustCommand{\csd}[1]{%
  \begingroup
  \hypersetup{linkcolor=macrodesccolor}%
  \renewcommand{\macrohlinkprefix}{macro}%
  \@ifundefined{href@desc@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{desc@#1.3}}}%
  \csX{#1}%
  \endgroup
}
\DeclareRobustCommand{\csX}[1]{%
  \begingroup
  \macrolink{\texttt{\textbackslash#1}}%
  \endgroup
}

\DeclareRobustCommand{\envi}[1]{%
  \begingroup
  \hypersetup{linkcolor=macroimplcolor}%
  \renewcommand{\macrohlinkprefix}{impl}%
  \@ifundefined{href@impl@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{impl@#1.3}}}%
  \envX{#1}%
  \endgroup
}
\DeclareRobustCommand{\envd}[1]{%
  \begingroup
  \hypersetup{linkcolor=macrodesccolor}%
  \renewcommand{\macrohlinkprefix}{macro}%
  \@ifundefined{href@desc@#1}%
    {\let\macrolink\relax}%
    {\def\macrolink{\hyperlink{desc@#1.3}}}%
  \envX{#1}%
  \endgroup
}
\DeclareRobustCommand{\envX}[1]{%
  \begingroup
  \macrolink{\texttt{\{#1\}}}%
  \endgroup
}
\let\cs\csd
\let\env\envd
\DeclareRobustCommand{\css}[1]{\texttt{\textbackslash#1}}
\DeclareRobustCommand{\envv}[1]{\texttt{\{#1\}}}
\DeclareRobustCommand{\op}[1]{%
  \begingroup
  \hypersetup{linkcolor=optioncolor}%
  \hyperlink{option@#1.3}{\textbf{\sffamily #1}}%
  \endgroup
}
\DeclareRobustCommand{\scr}[1]{%
  \begingroup
  \hypersetup{linkcolor=scriptcolor}%
  \hyperlink{script@#1.3}{\scriptformat{#1}}%
  \endgroup
}

\def\StopEventually#1{\ydoc@origStopEventually{#1}%
\let\cs\csi
\let\env\envi
}

%%% Macrocode %%%
\iffalse
\RequirePackage{listings}

\def\macrocode@catcodes{%
  \let\do\@makeother
  \dospecials
  \@makeother\ \relax
  \@makeother\^^M\relax
}

\begingroup
\endlinechar=-1\relax
\@makeother\^^M\relax
\gdef\macrocode{\begingroup\macrocode@catcodes\macrocode@}%
\gdef\macrocode@#1^^M{\endgroup\begingroup\macrocode@catcodes\macrocode@@}%
\endgroup%

\begingroup%
\endlinechar=-1\relax
\catcode`\(=\catcode`\{
\catcode`\)=\catcode`\}
\catcode`\{=12
\catcode`\}=12
\catcode`\ =12
\catcode`\|=0
\@makeother\^^M\relax
\catcode`\%=12
\catcode`\\=12
|long|gdef|macrocode@@#1^^M%    \end{macrocode}(|endgroup|handlemacrocode@(#1))
|endgroup


\def\handlemacrocode@#1{%
  \handlemacrocode{#1}%
  \end{macrocode}%
}

\newwrite\macrocode@write
\newwrite\codeoutput@write
\def\codeoutput@header{\@percentchar\@percentchar\space Code!}
\def\codeoutput@footer{^^J\noexpand\endinput}

\AtBeginDocument{%
  \immediate\openout\codeoutput@write=\jobname.stv\relax
  \immediate\write\codeoutput@write{\codeoutput@header}%
}

\lstset{%
  numbers=left,
  numberstyle=\tiny\sffamily,
  basicstyle=\ttfamily\small,
  stepnumber=1,
  firstnumber=last,
  language=[latex]tex,
  breaklines,
  name=macrocode
}%

\def\handlemacrocode#1{%
  \immediate\openout\macrocode@write=\jobname.mcr\relax
  \newlinechar=13\relax
  \immediate\write\macrocode@write{#1}%
  \immediate\write\codeoutput@write{#1}%
  \immediate\closeout\macrocode@write
  %\gdef\code{#1}%
  \par\noindent\lstinputlisting{\jobname.mcr}%
  %\gdef\code{\scantokens{#1}}%
}

\def\endmacrocode{}

\AtEndDocument{%
  \immediate\write\codeoutput@write{\codeoutput@footer}%
  \immediate\closeout\codeoutput@write
}
\fi


%%% Examples %%%
\RequirePackage{fancyvrb}
\RequirePackage{listings}
\RequirePackage{float}

\belowcaptionskip=\abovecaptionskip
\floatstyle{plaintop}
\restylefloat{table}

\floatstyle{plain}
\restylefloat{figure}

\newfloat{example}{tbph}{fle}
\floatname{example}{Example}
\newwrite\ydoc@exawrite
\newread\ydoc@exaread

\def\ydoc@exahead{%
  \@percentchar\space
  TikZ-Timing \tikztiming@version\space\tikztiming@date\space
  Example \the\c@example:^^J^^J%
  \string\documentclass{article}^^J%
  \string\usepackage{tikz-timing}[\tikztiming@date]^^J%
  \string\pagestyle{empty}^^J%
  \exampleextraheader^^J%
  \string\begin{document}^^J\@percentchar
}
\def\ydoc@exafoot{%
  \@percentchar^^J%
  \string\end{document}%
}
\let\exampleextraheader\empty

\def\writeexample{%
  \begingroup
    \advance\c@example by 1\relax%
    \immediate\openout\ydoc@exawrite=\jobname\the\c@example.exb\relax
    \openin\ydoc@exaread=\jobname.exa\relax
    \let\do\@makeother\dospecials
    \immediate\write\ydoc@exawrite{\ydoc@exahead}%
    \endlinechar=-1%
    \copylines
    \immediate\write\ydoc@exawrite{\ydoc@exafoot}%
    \immediate\closeout\ydoc@exawrite
    \closein\ydoc@exaread
    \tikztiming@embedexample
  \endgroup
}

\def\copylines{%
  \read\ydoc@exaread to \line%
  \ifeof\ydoc@exaread\else
    \immediate\write\ydoc@exawrite{\line}%
    \expandafter\copylines
  \fi
}

\newenvironment{exampletable}{%
  \floatstyle{plaintop}%
  \restylefloat{example}%
  \example
}{\endexample}

\newenvironment{examplecode}
  {\begingroup\VerbatimOut[gobble=4]{\jobname.exa}}
  {\endVerbatimOut\endgroup\writeexample
  \formatexample}

\newsavebox{\examplecodebox}
\newsavebox{\exampleresultbox}
\usepackage{ifthen,calc}

\def\formatexample{%
  \par\noindent
  \catcode`\%=14%
  \makebox[\textwidth]{\null
  \makebox%[0.5\textwidth]
  {\lstinputlisting{\jobname.exa}}\hfill \makebox%[0.5\textwidth]
  {\fbox{\input{\jobname.exa}}}%
  }%
}

\def\formatexample{%
  \begingroup
  \savebox{\examplecodebox}{\lstinputlisting{\jobname.exa}}
  \savebox{\exampleresultbox}{\catcode`\%=14\input{\jobname.exa}}%
  %
  \par\noindent
  \setlength{\@tempdima}{\wd\examplecodebox + \wd\exampleresultbox}%
  \ifthenelse{\linewidth < \@tempdima}%
    {%
      \centerline{\usebox{\examplecodebox}} \\[\bigskipamount]%
      \centerline{\usebox{\exampleresultbox}}%
    }%
    {%
      \minipage[c]{\wd\examplecodebox}\hbox{\usebox{\examplecodebox}}\endminipage%
      \hfill
      \minipage[c]{\wd\exampleresultbox}\hbox{\usebox{\exampleresultbox}}\endminipage%
      \\%
    }%
  \endgroup
  \par
}

\def\tikztiming@embedexample{%
  \embedfile[filespec=example\arabic{example}.tex,mimetype=text/x-tex,
    desc={Source Code to Example \arabic{example}}]{\jobname\the\c@example.exb}%
}

\lstset{%
  %numbers=left,
  numberstyle=\scriptsize\sffamily,
  basicstyle=\ttfamily,
  stepnumber=1,
  language=[latex]tex,
  breaklines,
}%

%%% %%%
%</ydoc>
%<*driver>
\makeatother

\def\topfraction{0.91}
\def\bottomfraction{0.89}
\def\floatpagefraction{0.9}
\def\textfraction{0.09}

\makeatletter
% The following code is only needed to produce package examples and therefor not 
% included in the style file but might be written to an additional file.
%    \begin{macrocode}
%</driver>
%<*examplecode>
\ifx\collect@body\@undefined
  \IfFileExists{environ.sty}
    {\RequirePackage{environ}}
    {\RequirePackage{amsmath}}
\fi
%    \end{macrocode}

% \begin{environment}{tikztimingexampletable}
%    \begin{macrocode}
\newenvironment{tikztimingexampletable}[1][]{%
  \tikzpicture[timing/table,#1]%
  \coordinate (last row) at (0,-1);
  \coordinate (label pos) at (-1,0);
  \collect@body\tikztimingexampletable@
}{}%
%    \end{macrocode}
% \end{environment}

% \begin{macro}{\tikztimingexampletable@}
%    \begin{macrocode}
\def\tikztimingexampletable@#1{%
  \tikztimingexampletable@row#1\endtikztimingtable@
  \path (0,-1) +(-\tikztiming@coldist,0.5*\tikztiming@rowdist) node
    [anchor=base east,timing/name] {Characters};
  \path (0,-1) +(0,0.5*\tikztiming@rowdist) node
    [anchor=base west,timing/name] {Resulting Diagram};
  \draw [line width=\lightrulewidth]
     (current bounding box.north west) +(-1,-2) --
     ($ (current bounding box.north east) +(+1,-2) $);
  \draw [line width=\heavyrulewidth]
     (current bounding box.north west) +(0,1) --
     ($ (current bounding box.north east) +(0,0) $);
  \draw [line width=\heavyrulewidth]
     (current bounding box.south west) +(0,-1) --
      ($ (current bounding box.south east) +(0,0) $);
  \endtikzpicture
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\tikztimingexampletable@row}
%    \begin{macrocode}
\def\tikztimingexampletable@row#1\\{%
  \def\tikztiming@text{#1}%
  \@onelevel@sanitize\tikztiming@text
  \path (last row) +(0,-1*\tikztiming@rowdist) coordinate (last row);
  \path (last row) +(-1*\tikztiming@coldist,0) node
    [anchor=base east,timing/name]
    {\ttfamily\tikztiming@text};
  \timing at (last row) {#1};
  \@ifnextchar\extracode
    {\tikztimingextracode}%
    {%
      \@ifnextchar\endtikztimingtable@
        {\@gobble}{\tikztimingexampletable@row}%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingfullexampletable}
%    \begin{macrocode}
\def\tikztimingfullexampletable{
  \begin{tikzpicture}[x=1em,y=1em,font=\sffamily]
    \tikzset{timing/d/background/.style={fill={gray!25},fill opacity=0.5}}%
    \iffalse
    \def\chars{\@gobble}%
    \def\@tempa{}%
    \@for\tchar:=\tikztiming@chars\do{%
      \expandafter\lowercase\expandafter{\expandafter\def\expandafter\@tempa
      \expandafter{\tchar}}%
      \edef\chars{\chars,\tchar,\@tempa}%
    }
    \else
    \let\chars\tikztiming@chars
    \fi
    \node (charnode) at (0,0) {%
       \scalebox{0.4}%
         {\rotatebox{-45}{$\frac{\mbox{\rotatebox{45}{to}}}%
         {\mbox{\rotatebox{45}{from}}}$}}%
    };
    \coordinate (charnodex) at (0.25,0);%
    \coordinate (charnodey) at (0,0);%
    \expandafter\foreach
    \expandafter\tchar
    \expandafter i\expandafter n\expandafter{\chars} {%
      \path (charnodex) ++(+2,0) node (charnodex) {\strut\tchar};
      \path (charnodey) ++(0,-2) node (charnodey) {\strut\tchar};
    }%
    \draw [line width=\heavyrulewidth] (charnodex) +(+1,+1) -- (-1,+1);
    \draw [line width=\lightrulewidth]  (charnodex) +(+1,-1) -- (-1,-1);
    \draw [line width=\lightrulewidth]  (charnodey) +(+1,-0.6) -- (+1,-1.4) 
    (+1,-0.6) -- (+1,+0.6);
    \draw [line width=\heavyrulewidth] (charnodey) ++(-1,-1) -- +($ (2,0) + 
    (charnodex) $);
    %
    \path (1.5,-2) node (charnodex) {\strut};
    \coordinate (charnodex) at (charnodex.base);
    \coordinate (charnodey) at (charnodex.base);
    \def\@tempa{\timing at (charnodey)}
    \expandafter\foreach
    \expandafter\xchar
    \expandafter i\expandafter n\expandafter{\chars} {
    \expandafter\foreach
    \expandafter\ychar
    \expandafter i\expandafter n\expandafter{\chars} {
      \draw [xstep={\timingwidth/2.},ystep={\timingheight/2.},timing/grid,
        shift={(charnodey)}]
        (0,0) grid +(2,1);
      \expandafter\@tempa\expandafter{\ychar\xchar};
      \path (charnodey) +(0,-2) node (charnodey) {};
    }
    \path (charnodex) ++(+2,0) node (charnodex) {} node (charnodey) {};
    }
  \end{tikzpicture}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</examplecode>
%<*driver>
%    \end{macrocode}
\makeatother

\EnableCrossrefs
%\CodelineIndex
\RecordChanges
%\OnlyDescription
\listfiles
\begin{document}
  \DocInput{tikz-timing.dtx}
  \PrintChanges
  %\newpage\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{1998}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.3}{2009/04/24}{First released version}
% \changes{v0.4}{2009/04/28}{Added output routine which combines successive 
% occurrences of the same character. This improves screen display quality and 
% reduces rendering time and file size.}
% \changes{v0.4}{2009/04/28}{Removed own macros for lowercase characters. They 
% are now handled by the uppercase macros which receive half of the width.  
% Exceptions are possible like for the `m' character.}
% \changes{v0.4}{2009/04/29}{Added parser for rows in \env{tikztimingtable}.  
% This makes the syntax much more stable. Also replaced row counter with TikZ 
% coordinates which is more user-friendly.}
% \changes{v0.4}{2009/04/30}{User macros to draw grids and lines inside table.}
% \changes{v0.4}{2009/05/01}{In-line Nodes, \eg to mark positions inside the 
% diagram.}
% \changes{v0.4}{2009/05/03}{Released as v0.4}
% \changes{v0.4a}{2009/05/05}{Added \cs{tablerules} macro. Changed default style 
% of inline nodes to \texttt{coordinate}.}
% \changes{v0.5}{2009/05/15}{Added PGF shape for timing diagrams. Added 
% meta-characters. Changed `M' character to use PGF decorations. Added special 
% `B' character to reduce width of next character. Changed \cs{timing} syntax to 
% include an `at' before the coordinate. Bug fix for use with the `calc' 
% package.}
%
% \GetFileInfo{tikz-timing.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\edef,\xdef,\DeclareRobustCommand}
% \DoNotIndex{\expandafter,\if,\else,\fi,\ifnum,\ifx,\let,\global,\long}
% \DoNotIndex{\newcounter,\newcount,\message,\meaning,\noexpand,\relax,\value}
% \DoNotIndex{\setcounter,\addtocounter,\advance,\afterassignment,\AtEndOfPackage}
% \DoNotIndex{\ProvidesPackage,\providecommand,\RequirePackage,\empty,\begin,\end}
% \DoNotIndex{\begingroup,\bgroup,\egroup,\endgroup,\csname,\endcsname,\@tempa}
% \DoNotIndex{\ignorespaces,\lccode,\sffamily,\@gobble,\@ifundefined,\@for,\or}
% \DoNotIndex{\@firstoftwo,\@ifnextchar,\@namedef,\@nameuse,\@secondoftwo}
% \DoNotIndex{\@temptokena,\toks@,\BODY,\do,\g@addto@macro,\lowercase,\uppercase,\the}
% \DoNotIndex{\height,\width,\slope,\style,\draw,\path,\newdraw,\lastchar,\currentchar}
% \DoNotIndex{\dslope,\zslope}
%
% \ifpdf
% \hypersetup{%
%   pdfauthor   = {Martin Scharrer <martin@scharrer-online.de>},
%   pdftitle    = {The svn-multi package, \fileversion\ from \filedate},
%   pdftitle    = {The tikz-timing package},
%   pdfsubject  = {Documentation of LaTeX package tikz-timing which allows the 
%   easy creation of timing diagrams inside tikz pictures or text.},
%   pdfkeywords = {tikz-timing, timing diagram, LaTeX}
% }%
% \fi
% \clearpage
% \null
% \vspace*{-2em}
% \begin{center}
%   \tikzset{timing/z/.style={black},
%   timing/intext/.style={timing,line width=0.1ex}}
%   {\LARGE\sffamily The \raisebox{-0.66ex}{\Huge\textsf
%   {\texttiming[z]{3d{\strut tikz}z5d{\strut timing}0.2z}}} package}\\[3ex]
%   {\large Martin Scharrer \\\normalsize 
%   \url{martin@scharrer-online.de}\\[.8ex]
%   \url{http://www.ctan.org/pkg/tikz-timing}\\[1.2ex]}
%   {\large Version \fileversion\ -- \filedate}\\
% \end{center}
% \vspace{1.2em}%
%
% ^^A\vfill
% \noindent
% ^^A\textbf{Note to Advanced Users:} This is a new package which internal
% ^^Amacros might still change.  Please only rely on the user macros for now.
%
% \section{Introduction}
% This package uses the \pkg[pgf]{tikz} package to produce timing diagrams 
% inside text or \envv{tikzpicture} environments.  Also a tabular-like 
% environment is provided to produce a larger timing diagram with multiple 
% labeled signals and the possibility to add own drawing material.
%
% The signal levels of the timing diagram can be given by corresponding 
% characters/letters like `|H|' for \emph{Logical High} or `|L|' for 
% \emph{Logical Low}. So e.g.\ `|{HLZXD}|' gives `\texttiming{HLZXD}'.  
% Lowercase characters only produce a signal with half the width while uppercase 
% characters produce one with the ``full'' width, called the `\textsf{period 
% width}' in this document and which is by default identical to there height, 
% called `\textsf{signal height}', which defaults to 1.6ex (about the height of 
% the uppercase `X' of the current font).
% Table~\ref{tab:chars} shows all by default defined logic characters and 
% Table~\ref{tab:full} all possible transitions.
% Additional functionality is provided by the ``modifiers'' shown in 
% Table~\ref{tab:modifiers}.
% 
% \iffalse
% The package is build to make it possible to define new characters from scratch 
% or as modified copy of other characters. However, no user macros nor 
% documentation for this are provided at the moment. Interested \LaTeX\ users 
% should look at the default definitions at the end of the source code.
% \fi
%
% \begin{table}[b!]
% \let\texttimingbefore\texttiminggrid
% \sffamily\centering
% \caption{Timing Characters}\label{tab:chars}
% \begin{tabular}{clccc}
%   \toprule
%   Character & Description & Full Width & Half Width & Transition \\
%             &             & \small (Uppercase) & \small (Lowercase) & Example 
%             \\\midrule
% \texttt{H} & High & \texttiming{H} & \texttiming{h} & \texttiming[L]{H} \\
% \texttt{L} & Low & \texttiming{L} & \texttiming{l} & \texttiming[H]{L} \\
% \texttt{Z} & High Impedance & \texttiming{Z} & \texttiming{z} & \texttiming[L]{Z} \\
% \texttt{X} & Undefined / Don't Care & \texttiming{X} & \texttiming{x} & \texttiming[L]{X} \\
% \texttt{D} & Data / Double & \texttiming{D} & \texttiming{d} & \texttiming[L]{D{A}D} \\
% \texttt{U} & Unknown Data & \texttiming{U} & \texttiming{u} & \texttiming[D]{U} \\
% \texttt{T} & Toggle & \texttiming{L} or \texttiming{H} & \texttiming{l} or 
% \texttiming{h} & \texttiming{TTTT} \\
% \texttt{C} & Clock (no slope) & \texttiming{L} or \texttiming{H} & 
% \texttiming{l} or \texttiming{h} & \texttiming{CCCC} \\
% \texttt{M} & Metastable Condition & \texttiming{M} & \texttiming{m} & \texttiming[H]{Ml} \\
%   \midrule
% \texttt{G} & Glitch (zero width) & \texttiming{G} & \texttiming{g} & \texttiming{HGH} \\
% \texttt{S} & Space (nothing) & \texttiming{S} & \texttiming{s} & \texttiming{HSL} \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \iffalse
% \subsection{Similar Packages}
% There a some packages which target the same application like the package 
% presented by this document.
%
% \begin{description}
%   \itempkg{ifsym} This package (using the |electronic| option) provides a 
%   special font which contains graphical representation of the logical levels 
%   high and low at the corresponding letter `|H|' and `|L|'.  The lower case 
%   versions have only half the width of the uppercase ones. Also a transition 
%   can be added using the `\verb+|+' character which will (sometimes) be added 
%   automatically between |HL| and |LH|.
%   The diagrams are created using the command |\textifsym|\marg{characters}, 
%   e.g.\ \verb+\textifsym{H|L|h|l|H|L}+ results in
%   \DeleteShortVerb{\|} `\textifsym{H|L|h|l|H|L}'.
%   \MakeShortVerb{\|}
%
%   There is no support for transition slopes and no support for new 
%   user-defined logical levels.
%
%   \itempkg[(CTAN)]{timing} This package also provides a font for the logical 
%   levels but supports transition slopes and larger timing diagrams.  This 
%   package seems not been updated for a while.
%
%   \itempkgnoctan[(TikZ Example Page)]{timing}%
%   {http://www.texample.net/tikz/examples/timing-diagram/} This package is 
%   accidentally also called `|timing.sty|' and is not published on CTAN but on 
%   the TikZ example website.  It is a small package which is meant as an 
%   example for the graphics package \texttt{tikz} which is used to draw the 
%   diagram.  The logical levels must be provided using macros like 
%   `|\bit|\marg{0 or 1}\marg{length}'.
% \end{description}
% \fi
%
% \section{Usage}
%
% \begin{table}
% \let\texttimingbefore\texttiminggrid
% \sffamily
% \caption{Overview over all transitions.}\label{tab:full}
%  \makebox[\textwidth][c]{\tikztimingfullexampletable}
% \end{table}
%
% \begin{table}
% \let\texttimingbefore\texttiminggrid
% \let\normalfont\sffamily
% \sffamily\centering
% \caption{Modifiers for Timing Characters}\label{tab:modifiers}
% \makebox[\textwidth][c]{%
% \begin{tabularx}{1.25\textwidth}{>{\ttfamily}l>{\raggedright}X>{\ttfamily}ll}
%   \toprule
%   \normalfont
%   Modifier Syntax  & Description & \normalfont Example & Example \\
%                    &             & \normalfont Usage    & Result  \\\midrule
% D\{\}D & Produces transition between two data values. & D\{\}D & 
% \texttiming{D{}D} \\
% D\{\meta{Text}\} & Adds text material into a data signal using a node.  & 
% D\{A\}D\{B\} & \texttiming{D{A}D{B}} \\
% D\{[\meta{\scriptsize 
% \raisebox{-1ex}{\shortstack{TikZ\\Settings}}}]\meta{Text}\} & Adds text 
% material into a data signal using the given settings.  & D\{[blue]A\} & 
% \texttiming{D{[blue]A}} \\
% \meta{\small integer}\{\meta{\small characters}\} &  Repeats the given 
% characters \texttt{\meta{int}} times.  & 5\{hl\} & \texttiming{5{hl}}\\
% \meta{\small number}\meta{\small character} & Sets width of next signal to 
% given number.  Half of it if character is in lower case. & 2.6H5.2l & 
% \texttiming{2.6H5.2l}\\
% \meta{\small number}B & Su\underline{b}tracts the given number from the width 
% of the next character. & H .5B L & \texttiming{H.5BL}\\
% N\oarg{\tiny Settings}\parg{\tiny Name}\marg{\tiny Content} & Adds node at 
% current position.  All three arguments are optional.  & H N(a1) L & 
% \texttiming{H N(a1) L}\\
%   \midrule
% {}[\meta{TikZ Settings}]  & Executes given TikZ settings. & H[blue]LH & 
% \texttiming{H[blue]LH} \\
% ;  & Renews the internal drawing path which ends the scope of all options 
% given by \texttt{[\,]}. & H;[blue]L;H & \texttiming{H;[blue]L;H} \\
% ,  & Same as `\texttt{;}', but timing specific options (atm.: slopes and line 
% width) are restored for the new path. & \small H,[lw=1pt]L;H & 
% \texttiming{H,[line width=1pt]L;H} \\
% !\{\meta{code}\}  & Places given code into the internal \envv{tikzpicture}.
%& \multicolumn{2}{l}{\small See Example~\ref{exa:adv} on
% page~\pageref{exa:adv}.} \\
% \bottomrule
% \end{tabularx}}
% \end{table}
%
% \subsection{Macro for use in Text Mode}
% \vspace{-\bigskipamount}%
% \DescribeMacro{texttiming}{\oarg{initial~character/TikZ 
% Settings}\marg{characters}}
% This macro places a single timing diagram line into the current text. The 
% signals have the same height as a uppercase letter (like `X') of the current 
% font, \ie they scale with the font size.
% The macro argument must contain only valid logic characters and modifiers 
% which define the logical levels of the diagram line.
%
% An initial character can be given as an optional argument. No logic level will 
% be drawn for this character. Instead it will be used to define the initial 
% position of the signal so that the diagram line will start with a transition 
% from the initial to the first character. However, if the optional argument 
% holds more than a single character it is taken as TikZ settings for the 
% diagram. The initial character can then be given using the key 
% `|timing/initchar=|\meta{char}'.
%
% \par\medskip\noindent
% \begin{minipage}{\textwidth}\noindent
% \textit{Examples:}\\*[\smallskipamount]\hspace*{\parindent}%
% \begin{minipage}{\textwidth-4\parindent}
% \small |\texttiming{HLZDZLH}|^^A
% \phantom{\texttt{[L]}} gives `\texttiming{HLZDZLH}', with grid: 
% `{\let\texttimingbefore\texttiminggrid\texttiming{HLZDZLH}}'.\\
% |\texttiming[L]{HLZDZLH}| ^^A
% gives `\texttiming[L]{HLZDZLH}', with grid: 
% `{\let\texttimingbefore\texttiminggrid\texttiming[L]{HLZDZLH}}'.\\
% |\texttiming[green]{HLZDZLH}| ^^A
% gives `\texttiming[green]{HLZDZLH}'\\
% |\texttiming[green,timing/initchar=L]{HLZDZLH}| ^^A
% gives `\texttiming[green,timing/initchar=L]{HLZDZLH}'
% \end{minipage}
% \end{minipage}
%
% \DescribeMacro{texttimingbefore}{\hspace{15.5em}(\emph{defaults to}: 
% \meta{empty})}
% \DescribeMacro*{texttimingafter}{\hspace{16em}(\emph{defaults to}: 
% \meta{empty})}
% This two macros are executed before and after every timing diagram line 
% created by \cs{texttiming} macro inside the same \envv{tikzpicture} 
% environment and can be used to add drawing macros. The argument of the 
% \cs{texttiming} macro is already processed before any of these macros are 
% expanded, therefore this macros can access the width of the diagram.
%
% Example: |\let\texttimingbefore\texttiminggrid| adds a grid into the 
% background of the \cs{texttiming} diagram. A more \LaTeX-stylish way to do 
% this is |\renewcommand*{\textttimingbefore}{\texttiminggrid}|.
%
% \DescribeMacro{texttiminggrid}{}
% This macro should only be used inside \cs{texttimingbefore} or 
% \cs{texttimingafter} and draws a grid of the full size of the
% \cs{texttiming} diagram.
%
% \newpage
% \subsection{Macro for use inside TikZ-Pictures}
%
% \DescribeMacro{timing}{\oarg{TikZ Settings}\ ^^A
% at \parg{TikZ Coordinate}\ \{\oarg{initial character}\meta{characters}\};}
% This macro does the same as \cs{texttiming} but is designed to be used inside 
% a \envv{tikzpicture} environment and only there. Like normal TikZ macros 
% (\css{path}, \css{drawn}, \css{node}) it allows an optional argument with TikZ 
% settings and an optional TikZ-coordinate.  However, a own argument parser, not 
% the one used by TikZ, is used to detect and read these optional arguments.  
% Therefore the order of the arguments is mandatory and might not be reversed.  
% This small limitation might be overcome in future versions of this package.
%
% Please note that the optional initial character may be given \emph{inside} and 
% at the very start of the mandatory argument, not before it. This is necessary 
% because of several technical reasons.
%
% Example: |\tikz \timing [green] at (1,2) {HLZDZLH};|\phantom{\texttt{[L]}} 
% gives `\tikz \timing [green] at (1,2) {HLZDZLH};'.
% 
% Example: |\tikz \timing [green] at (1,2) {[L]HLZDZLH};| gives `\tikz \timing 
% [green] at (1,2) {[L]HLZDZLH};'.
% 
% \subsubsection*{Timing Shape Anchors}
% Every timing diagram line produced by \cs{timing}, which includes the rows in 
% \env{tikztimingtable}, is also a PGF shape (node) with several anchors. These 
% are shown in Figure~\ref{fig:shape}.
% The shape is very similar to the standard |rectangle| shape but does not 
% provide a |text| anchor. In addition to the standard points of the compass 
% anchors of TikZ the three logic levels |low|, |mid| and |high| can be used in 
% combination with |start|, |mid| and |end|.  An extra |origin| anchor is 
% located at the lower left, also called |south west| corner where the diagram 
% originates.  The two anchors called |start| and |end| are provided to mark the 
% start and end of the timing signal.  There are either located at the low, 
% middle or high logic level dependent on the used first (or initial) and last 
% timing character.
% 
% In order to use the timing node it has to be named which can be done using the 
% `\texttt{name=\meta{name}}' option inside the optional argument. The rows of a 
% \env{tikztimingtable} are automatically named as `|row|\meta{row number}' 
% where the first row has the number 1.
%
% ^^AFurther details how to use a shape inside a TikZ or PGF picture can be 
% ^^Afound in the PGF manual Section~15 and~59, respectively.
%
% \begin{figure}
% \centering
% \begin{tikzpicture}[timing,y=1.5cm,x=1.5cm,timing/slope=0]
%   \timing [y=1.5cm,x=1.5cm,gray,thick] at (0,0) {HLHLHL};
%   \node[name=s,shape=tikztiming@shape,anchor=origin] at (0,0) {};
%   \foreach \anchor/\placement in
%     {north west/above left, north/above, north east/above right,
%     west/left, center/right, east/right,
%     mid west/right, mid/left, mid east/left,
%     base west/left, base/left, base east/above right,
%     south west/below left, south/below, south east/below right,
%     low start/below right, mid start/below right, high start/above right,
%     low mid/above right, high mid/right,
%     low end/below left, mid end/below left, high end/above left,
%     start/left, end/right, origin/right}
%   \draw[shift=(s.\anchor)] plot[mark=x] coordinates{(0,0)}
%     node[\placement] {\tiny\texttt{(s.\anchor)}};
% \end{tikzpicture}
% \caption[Timing Shape Anchors]{Timing Shape Anchors. The \texttt{start} and 
% \texttt{end} anchors mark the start and end of the timing 
% signal.}\label{fig:shape}
% \end{figure}
%
% ^^A\newpage
% \subsection{Table for Timing Diagrams}
% \DescribeEnv{tikztimingtable}{\oarg{TikZ settings for whole 
% table}\\\meta{Signal Name}\ \ \&\ \ \oarg{\small Init.~Char./TikZ Settings for 
% Row}\ \meta{Characters} \textbackslash\textbackslash\\\dots\\
% \hspace*{-1em}\cs{extracode}\ \% Optional\\\meta{additional code}}
% This environment can be used to typeset multi-line timing diagrams.  The 
% syntax is like the one for a \envv{tabular} environment with two columns.  The 
% first column is for the signal name and the second one are the logic 
% characters which would be placed inside the argument of a \cs{texttiming} or 
% \cs{timing} macro.
% If the second column starts with an optional argument it is either taken as 
% initial character if it holds only a single character or as row wide settings 
% otherwise.
% The whole table will be drawn inside a \envv{tikzpicture} environment using 
% multiple \cs{timing} and \cs{node} macros for the timing signals and their 
% names, respectively.  Additional \pkg{tikz} drawing code can be insert at the 
% end of the table using \cs{extracode}.
%
% \DescribeMacro{extracode}{}
% This macro is only defined inside a \env{tikztimingtable} environment and can 
% only be used after the last table line (\ie after a |\\|). If used all code 
% between it and the |\end{tikztimingtable}| will be placed inside the same 
% \envv{tikzpicture}. This allows to add some drawing lines or a grid to the 
% picture. It is also possible to draw something behind the timing diagram by 
% using the PGF background layer:
% |\begin{pgfonlayer}{background}|\ldots|\end{pgfonlayer}|.
%
% \subsubsection{Macros for \cs{extracode} Section}
% The following macros are only defined inside a \env{tikztimingtable} after the 
% macro \cs{extracode}. They are useful for drawing additional material.
%
%
% \DescribeMacro{tablegrid}{\oarg{TikZ Settings}}
% \DescribeMacro*{fulltablegrid}{\oarg{TikZ Settings}}
% After \css{extracode} this macros draw a grid in the background of the table.
% The first one draws a separate grid for each row and the second one a big grid 
% over all rows.
%
% \DescribeMacro{rowdist}{}
% \DescribeMacro*{coldist}{}
% This macros return the row and column distance.  There are useful for drawing 
% additional material relative to the rows and columns.  This values can be set 
% (\eg in the optional argument of the table) using the \texttt{timing/rowdist} 
% and \texttt{timing/coldist} settings which are explained in 
% Section~\ref{sec:styles}.
%
% \DescribeMacro{nrows}{}
% Returns the number of rows in the current table. Useful for use in 
% \cs{horlines}.
%
% \DescribeMacro{twidth}{}
% Returns the width (as multiple of the `period width') of the longest timing 
% diagram line in the table.\\Example: If the longest line would be
% `|H 2.3L z|' than \cs{twidth} would be $1+2.3+0.5=3.8$.
%
% \DescribeMacro{horlines}{\oarg{TikZ Settings}\marg{list}}
% Draws horizontal lines, optionally with the given \meta{Settings}, at the base 
% line of the rows given by \meta{list}. The PGF macro 
% \css{foreach}\footnote{See the \texttt{pgf} manual for more details.} is 
% internally used so the list can include not only row numbers as integer but 
% also fractional numbers and the `|...|' operator to auto-increment the 
% numbers. Please note that all numbers in the list are multiplied by 
% \cs{rowdist}.
% If the list is empty the default `|1,2,...,\nrows|' is used which draws lines 
% for all rows.
%
% \DescribeMacro{vertlines}{\oarg{TikZ Settings}\marg{list}}
% Like \cs{horlines} but draws vertical lines and the listed numbers a relative 
% to the basic width.
% If the list is empty the default `|0,1,...,\twidth|' is used which draws lines 
% after every period width.
%
% \DescribeMacro{tablerules}{\oarg{TikZ Settings}}
% This macro adds top and bottom rules to the table in the same (or at least 
% very similar) way as the \texttt{booktabs} package is doing it for normal 
% \texttt{tabular}s. The current bounding box is used to calculate the needed 
% rule length, which makes this macro position dependent if further code is 
% changing the bounding box.
%
% \subsubsection*{Positions \& Scalings inside the Table}
% The first row starts at $y=0$ and the next rows are each
% |-1*\rowdist| lower than the previous one.
% ^^A The very last one can be accessed by the tikz coordinate `\texttt{(last
% ^^A row)}'.
% The vertical unit is 1 \textsf{signal height} and the default row distance is 
% `2' (=$2\times$\textsf{signal height}).  This means that a normal table with 
% three rows goes from $y=+1$ (base line at 0 + 1 \textsf{signal height}) to 
% $y=-4$ (first row:~+0, second row:~-2, third row:~-4).  This are relative to 
% the middle of the drawn lines, \ie the bounding box is 
% $2\times\frac{\text{\textsf{line width}}}{2}=1\cdot $\textsf{line width} 
% higher.
%
% The timing column starts at $x=0$ and goes into the positive range while 
% scaled using the period width. Example: |HHHh| has a width of 3.5.
%
% The label column starts at $x=-$|\coldist| and the text is right align with 
% the right border at this position.
%
% \subsection{Meta-Characters}
% It is possible to define recurring groups of characters and modifiers as so 
% called meta-characters. These characters are than expanded to the group 
% whenever they appear inside the character list. Please note that like for 
% groups a numeric factor before such a meta-character is taken as a repetition 
% factor not as a width. The meta-character is case sensitive and the other case 
% is not affected by the definition, \ie the lower- and uppercase versions of 
% one character can have complete different meanings. It is possible to redefine 
% normal characters (only one or both cases) as meta-characters, which 
% suppresses its normal meaning. Using the meta-character in its own definition 
% group causes a infinite loop which will lead to an \TeX\ error.
% 
% \DescribeMacro{tikztimingmetachar}{\marg{Meta-Character}\marg{Character 
% Group}}
% This macro defines the given \meta{meta-character} to be identical to the 
% given \meta{character group}. Alternatively this can also be done using the 
% TikZ style `|timing/metachar=|\marg{Meta-Character}\marg{Character~Group}'.
%
% An empty group deletes the meta-character, which  might be necessary in cases 
% when normal characters are temporary redefined as meta-characters. However, if 
% the group only contains spaces the meta-character is practically ignored.
%
% \bigskip
% \noindent
% \textit{Examples:}\\[\medskipamount]
% |\tikztimingmetachar{Y}{2D 0.5U 2D{}}  \texttiming{ZZ Y Z 3Y ZZ}|\\
% gives:\\
% {\tikztimingmetachar{Y}{2D 0.5U 2D{}}  \texttiming{ZZ Y Z 3Y ZZ}}
% \\[\bigskipamount]
% |\tikztimingmetachar{Y}{2D{Text}}  \tikztimingmetachar{y}{1D{\tiny Text}}|
% |\texttiming{ZZ Y Z 3y ZZ}|\\
% gives:\\
% {\tikztimingmetachar{Y}{2D{Text}}  \tikztimingmetachar{y}{1D{\tiny Text}}
% \texttiming{ZZ Y Z 3y ZZ}}
% \\[\bigskipamount]
% |\newcounter{mycount}|\\
% |\tikztimingmetachar{H}{2D{\stepcounter{mycount}\arabic{mycount}}}|\\
% |\tikztimingmetachar{R}{[/utils/exec=\setcounter{mycount}{0}]}|\\
% |\texttiming{ 5H R 3H R 10H }|\\
% gives:\\
% {\newcounter{mycount}%
% \tikztimingmetachar{H}{2D{\stepcounter{mycount}\arabic{mycount}}}%
% \tikztimingmetachar{R}{[/utils/exec=\setcounter{mycount}{0}]}%
% \texttiming{ 5H R 3H R 10H }}
% \\[\bigskipamount]
% Redefining the glitch `|G|' character:\\
% |\tikztimingmetachar{G}{.1T.1T .2B} \tikztimingmetachar{g}{.1T.1T}|\\
% |\texttiming{ 10{H G L G} H } % With correction of width `.2B'|\\
% |\texttiming{ 10{H g L g} H } % Without correction|\\
% |\texttiming{ 10{H   L  } H } % For comparison|\\
% gives:\\
% {\let\texttimingbefore\texttiminggrid
% \tikztimingmetachar{G}{.1T.1T .2B} \tikztimingmetachar{g}{.1T.1T}%
% \texttiming{ 10{H G L G} H }\\
% \texttiming{ 10{H g L g} H }\\
% \texttiming{ 10{H   L  } H }}
%
% \clearpage
% \section{Styles}\label{sec:styles}
% The generated logic signals are drawn using the style mechanism provided by 
% \pkg{tikz}. This styles are defined and can be redefined using 
% \css{tikzset}|{|\meta{style name}|/.style=|\meta{value}|,}|.  They can also be 
% used in all places where \meta{TikZ Settings} is mentioned.  Please note that 
% path/draw specific settings might not survive the transition to characters 
% which have there own color, because these start a new drawing path.  For a 
% more detailed explanation why this is necessary see the \pkg{tikz} manual.  
% However, timing specific settings are saved and restored between internal 
% paths.
%
% The package follows the directory structures approach used by TikZ/PGF and 
% places all styles and other settings under the ``subdirectory'' `|timing|' in 
% the main ``directory'' `tikz', which is the default when \css{tikzset} is 
% used.\\
% ^^AExample: The slope of the transitions can be changed using the key 
% ^^A`|timing/slope|', which can also written in the absolute form 
% ^^A`|/tikz/timing/slope|'.
%
% ^^AThe Table~\ref{tab:styles} lists all styles defined by this package.
% {%
% \begin{table}[b]
%   \centering
%   \caption{TikZ Styles and Settings provided and used by this Package.}
%   \label{tab:styles}
%   \def\en{\,\textsf{--}\,}
%   \makebox[\textwidth][c]{^^A
%   \begin{tabularx}{1.15\textwidth}{>{\ttfamily}l>{\raggedright\arraybackslash}X}
%     \toprule
%     \normalfont Style/Setting & Description \\
%     \midrule
%     timing      & Base settings like signal height \& period width.\\
%     timing/intext & Used for \cs{texttiming}. Depends on |timing|.\\
%     timing/picture & Usable for own \texttt{tikzpictures} to set timing 
%     settings.\\
%     timing/grid   & Used for grids. Depends on |help lines| and |timing|.  \\
%     timing/table & Used for \env{tikztimingtable}. Depends on |timing|.\\
%     timing/table/grid & Used for table grid. Depends on |timing/grid|.\\
%     timing/table/lines & Used for \cs{horlines} and \cs{vertlines}. \\
%     timing/table/rules & Used for \cs{tablerules}. \\
%     timing/inline node & Used for nodes created by the |N| character.  
%     Defaults to \texttt{coordinate}.\\
%     \midrule
%     timing/\meta{lowercase char} & Style for character \meta{char}. Not used 
%     for `|H|' and `|L|'. \\
%     timing/\meta{lc char}/background & Background style for characters `|D|' 
%     and `|U|'. \\
%     timing/\meta{lc char}/text & Text style for character \meta{char}.  Only 
%     defined for `|D|'. \\
%     \midrule
%     timing/initchar=\meta{char} & Sets initial character. Only valid as first  
%     optional argument in table rows or \cs{texttiming}.\\
%     timing/metachar=\meta{C}\meta{G} & Sets meta-character \meta{C} to 
%     character group \meta{G}.\\
%     timing/slope=\meta{0.0\en1.0} & Sets slope for logic transitions.  
%     \newline This also sets |dslope=2*slope|, |zslope=slope/2|.\\
%     timing/lslope=\meta{0.0\en1.0} & Sets slope for logic transitions only.  
%     Default: 0.1\\
%     timing/dslope=\meta{0.0\en1.0} & Sets slope for data transitions.  
%     Default: 0.2\\
%     timing/zslope=\meta{0.0\en1.0} & Sets slope for Z transitions. Default: 
%     0.05\\
%     timing/rowdist=\meta{distance} & Sets (baseline) distance between rows in 
%     a tikztimingtable. Default: 2 (=$2\times$signal height)\\
%     timing/coldist=\meta{distance} & Sets distance between columns in a 
%     tikztimingtable. Default: 1 (=$1\times$period width)\\
%     \bottomrule
%   \end{tabularx}
%   }
%   ^^A\\[\smallskipamount]
%   ^^A\emph{Note:} As a convention all style names are completely in lowercase.
% \end{table}}
%
% \clearpage
% \section{Examples}
% This section shows some examples by putting either the full source code or 
% only the needed characters beside the graphical result. Please note that the 
% displayed syntax is the one of \cs{timing} where the initial character is 
% declared as optional argument (\oarg{char}) \emph{inside}/\emph{together} with 
% the logic characters. The syntax of \cs{textttiming} is identical except the 
% initial character is given as a normal optional argument before the characters 
% argument.
% All examples except Example~\ref{exa:adv} are attached in compilable form
% to this PDF.
% ^^A\\[\smallskipamount]
% ^^A\emph{Example notation example:} `|[c]cccc|' means either 
% ^^A|\timing{[c]cccc};| or |\texttiming[c]{cccc}|.
%

% \begin{exampletable}
% \centering
% \pgfmathsetbasenumberlength{2}
% \newcounter{hexcount}
% \addtocounter{hexcount}{+8}%
% \newcommand{\hexcountmacro}{%
%   \pgfmathdectoBase\thehexcount{\value{hexcount}}{16}%
%   \hbox{\thehexcount}%
%   \addtocounter{hexcount}{+1}%
% }
% \caption{Initial Characters, Modifiers, TikZ Settings}\label{exa:adv}
% \def\somemacro{}%
% \def\code{}%
% \makebox[\textwidth][c]{%
% \begin{tikztimingexampletable}
%   HLZXDUTC \\
%   cccc \\
%   tttt \\
%   [c]cccc \\
%   4{c} \\
%   4c4c \\
%   4{1.8c} \\
%   [d] 4{5D{Text}} 0.2D \\
%   3.4H 0.6L \\
%   DDDUUUDDD \\
%   DDD{}DUUDD \\
%   8{2D{\hexcountmacro}} \\
%   3{2{0.25X 2.5D .25Z}} \\
%   DDD{} 3{0.2D{}} DDD \\
%   DDD{} 3{0.2D{}} 0.4D{} 0.6D{} DDD \\
%   HHHLLH SSSS HLLHHL \\
%   HHGHHGGHHLLGLLGH \\
%   ZZ G ZZ G XX G X \\
%   LLL 2{0.1H 0.1L} 0.6H HH \\
%   LLL [timing/slope=0.05] 4{.05H .05L} 0.6H HH\\
%   LLL 0.4U 0.6H HH \\
%   [L][timing/slope=1.0] HL HL HL HL HL \\
%   LLLLL !{-- +(.5,.5) -- ++(1,0)} HHHHHH \\
%   LLLLL [/utils/exec={\somemacro\code}] HHHHHH \\
%   LL [green] HH [brown] XX LL ZZ [orange] HH \\
%   [][line width=1pt] HLXZDU  [line width=0.1pt] HLXZDU \\
%   [][line width=1pt] HLXZDU ;[line width=0.1pt] HLXZDU \\
% \end{tikztimingexampletable}%
% }
% \\\scriptsize
% \emph{Note:} Optional argument must be placed before macro argument if 
% \cs{texttiming} is used.
% 
% \end{exampletable}
%
% \begin{example}
% \centering
% \begin{examplecode}
%   \begin{tikztimingtable}
%     <<Name>> & hLLLLh     \\
%     Clock    & 10{c}      \\
%     Signal   & z4D{Text}z \\
%   \end{tikztimingtable}
% \end{examplecode}
% \caption{\env{tikztimingtable} without \cs{extracode}.}
% \end{example}
%
% \begin{example}
% \centering
% \begin{examplecode}
%   \begin{tikztimingtable}
%     <<Name>> & hLLLLh     \\
%     Clock    & 10{c}      \\
%     Signal   & z4D{Text}z \\
%    \extracode
%     \draw (0,0) circle (0.2pt); % Origin
%     \begin{pgfonlayer}{background}
%       \vertlines[help lines]{0.5,4.5}
%     \end{pgfonlayer}
%   \end{tikztimingtable}
% \end{examplecode}
% \caption{\env{tikztimingtable} with \cs{extracode}.}
% \end{example}
%
% \begin{example}
% \centering
% \begin{examplecode}
%   \begin{tikzpicture}[x=4cm,y=4cm]
%     \draw (0,0) rectangle (1,1);
%     \draw (0.2,0.7) circle (10pt);
%     \begin{scope}[green]
%       \draw (0.1,0.1) -- +(0.8,0.2);
%       \timing at (0.3,0.4) {hlzhhlhhl};
%     \end{scope}
%     \timing [rotate=-30]
%         at (0.4,0.7) {HLZHHLHHL};
%   \end{tikzpicture}
% \end{examplecode}
% \caption{\cs{timing} inside general \envv{tikzpicture}.}
% \end{example}
%
% \begin{example}
% \centering
% \begin{examplecode}
%   \Huge
%   \begin{tikzpicture}[timing,thick,
%     timing/inline node/.style={coordinate,
%     shift={(0.05,-.5)}}]
%     \timing at (0,2) {hH N(A) LHLHL};
%     \timing at (0,0) {HLH N(B) LHLl};
%     \draw [orange,semithick]
%       (A) ellipse (.2 and .6) +(0,-0.6) coordinate (Ax)
%       (B) ellipse (.2 and .6) +(0,+0.6) coordinate (Bx);
%     \draw [orange,semithick,->]
%       (Ax) parabola[bend pos=0.5] (Bx);
%   \end{tikzpicture}
% \end{examplecode}
% \caption{Using In-Line Nodes to draw Relationships.}
% \end{example}
%
% \begin{example}
% \centering
% \lstset{basicstyle=\footnotesize\ttfamily}
% \begin{examplecode}
%   \def\degr{${}^\circ$}
%   \begin{tikztimingtable}
%     Clock 128\,MHz 0\degr    & H 2C N(A1) 8{2C} N(A5) 3{2C} G\\
%     Clock 128\,MHz 90\degr   & [C] 2{2C} N(A2) 8{2C} N(A6) 2{2C} C\\
%     Clock 128\,MHz 180\degr  & C 2{2C} N(A3) 8{2C} N(A7) 2{2C} G\\
%     Clock 128\,MHz 270\degr  & 3{2C} N(A4) 8{2C} N(A8) 2C C\\
%     Coarse Pulse             & 3L 16H 6L \\
%     Coarse Pulse - Delayed 1 & 4L N(B2) 16H N(B6) 5L \\
%     Coarse Pulse - Delayed 2 & 5L N(B3) 16H N(B7) 4L \\
%     Coarse Pulse - Delayed 3 & 6L 16H 3L \\
%     \\
%     Final Pulse Set          & 3L 16H N(B5) 6L \\
%     Final Pulse $\overline{\mbox{Reset}}$ & 6L N(B4) 16H 3L \\
%     Final Pulse              & 3L N(B1) 19H N(B8) 3L \\
%   \extracode
%     \tablerules
%     \begin{pgfonlayer}{background}
%       \foreach \n in {1,...,8}
%         \draw [help lines] (A\n) -- (B\n);
%     \end{pgfonlayer}
%   \end{tikztimingtable}
% \end{examplecode}
% \caption{Using In-Line Nodes to draw Marker Lines.}
% \end{example}
%
% \begin{example}
% \centering
% \lstset{basicstyle=\ttfamily\small}
% \def\texta{}\def\textb{}^^A
% \let\insertoriginalimageforcomparisionifpresent\relax
% \ifpdf
%   \IfFileExists{SR_FF_timing_diagram.png}{^^A
%   \def\insertoriginalimageforcomparisionifpresent{^^A
%     \hspace{0.2\textwidth}\relax\includegraphics[width=28ex,trim=0 10pt 0 
%     0,clip]{SR_FF_timing_diagram.png}^^A
%   }^^A
%   \def\texta{ (left)}\def\textb{ (right)}^^A
%   }{}^^A
%  \def\exampleextraheader{%
%    \string\let
%    \string\insertoriginalimageforcomparisionifpresent\string\relax
%  }%
% \fi
% \begin{examplecode}
%   \definecolor{bgblue}{rgb}{0.41961,0.80784,0.80784}
%   \definecolor{bgred}{rgb}{1,0.61569,0.61569}
%   \definecolor{fgblue}{rgb}{0,0,0.6}
%   \definecolor{fgred}{rgb}{0.6,0,0}
%   \begin{tikztimingtable}[timing/slope=0,
%     timing/coldist=2pt,xscale=2,yscale=1.1,semithick]
%     \scriptsize clock & 7{C}\\
%     S & .75L h 2.25L H LLl [fgblue]\\
%     R & 1.8L .8H 2.2L 1.4H 0.8L [fgblue]\\
%     Q & L .8H 1.7L 1.5H LL\\
%     $\overline{\mbox{Q}}$ & H .8L 1.7H 1.5L HH\\
%     Q & LHHHHLL[fgred]\\
%     $\overline{\mbox{Q}}$ & HLLLLHH[fgred]\\
%   \extracode
%    \begin{pgfonlayer}{background}
%     \shade [right color=bgblue,left color=white]
%        (7,-8.45) rectangle (-2,-4.6);
%     \shade [right color=bgred,left color=white]
%        (7,-12.8) rectangle (-2,-8.6);
%     \begin{scope}[gray,semitransparent,semithick]
%       \horlines{}
%       \foreach \x in {1,...,6}
%         \draw (\x,1) -- (\x,-12.8);
%       % similar: \vertlines{1,...,6}
%     \end{scope}
%     \node [anchor=south east,inner sep=0pt]
%       at (7,-8.45) {\tiny clocked};
%     \node [anchor=south east,inner sep=0pt,fgred]
%       at (7,-12.8) {\tiny positive edge triggered};
%    \end{pgfonlayer}
%   \end{tikztimingtable}
%   \insertoriginalimageforcomparisionifpresent
% \end{examplecode}
% \caption[SR flip-flop timing diagram]{SR flip-flop timing diagram\texta.  
% Redrawn from image\textb\\ {\small
% \url{http://commons.wikimedia.org/wiki/File:SR_FF_timing_diagram.png}
% }}
% \end{example}
%
% \begin{example}
% \centering
% \lstset{basicstyle=\ttfamily\footnotesize}
% \def\texta{}\def\textb{}^^A
% \begin{examplecode}
%   \newcounter{countup}
%   \newcommand*{\countup}{\addtocounter{countup}{1}\thecountup}
%   \newcommand*{\crst}{\setcounter{countup}{0}}
%   \begin{tikztimingtable}
%     [timing/d/background/.style={fill=white},
%      timing/lslope=0.2]
%             CPOL=0 & LL 15{T} LL \\
%             CPOL=1 & HH 15{T} HH \\
%                    & H 17L H     \\
%     \\
%     \crst Cycle \# & U     8{2D{\countup}} 2U    \\
%     \crst     MISO & D{z}  8{2D{\countup}} 2D{z} \\
%     \crst     MOSI & D{z}  8{2D{\countup}} 2D{z} \\
%     \\
%     \crst Cycle \# & UU    8{2D{\countup}}  U    \\
%     \crst     MISO & D{z}U 8{2D{\countup}}  D{z} \\
%     \crst     MOSI & D{z}U 8{2D{\countup}}  D{z} \\
%   \extracode
%     \begin{pgfonlayer}{background}
%       \begin{scope}[semitransparent,semithick]
%         \vertlines[red]{2.1,4.1,...,17.1}
%         \vertlines[blue]{3.1,5.1,...,17.1}
%       \end{scope}
%     \end{pgfonlayer}
%     \begin{scope}
%       [font=\sffamily\Large,shift={(-6em,-0.5)},anchor=east]
%       \node at (  0, 0) {SCK};    \node at (  0,-3 ) {SS};
%       \node at (1ex,-9) {CPHA=0}; \node at (1ex,-17) {CPHA=1};
%     \end{scope}
%   \end{tikztimingtable}%
% \end{examplecode}
% \caption[SPI Interface Timing]{SPI Interface Timing\texta.  Redrawn from 
% image\textb\\ {\small
% \url{http://en.wikipedia.org/wiki/File:SPI_timing_diagram.svg}}}
% \end{example}
%
% \StopEventually{}
% \FloatBarrier
% \clearpage
% \section{Implementation}
% \subsection{Package Header}
%    \begin{macrocode}
%<*package>
\RequirePackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations.pathmorphing}
\ifx\collect@body\@undefined
  \IfFileExists{environ.sty}
    {\RequirePackage{environ}}
    {\RequirePackage{amsmath}}
\fi

\def\tikztimingwidth{0.0}
\newcount\tikztiming@numint
\newcount\tikztiming@numfrac
\def\tikztiming@num{1.0}%
\let\tikztiming@back\empty
\newlength\tikztiming@xunit
\newlength\tikztiming@yunit

\newcounter{tikztiming@nrows}%
\def\tikztiming@rowdist{2}%
\def\tikztiming@coldist{1}%
\def\tikztiminglabel#1{#1}%

\def\tikztiming@prefix{tikztiming@trans@}
%    \end{macrocode}

% \subsection{TikZ Style Settings}
%    \begin{macrocode}
\tikzset{timing/.style={%
    x=1.6ex, y=1.6ex,
    line cap=round, line join=round,
    /utils/exec={\setlength{\tikztiming@xunit}{1.6ex}\setlength{\tikztiming@yunit}{1.6ex}},
  }%
}
\tikzset{%
  timing/.cd,
  initchar/.value required,
  initchar/.code={\ifx\lastchar\empty\uppercase{\def\lastchar{#1}}\fi},
  metachar/.code 2 args={\tikztimingmetachar{#1}{#2}},
  grid/.style={timing,help lines},
  picture/.style={timing,line width=0.15ex},
  intext/.style={timing,line width=0.15ex},
  inline node/.style={shape=coordinate},
  table/.style={timing,line width=0.15ex,font=\sffamily},
  coord/.style={inner sep=0pt,outer sep=0pt},
  save/.style={inner sep=0pt,outer sep=0pt,/utils/exec=\tikztiming@savesettings},
  restore/.style={/utils/exec=\tikztiming@restoresettings},
  name/.style={inner sep=0pt,outer sep=0pt},
  d/text/.style={timing,scale=0.6,font=\sffamily},
  d/background/.style={},
  h/.style={},
  l/.style={},
  d/.style={},
  m/.style={black!40!brown},
  m/decoration/.style={decorate,decoration={zigzag,segment 
  length=.25\tikztiming@xunit,amplitude=.225\tikztiming@yunit}},
  k/.style={black!40!blue,semitransparent},
  u/background/.style={fill=gray},
  u/.style={},
  o/background/.style={},
  o/.style={timing/d,line width=0.10ex,dotted},
  g/.style={},
  z/.style={blue},
  t/.style={},
  c/.style={timing/slope=0.0},
  x/.style={red},
  table/grid/.style={timing/grid},
  table/lines/.style={},
  table/rules/.style={line width=0.08em,line cap=butt},
  slope/.code={%
    \tikztimingsetslope{#1}%
    \tikztimingsetdslope{2*#1}%
    \tikztimingsetzslope{#1/2}%
  },
  lslope/.code={\tikztimingsetslope{#1}},
  dslope/.code={\tikztimingsetdslope{#1}},
  zslope/.code={\tikztimingsetzslope{#1}},
  coldist/.store in=\tikztiming@coldist,
  rowdist/.store in=\tikztiming@rowdist,
}
%    \end{macrocode}
%
% \subsection{Macros}
% \begin{macro}{\texttimingbefore}
% This macro is executed inside the tikzpicture environment of \cs{texttiming} 
% before the timing diagram is drawn.
%    \begin{macrocode}
\def\texttimingbefore{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\texttimingafter}
% This macro is executed inside the tikzpicture environment of \cs{texttiming} 
% after the timing diagram is drawn.
%    \begin{macrocode}
\def\texttimingafter{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\texttiminggrid}
% Draws a background grid with the `timing/grid' setting. Should be used inside 
% \cs{texttimingbefore}.
%    \begin{macrocode}
\def\texttiminggrid{%
  \draw[xstep={\timingwidth/2.},ystep={\timingheight/2.},timing/grid] (0,0) grid 
  (\timingwidth*\tikztimingwidth,\timingheight);
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\texttiming}[2]{Optional initial character}{Timing characters}
%    \begin{macrocode}
\DeclareRobustCommand*\texttiming[2][]{%
  \begingroup
    \tikztiming@init
    \ifx\relax#1\relax\else
      \tikztiming@testoptarg#1\relax\relax%
    \fi
    \def\@tempa{\begin{tikzpicture}[timing/intext,}%]}[
    \expandafter\@tempa\settings]
      \@ifundefined{tikztiming@initcode@\lastchar}%
        {}%
        {\@nameuse{tikztiming@initcode@\lastchar}}%
      \ifx\lastchar\empty\else
      \@ifundefined{\tikztiming@prefix\lastchar @start}%
        {\PackageWarning{tikz-timing}{Start value for timing character '\lastchar' 
        is not defined and will be ignored!}{}{}{}}%
        {\tikztiming@nameaddtostr{\lastchar @start}{}}%
      \fi
      \tikztiming@#2\relax
      %\message{^^J\meaning\tikztiming@str^^J}%
      \path[use as bounding box] (0,0) rectangle 
      (\timingwidth*\tikztimingwidth,\timingheight);%
      \texttimingbefore
      \tikztiming@str;%
      \node [shape=tikztiming@shape,anchor=origin,name=last texttiming] at (0,0) 
      {};
      \texttimingafter
    \end{tikzpicture}%
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testoptarg}
%    \begin{macrocode}
\def\tikztiming@testoptarg#1#2\relax{%
  \ifx\relax#2\relax
    \uppercase{\def\lastchar{#1}}%
  \else
    \def\settings{#1#2}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@init}
%    \begin{macrocode}
\def\tikztiming@init{%
    \let\lastchar\empty%
    \let\currentchar\empty
    \let\settings\empty
    \def\tikztimingwidth{0.0}%
    \setcounter{tikztimingtrans}{-1}%
    \def\tikztiming@str{\draw (0,0) coordinate (timing/start base) }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing}
%    \begin{macrocode}
\def\timing{%
  \@ifnextchar{[}%
    {\timing@}%
    {\timing@[]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing@}[1]{Optional TikZ Settings}
%    \begin{macrocode}
\def\timing@[#1]{%
  \@ifnextchar{a}%
    {\timing@at{#1}}%
    {\PackageWarning{tikz-timing}{The \string\timing\space command awaits now an 
    `at' before the coordinate, like the \string\node\space command is doing.  
    Please update your source code to ensure compatibility with newer 
    versions}{}{}{}%
     \@ifnextchar{+}%
      {\timing@@{#1}}%
      {\@ifnextchar(%)
        {\timing@@{#1}}%
        {\timing@@{#1}++(0,0)}%
      }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing@at}[1]{Optional TikZ Settings}
%    \begin{macrocode}
\def\timing@at#1at#2(#3){%
  \timing@@@{#1}{#2(#3)}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing@@}[3]{Optional TikZ Settings}{Potential `+' or 
% empty}{Coordinate}
%    \begin{macrocode}
\def\timing@@#1#2(#3){%
  \timing@@@{#1}{#2(#3)}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing@@@}[3]{Optional TikZ Settings}{Coordinate}{Timing 
% Characters}
%    \begin{macrocode}
\def\timing@@@#1#2#3{%
  \begingroup
    \tikztiming@init
    \let\tikz@alias=\pgfutil@empty%
    \begin{scope}[shift={#2},timing,#1]%
      \@ifnextchar{[}%
        {\timing@@@init}%
        {\timing@@@init[]}%
      #3\relax
      %\message{^^J\meaning\tikztiming@str^^J}%
      \tikztiming@str;%
      \node [shape=tikztiming@shape,anchor=origin,#1] at (0,0) {};
    \end{scope}%
  \endgroup
  \timing@@@end
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing@@@end}[1]{Token behind \cs{timing} macro.}
%    \begin{macrocode}
\def\timing@@@end#1;{%
  \ifx;#1;\else
    \PackageError{tikz-package}{Can not parse timing path}{}{}{}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timing@@@init}[1]{Initial character.}
%    \begin{macrocode}
\def\timing@@@init[#1]{%
  \ifx\relax#1\relax\else
    \uppercase{\def\lastchar{#1}}%
  \fi
  \@ifundefined{tikztiming@initcode@\lastchar}%
    {}%
    {\@nameuse{tikztiming@initcode@\lastchar}}%
  \ifx\lastchar\empty\else
  \@ifundefined{\tikztiming@prefix\lastchar @start}%
    {\PackageWarning{tikz-timing}{Start value for timing character '\lastchar' 
    is not defined and will be ignored!}{}{}{}}%
    {\tikztiming@nameaddtostr{\lastchar @start}{}}%
  \fi
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\tikztiming@trans@}
% The empty transition gets defined to avoid errors if it is used by the generic 
% code, e.g. if a non-combinable character like `C' is the last one.
%    \begin{macrocode}
\let\tikztiming@trans@\@gobble
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@T}
%    \begin{macrocode}
\def\tikztiming@aftercode@T{%
  \tikztiming@output@flush
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@t}
%    \begin{macrocode}
\def\tikztiming@aftercode@t{%
  \tikztiming@aftercode@T
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@C}
%    \begin{macrocode}
\def\tikztiming@aftercode@C{%
  %\tikztiming@output@flush
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@c}
%    \begin{macrocode}
\def\tikztiming@aftercode@c{%
  \tikztiming@aftercode@C
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@G}
%    \begin{macrocode}
\def\tikztiming@aftercode@G{%
  \let\lastchar\secondlastchar
  \let\tikztimingwidth\lasttikztimingwidth
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@g}
%    \begin{macrocode}
\def\tikztiming@aftercode@g{%
  \let\lastchar\secondlastchar
  \let\tikztimingwidth\lasttikztimingwidth
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@S}
%    \begin{macrocode}
\def\tikztiming@aftercode@S{%
  \let\lastchar\secondlastchar
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@aftercode@s}
%    \begin{macrocode}
\def\tikztiming@aftercode@s{%
  \let\lastchar\secondlastchar
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@beforenextcode@D@edge@}
%    \begin{macrocode}
\def\tikztiming@beforenextcode@D@edge@{%
  \if D\currentchar\else
    \if d\currentchar\else
      \def\lastchar{D}%
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@beforecode@d@edge@}
%    \begin{macrocode}
\def\tikztiming@beforenextcode@d@edge@{%
  \if D\currentchar\else
    \if d\currentchar\else
      \def\lastchar{D}%
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@initcode@D}
%    \begin{macrocode}
\def\tikztiming@initcode@D{%
  \def\lastchar{D@edge@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@initcode@d}
%    \begin{macrocode}
\def\tikztiming@initcode@d{%
  \def\lastchar{d@edge@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@}
% The |\@ifnextchar\bgroup| is a trick to remove following spaces which would 
% break the number test.
%    \begin{macrocode}
\def\tikztiming@{%
  \@ifnextchar\bgroup
    {\tikztiming@testfornum}%
    {\tikztiming@testfornum}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@eaddtostr}[1]{Tokens to add to string.}
%    \begin{macrocode}
\def\tikztiming@eaddtostr#1{%
  \begingroup
    \tikztiming@internaldefs{}%
    \@temptokena\expandafter{\tikztiming@str}%
    \xdef\tikztiming@str{%
      \the\@temptokena
      #1%
    }%
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@addtostr}
%    \begin{macrocode}
\def\tikztiming@addtostr{%
  \g@addto@macro\tikztiming@str
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@output}[2]{Character 1}{Character 2}
%    \begin{macrocode}
\def\tikztiming@output#1#2{%
  \ifx\relax#2\relax
    \tikztiming@nameaddtostr{#1}%
  \else
    \ifcase0%
      \ifx\tikztiming@output@bufchara\empty
        \ifx\tikztiming@output@bufcharb\empty
          1%
        \fi
      \fi\relax
      % not empty
      \edef\tikztiming@output@currentchar{#2}%
      \ifcase0%
      \expandafter\ifx\csname tikztiming@nocombine@#2\endcsname\relax
      \ifx\tikztiming@output@currentchar\tikztiming@output@bufcharb
        1%
      \fi\fi
      \relax
        \tikztiming@output@flush
        \edef\tikztiming@output@bufchara{#1}%
        \edef\tikztiming@output@bufcharb{#2}%
      \or
        \pgfmathparse{\tikztiming@output@bufnum + \tikztiming@num}%
        \let\tikztiming@output@bufnum\pgfmathresult
        \def\tikztiming@num{1.0}%
      \fi
    \else % empty
      \edef\tikztiming@output@bufchara{#1}%
      \edef\tikztiming@output@bufcharb{#2}%
      \let\tikztiming@output@bufnum\tikztiming@num
      \def\tikztiming@num{1.0}%
    \fi
  \fi
}
%    \end{macrocode}
%
% Init buffer macros:
%    \begin{macrocode}
\def\tikztiming@output@bufchara{}%
\def\tikztiming@output@bufcharb{}%
\def\tikztiming@output@bufnum{0}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@output@flush}
%    \begin{macrocode}
\def\tikztiming@output@flush{%
  \begingroup
    \let\tikztiming@num\tikztiming@output@bufnum
    \tikztiming@nameaddtostr{%
      \tikztiming@output@bufchara
      \tikztiming@output@bufcharb
    }%
  \endgroup%
  \gdef\tikztiming@output@bufchara{}%
  \gdef\tikztiming@output@bufcharb{}%
  \global\let\tikztiming@output@bufnum\tikztiming@num
  \gdef\tikztiming@num{1.0}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@nameaddtostr}[1]{Name of macro without prefix
% to add}
%    \begin{macrocode}
\def\tikztiming@nameaddtostr#1{%
  \begingroup
    \edef\@tempa{\tikztiming@num}%
    \expandafter\g@addto@macro
    \expandafter\tikztiming@str
    \expandafter{\csname\tikztiming@prefix#1\expandafter\endcsname
    \expandafter{\@tempa} }%
  \endgroup
  \def\tikztiming@num{1.0}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@nameedef}[3]{Optional character to indicate 
% character case}{Macro name to be defined (without prefix)}{Content of macro}
% Defines internal tikztiming macro with name |\|\meta{prefix}\meta{name (\#2)}.  
% The macro definition (\#3) is expanded while the internal drawing definitions 
% are active.
%    \begin{macrocode}
\newcommand\tikztiming@nameedef[3][A]{%
  \def\@gtempa##1{#3}%
  \expandafter\let\csname\tikztiming@prefix#2@general\endcsname\@gtempa
  \begingroup
    \tikztiming@internaldefs{#1}%
    \xdef\@gtempa##1{\@gtempa{\width}}%
  \endgroup
  \expandafter\let\csname\tikztiming@prefix#2\endcsname\@gtempa
  \let\@gtempa\empty
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@namelet}[2]{Original Characters}{New Characters}
% Only execute |\let| if the original macro is defined or the destination macro 
% is defined and would now set to undefined.
%    \begin{macrocode}
\newcommand\tikztiming@namelet[2]{%
  \ifcase0%
    \@ifundefined{\tikztiming@prefix#2}%
      {\@ifundefined{\tikztiming@prefix#1}%
        {0}{1}%
      }%
      {1}%
    \relax
  \else
    \expandafter\let
    \csname\tikztiming@prefix#1\expandafter\endcsname
    \csname\tikztiming@prefix#2\endcsname
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@@end}
%    \begin{macrocode}
\def\tikztiming@@end{%
  \tikztiming@output@flush
  \global\let\tikztimingwidth\tikztimingwidth
  \tikztiming@addtostr{ coordinate (timing/end)
    let \p1 = (timing/start base), \p2 = (timing/end) in
      coordinate (timing/end base) at (\x2,\y1)
      coordinate (timing/end top)  at (\x2,1+\y1)
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@@}[1]{Next Character}
%    \begin{macrocode}
\def\tikztiming@@#1{%
  \ifx\relax#1\empty
    \expandafter\tikztiming@@end
  \else
    \let\lasttikztimingwidth\tikztimingwidth
    \tikztiming@iflower{#1}%
      {\pgfmathparse{\tikztiming@num/2.0}\let\tikztiming@num\pgfmathresult}%
      {}%
    \ifx\tikztiming@back\empty\else
      \pgfmathparse{\tikztiming@num-\tikztiming@back}%
      \let\tikztiming@num\pgfmathresult
      \let\tikztiming@back\empty
    \fi
    \pgfmathparse{\tikztimingwidth + \tikztiming@num}%
    \let\tikztimingwidth\pgfmathresult
    \def\currentchar{#1}%
    \uppercase{\def\currentcharuc{#1}}%
    \@ifundefined{tikztiming@beforenextcode@\lastchar}%
      {}%
      {\@nameuse{tikztiming@beforenextcode@\lastchar}}%
    \@ifundefined{tikztiming@beforecode@\currentchar}%
      {}%
      {\@nameuse{tikztiming@beforecode@\currentchar}}%
    \@ifundefined{\tikztiming@prefix\lastchar\currentchar}%
      {\@ifundefined{\tikztiming@prefix\lastchar\currentcharuc}%
        {\PackageWarning{tikz-timing}{Timing transition '\lastchar\currentchar' 
        is not defined and will be ignored!}{}{}{}}%
        {\tikztiming@output{\lastchar}{\currentcharuc}}%
      }%
      {\tikztiming@output{\lastchar}{\currentchar}}%
    \let\secondlastchar\lastchar
    \let\lastchar\currentcharuc
    \@ifundefined{tikztiming@aftercode@\currentcharuc}%
      {}%
      {\@nameuse{tikztiming@aftercode@\currentcharuc}}%
    \expandafter
    \tikztiming@testfortext
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testfortext}
%    \begin{macrocode}
\def\tikztiming@testfortext{%
  \@ifnextchar\bgroup
    {\tikztiming@handletext}%
    {\tikztiming@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@handletext}[1]{Text}
%    \begin{macrocode}
\def\tikztiming@handletext#1{%
  \@ifnextchar{[}%
    {\tikztiming@handletext@}%
    {\tikztiming@handletext@[]}%
  #1\relax
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@handletext@}[2]{Optional Settings}{Text}
%    \begin{macrocode}
\def\tikztiming@handletext@[#1]#2\relax{%
  \begingroup
  \expandafter\lowercase\expandafter{%
    \expandafter\def\expandafter\currentcharlc
    \expandafter{\currentchar}%
  }%
  \pgfkeysifdefined{/tikz/timing/\currentcharlc/text/.@cmd}%
  {%
  \tikztiming@output@flush
  \tikztiming@eaddtostr{%
    node (timing@dend) at +(\dslope/2.0,\height/2.0) {}
    node [%]
      shift={($ (timing@dstart)!0.5!(timing@dend) $)},%
      timing/\currentcharlc/text,%
  }%
  \endgroup
  \tikztiming@addtostr{%[
      #1%
      ] {#2}%
  }%
  \def\lastchar{D@edge@}%
  }{%
    \endgroup
    \PackageWarning{tikz-timing}{Ignoring text for character 
    '\currentchar'!}{}{}{}%
  }%
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@defcode}[1]{Code Character}
%    \begin{macrocode}
\def\tikztiming@defcode#1{%
  \@namedef{tikztiming@code@\meaning#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@defcode{,}}
%    \begin{macrocode}
\tikztiming@defcode{,}{%
  \tikztiming@output@flush
  \tikztiming@eaddtostr{%
    \newdraw
  }%
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@defcode{;}}
%    \begin{macrocode}
\tikztiming@defcode{;}{%
  \tikztiming@output@flush
  \tikztiming@eaddtostr{%
    \newdrawns
  }%
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@defcode{N}}
%    \begin{macrocode}
\tikztiming@defcode{N}{%
  \@ifnextchar[%]
    {\tikztiming@addnode@getoptions}%
    {\tikztiming@addnode@getoptions[]}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@addnode}[1]{Options}
%    \begin{macrocode}
\def\tikztiming@addnode@getoptions[#1]{%
  \@ifnextchar(%)
    {\tikztiming@addnode@getname{#1}}%
    {\tikztiming@addnode@getname{#1}()}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@addnode@getname}[2]{Previous read options}{Node 
% name}
%    \begin{macrocode}
\def\tikztiming@addnode@getname#1(#2){%
  \@ifnextchar\bgroup
    {\tikztiming@addnode@{#1}{#2}}%
    {\tikztiming@addnode@{#1}{#2}{}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@addnode@}[3]{Options}{Node name}{Node text}
%    \begin{macrocode}
\def\tikztiming@addnode@#1#2#3{%
  \tikztiming@output@flush
  \begingroup
    \def\@tempa{#2}%
    \ifx\@tempa\empty
      \def\@tempa{ node [timing/inline node,#1] }%
    \else
      \def\@tempa{ node [timing/inline node,#1] (#2) }%
    \fi
    \expandafter\tikztiming@addtostr\expandafter{\@tempa {#3} }%
  \endgroup
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testforcode}
%    \begin{macrocode}
\def\tikztiming@testforcode{%
  \@ifnextchar{!}%
    {\tikztiming@testforcode@}%
    {\@ifundefined{tikztiming@code@\meaning\@let@token}%
      {\tikztiming@@}%
      {\csname tikztiming@code@\meaning\@let@token\expandafter
       \endcsname\@gobble}%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testforcode@}[1]{Character to gobble}
%    \begin{macrocode}
\def\tikztiming@testforcode@#1{%
  \@ifnextchar\bgroup
    {\tikztiming@handlecode}%
    {%
      \PackageWarning{tikz-timing}{Missing braces after '!' character. Ignoring 
      this character}{}{}{}%
      \tikztiming@
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@defcode{B}}
%    \begin{macrocode}
\tikztiming@defcode{B}{%
  \pgfmathparse{\tikztiming@back+\tikztiming@num}%
  \let\tikztiming@back\pgfmathresult
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@handlecode}[1]{Code to add to string}
%    \begin{macrocode}
\def\tikztiming@handlecode#1{%
  \tikztiming@output@flush
  \tikztiming@addtostr{ #1 }%
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@defcode []}[1]{Options to add to string}
%    \begin{macrocode}
\tikztiming@defcode[#1]{%
  \tikztiming@addtostr{ [#1] }%
  \tikztiming@
}
%    \end{macrocode}
% \end{macro}
%

% \begin{macro}{\tikztiming@testfornum}
%    \begin{macrocode}
\def\tikztiming@testfornum{%
  \let\tikztiming@numchars\empty
  \tikztiming@numfrac0\relax
  \afterassignment
  \tikztiming@testfornum@
  \tikztiming@numint0%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testfornumfrac}
%    \begin{macrocode}
\def\tikztiming@testfornumfrac{%
  \afterassignment
  \tikztiming@testfornum@@@
  \tikztiming@numfrac1%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@numloop}
%    \begin{macrocode}
\def\tikztiming@numloop{%
  \ifnum\tikztiming@numint>0%
    \toks@\expandafter{\tikztiming@numchars}%
    \xdef\tikztiming@numchars{%
      \the\toks@
      \the\@temptokena
    }%
    \advance\tikztiming@numint by -1\relax
    \expandafter\tikztiming@numloop
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testfornum@}
%    \begin{macrocode}
\def\tikztiming@testfornum@{%
  \ifnum0<\tikztiming@numint
    \let\tikztiming@next\tikztiming@testfornum@@
  \else
    \def\tikztiming@next{%
      \@ifnextchar{.}%
        {\expandafter\tikztiming@testfornumfrac\@gobble}%
        {%
          \tikztiming@numint1\relax
          \tikztiming@numfrac0\relax
          \def\tikztiming@num{1.0}%
          \if@tikztiming@metachar
            {\def\@tempa{\expandafter\expandafter\expandafter
            \tikztiming@testfornum@@@@
            \expandafter\expandafter\expandafter{%
            \csname tikztiming@metachar@\meaning\@let@token\endcsname}}%
            \expandafter\@tempa\@gobble
            }%
            {\tikztiming@testforcode}%
        }%
    }%
  \fi
  \tikztiming@next
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testfornum@@}
%    \begin{macrocode}
\def\tikztiming@testfornum@@{%
  \@ifnextchar{.}%
    {\expandafter\tikztiming@testfornumfrac\@gobble}%
    {\tikztiming@testfornum@@@}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testfornum@@@}
%    \begin{macrocode}
\def\tikztiming@testfornum@@@{%
  \xdef\tikztiming@num{\the\tikztiming@numint.\expandafter\@gobble\the\tikztiming@numfrac}%
  \@ifnextchar\bgroup
    {%
      \expandafter\tikztiming@numfrac\expandafter0\expandafter
      \@gobble\the\tikztiming@numfrac\relax
      \ifnum0=\tikztiming@numfrac\else
        \pgfmathparse{round(\tikztiming@num)}%
        \PackageWarning{tikz-timing}%
          {Can not repeat group by a non-integer factor!^^J%
           Rounding '\tikztiming@num' to '\pgfmathresult'.}{}{}{}%
        \let\tikztiming@num\pgfmathresult
      \fi
      \tikztiming@testfornum@@@@
    }%
    {%
      \if@tikztiming@metachar
        {\def\@tempa{\expandafter\expandafter\expandafter
        \tikztiming@testfornum@@@@
        \expandafter\expandafter\expandafter{%
        \csname tikztiming@metachar@\meaning\@let@token\endcsname}}%
        \expandafter\@tempa\@gobble
        }%
        {\tikztiming@testforcode}%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimig@metachar}[2]{Macro character}{Substituted 
% Characters}
%    \begin{macrocode}
\def\tikztimingmetachar#1#2{%
  \ifx\relax#2\relax
    \expandafter\let\csname tikztiming@metachar@\meaning#1\endcsname\@undefined
  \else
    \@namedef{tikztiming@metachar@\meaning#1}{#2}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@tikztimig@metachar}[2]{True clause}{False clause}
%    \begin{macrocode}
\def\if@tikztiming@metachar#1#2{%
  \@ifundefined{tikztiming@metachar@\meaning\@let@token}{#2}{#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@testfornum@@@@}[1]{Characters and other tokens to 
% repeat}
%    \begin{macrocode}
\def\tikztiming@testfornum@@@@#1{%
  \begingroup
    \@temptokena{#1}%
    \tikztiming@numloop%
  \endgroup
  \tikztiming@numint1\relax
  \tikztiming@numfrac0\relax
  \expandafter\tikztiming@\tikztiming@numchars
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Table environment}
%    \begin{macrocode}
%\usetikzlibrary{backgrounds}
\newcounter{tikztimingrows}
%    \end{macrocode}
%
% \begin{macro}{\tikztiming@extracode}
%    \begin{macrocode}
\def\tikztiming@extracode{\@gobble{EXTRACODE}}%
%    \end{macrocode}
% \end{macro}

% \begin{environment}{tikztimingtable}[1]{Optional settings}
%    \begin{macrocode}
\newenvironment{tikztimingtable}[1][]{%
  \begingroup
  \setcounter{tikztiming@nrows}{0}%
  \def\tikztiming@maxwidth{0.0}%
  \let\extracode\tikztiming@extracode
  \let\tablegrid\tikztiming@tablegrid
  \let\fulltablegrid\tikztiming@fulltablegrid
  \let\horlines\tikztiming@horlines
  \let\vertlines\tikztiming@vertlines
  \let\tablerules\tikztiming@tablerules
  \def\rowdist{\tikztiming@rowdist}%
  \def\coldist{\tikztiming@coldist}%
  \def\nrows{\the\c@tikztiming@nrows}%
  \def\twidth{\tikztiming@maxwidth}%
  \tikzpicture[timing/table,#1]%
    \coordinate (last row)  at (0,\rowdist);
    \coordinate (label pos) at (-1*\coldist,0);
    \coordinate (timing/table/top left) at (0,1);
    \coordinate (timing/table/bottom right) at (0,0);
  \collect@body\tikztiming@table
}{%
}
%    \end{macrocode}
% \end{environment}

% \begin{macro}{\tikztiming@table}[1]{Table content}
%    \begin{macrocode}
\def\tikztiming@table#1{%
  \tikztimingtable@row#1\endtikztimingtable@
  \endtikzpicture
  \endgroup
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\endtikztimingtable@}
%    \begin{macrocode}
\def\endtikztimingtable@{\@gobble{ENDTIKSTIMING}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\tikztimingextracode}[2]{Token to gobble}{Extra drawing code}
%    \begin{macrocode}
\long\def\tikztimingextracode#1#2\endtikztimingtable@{%
  \path let
     \p1 = (timing/table/top left),
     \p2 = (timing/table/bottom right)
   in
     coordinate (timing/table/bottom left) at (\x1,\y2)
     coordinate (timing/table/top right) at (\x2,\y1)
     coordinate (timing/table/size) at (\x2-\x1,\y1-\y2)
   ;
  #2%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@emptycell}
% Just used as marker. Needs unique definition.
%    \begin{macrocode}
\def\tikztiming@emptycell{%
  \@gobble{tikztiming@emptycell}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingtable@row}[1]{Row content}
%    \begin{macrocode}
\def\tikztimingtable@row#1\\{%
  \tikztimingtable@row@#1&\tikztiming@emptycell&\\
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingtable@row@}[3]{Cell 1}{Cell 2 or empty}{Potential 
% further cells}
%    \begin{macrocode}
\def\tikztimingtable@row@#1&#2&#3\\{%
  \ifx\\#3\\\else
    \begingroup
      \def\@tempa{\tikztiming@emptycell&}%
      \def\@tempb{#3}%
      \ifx\@tempa\@tempb\else
        \PackageWarning{tikz-timing}{%
          To many columns in tikztimingtable row! Only two are allowed%
        }{}{}{}%
      \fi
    \endgroup
  \fi
  \ifx\tikztiming@emptycell#2%
    \def\next{\tikztimingtable@row@@{#1}{}}%
  \else
    \def\next{\tikztimingtable@row@@{#1}{#2}}%
  \fi
  \next
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingtable@row@@}[2]{Name/Label}{Timing characters}
%    \begin{macrocode}
\def\tikztimingtable@row@@#1#2{%
  \addtocounter{tikztiming@nrows}{1}%
  \path ($ (last row) + (0,-1*\rowdist) $) coordinate (last row);
  \path ($ (last row) + (-1*\coldist,0) $) node [anchor=base east,timing/name]
    {\tikztiminglabel{#1}};
  \@ifnextchar{[}%
    {\tikztiming@tabletiming}%
    {\tikztiming@tabletiming[]}%
  #2\relax
  \path let \p1 = (timing/table/bottom right), \p2 = (timing/end base) in
    coordinate (timing/table/bottom right) at ({max(\x1,\x2)},\y2);
  %
  \pgfmathparse{max(\tikztiming@maxwidth,\tikztimingwidth)}%
  \let\tikztiming@maxwidth\pgfmathresult
  \@ifnextchar\extracode
    {%
      \let\extracode\relax
      \tikztimingextracode
    }%
    {%
      \@ifnextchar\endtikztimingtable@
        {\@gobble}{\tikztimingtable@row}%
    }%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\tikztiming@tabletiming}
%    \begin{macrocode}
\def\tikztiming@tabletiming[#1]#2\relax{%
  \let\lastchar\empty
  \let\settings\empty
  \ifx\relax#1\relax\else
    \tikztiming@testoptarg#1\relax\relax
  \fi
  \edef\@tempa{\noexpand\timing[name=row\the\c@tikztiming@nrows,\settings]
    at (last row)}%
  \expandafter\@tempa\expandafter{\expandafter[\lastchar]#2};
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\tikztiming@fulltablegrid}[1]{Optional settings}
%    \begin{macrocode}
\newcommand*\tikztiming@fulltablegrid[1][]{%
  \begin{pgfonlayer}{background}
    \scope[xstep={\timingwidth/2.},ystep={\timingheight/2.},
    shift={(timing/table/bottom left)},timing/table/grid,#1]
      \draw (0,0) grid
        ($ (timing/table/top right) - (timing/table/bottom left) $);
   \endscope
  \end{pgfonlayer}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@tablegrid}[1]{Optional settings}
%    \begin{macrocode}
\newcommand*\tikztiming@tablegrid[1][]{%
  \begin{pgfonlayer}{background}
    \scope[xstep={\timingwidth/2.},ystep={\timingheight/2.},timing/table/grid,#1]
      \foreach \y in {1,...,\nrows} {%
        \draw {[shift={($ (timing/table/bottom left) + (0,\y*\rowdist) - 
        (0,\rowdist) $)}] let \p1 = (timing/table/bottom right) in (0,0) grid 
        (\x1,1)};
      }%
    \endscope
  \end{pgfonlayer}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@tablerules}[1]{Optional Settings}
%    \begin{macrocode}
\newcommand*\tikztiming@tablerules[1][]{%
    \draw [timing/table/rules,#1] let
      \p1 = (current bounding box.north west),
      \p2 = (current bounding box.south east),
      \p3 = (last row)
    in
      (\x1-\tabcolsep,\rowdist) -- (\x2+\tabcolsep,\rowdist)
      ($ (\x1-\tabcolsep,\y3) - (0,\rowdist-1) $) --
      ($ (\x2+\tabcolsep,\y3) - (0,\rowdist-1) $)
    ;
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@horlines}[2]{Optional Settings}{Row numbers}
%    \begin{macrocode}
\newcommand*\tikztiming@horlines[2][]{%
  \begingroup
    \def\list{#2}%
    \ifx\list\empty
      \def\list{1,2,...,\nrows}%
    \fi
    \foreach \row in \list%
      \draw [timing/table/lines,#1] let
        \p1 = (timing/table/bottom right)
      in
        (0,\rowdist-\row*\rowdist) -- +(\x1,0);
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@vertlines}[2]{Optional Settings}{Column numbers}
%    \begin{macrocode}
\newcommand*\tikztiming@vertlines[2][]{%
  \begingroup
    \def\list{#2}%
    \ifx\list\empty
      \def\list{0,1,...,\twidth}%
    \fi
    \draw [timing/table/lines,#1] let
        \p1 = ($ (timing/table/bottom right) - (0,2) $)
      in
        \foreach \clk in \list {
          (\clk,+1.5) -- +(0,\y1)
        }
    ;
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Shape}
%    \begin{macrocode}
\pgfdeclareshape{tikztiming@shape}{%
  \savedanchor\northeast{\pgfpointxy{.5*\tikztimingwidth}{.5}}%
  \savedanchor\northeastborder{\pgfpointxy{.5*\tikztimingwidth+0.1}{.6}}%
  \savedanchor\startpoint{%
    \pgfpointanchor{timing/start}{center}%
    \@tempdima=\pgf@x
    \@tempdimb=\pgf@y
    \pgfpointxy{-.5*\tikztimingwidth}{-.5}%
    \advance\pgf@x by \@tempdima
    \advance\pgf@y by \@tempdimb
  }%
  \savedanchor\endpoint{%
    \pgfpointanchor{timing/end}{center}%
    \@tempdima=\pgf@x
    \@tempdimb=\pgf@y
    \pgfpointxy{-.5*\tikztimingwidth}{-.5}%
    \advance\pgf@x by \@tempdima
    \advance\pgf@y by \@tempdimb
  }%
  \anchor{center}{\pgfpointorigin}%
  \anchor{start}{\startpoint}%
  \anchor{end}{\endpoint}%
  %
  \anchor{origin}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{east}{\northeast \pgf@y=0pt }%
  \anchor{west}{\northeast \pgf@y=0pt \pgf@x=-\pgf@x }%
  \anchor{north}{\northeast \pgf@x=0pt }%
  \anchor{north west}{\northeast \pgf@x=-\pgf@x }%
  \anchor{north east}{\northeast}
  \anchor{high mid}{\northeast \pgf@x=0pt }%
  \anchor{high start}{\northeast \pgf@x=-\pgf@x }%
  \anchor{high end}{\northeast}
  \anchor{south}{\northeast \pgf@x=0pt \pgf@y=-\pgf@y }%
  \anchor{south west}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{south east}{\northeast \pgf@y=-\pgf@y }%
  \anchor{low mid}{\northeast \pgf@x=0pt \pgf@y=-\pgf@y }%
  \anchor{low start}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{low end}{\northeast \pgf@y=-\pgf@y }%
  \anchor{mid}{\pgfpointorigin}%
  \anchor{mid east}{\northeast \pgf@y=0pt }%
  \anchor{mid west}{\northeast \pgf@y=0pt \pgf@x=-\pgf@x }%
  \anchor{mid end}{\northeast \pgf@y=0pt }%
  \anchor{mid start}{\northeast \pgf@y=0pt \pgf@x=-\pgf@x }%
  \anchor{base}{\northeast \pgf@x=0pt \pgf@y=-\pgf@y }%
  \anchor{base west}{\northeast \pgf@x=-\pgf@x \pgf@y=-\pgf@y }%
  \anchor{base east}{\northeast \pgf@y=-\pgf@y }%
  \anchorborder{%
    \@tempdima=\pgf@x
    \@tempdimb=\pgf@y
    \pgfpointborderrectangle{\pgfpoint{\@tempdima}{\@tempdimb}}{\northeastborder}%
  }%
}
%    \end{macrocode}
%
% \subsection{Other Macros}
%
% \begin{macro}{\tikztiming@iflower}[1]{Character}
%    \begin{macrocode}
\def\tikztiming@iflower#1{%
  \begingroup
  \edef\@tempa{`#1}%
  \ifnum\@tempa=\lccode\@tempa
    \endgroup
    \expandafter
    \@firstoftwo
  \else
    \endgroup
    \expandafter
    \@secondoftwo
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\timingwidth}
% \begin{macro}{\timingheight}
%    \begin{macrocode}
\def\timingwidth{1}%
\def\timingheight{1}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\tikztiming@internaldefs}[1]{Character}
%    \begin{macrocode}
\def\tikztiming@internaldefs#1{%
  \def\draw{\noexpand\draw}%
  \def\path{\noexpand\path}%
  \def\fill{\noexpand\fill}%
  \def\width{####1*\noexpand\timingwidth}%
  \def\fwidth{\noexpand\timingwidth}%
  \def\height{\noexpand\timingheight}%
  \def\slope{\noexpand\timingslope}%
  \def\zslope{\noexpand\timingzslope}%
  \def\dslope{\noexpand\timingdslope}%
  \def\gslope{0}%
  \lowercase{%
  \def\style{timing/#1}%
  \def\bgstyle{timing/#1/background}%
  }%
  \def\newdraw{\tikztiming@newdraw}%
  \def\newdrawns{\tikztiming@newdraw@nosave}%
  \def\code##1{ [/utils/exec={\unexpanded{##1}}] }%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\tikztimingsetslope}[1]{Slope value}
%    \begin{macrocode}
\def\tikztimingsetslope#1{%
  \pgfmathparse{min(1.0,{max(0.0,#1)})}%
  \let\tikztiming@slope\pgfmathresult
  \edef\timingslope{\tikztiming@slope*\noexpand\timingwidth}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingsetdslope}[1]{Slope value}
%    \begin{macrocode}
\def\tikztimingsetdslope#1{%
  \pgfmathparse{min(1.0,{max(0.0,#1)})}%
  \let\tikztiming@dslope\pgfmathresult
  \edef\timingdslope{\tikztiming@dslope*\noexpand\timingwidth}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingsetzslope}[1]{Slope value}
%    \begin{macrocode}
\def\tikztimingsetzslope#1{%
  \pgfmathparse{min(1.0,{max(0.0,#1)})}%
  \let\tikztiming@zslope\pgfmathresult
  \edef\timingzslope{\tikztiming@zslope*\noexpand\timingwidth}%
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\tikztimingsetslope{0.10}%
\tikztimingsetdslope{0.20}%
\tikztimingsetzslope{0.05}%
%    \end{macrocode}
%
% \begin{macro}{\tikztiminguse}[1]{Character(s)}
%    \begin{macrocode}
\def\tikztiminguse#1{%
  \@ifundefined{\tikztiming@prefix#1@general}%
    {\PackageWarning{Can not use transition macro for '#1'.}{}{}{}}%
    {\@nameuse{\tikztiming@prefix#1@general}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingdef}[1]{One or two characters}
%    \begin{macrocode}
\def\tikztimingdef#1{%
  \tikztimingdef@#1\relax%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingdef@}[3]{First character}{Second character or 
% empty}{Definition code}
%    \begin{macrocode}
\def\tikztimingdef@#1#2\relax#3{%
  \ifx\relax#2\relax
    \tikztiming@nameedef[#1]{#1}{#3}%
  \else
    \tikztiming@nameedef[#2]{#1#2}{#3}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiminglet}[2]{Original characters}{New characters}
%    \begin{macrocode}
\def\tikztiminglet#1#2{%
  \tikztiminglet@#1\relax#2\relax
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiminglet@}[4]{First original character}{Second original 
% character}{First new character}{Second new character}
%    \begin{macrocode}
\def\tikztiminglet@#1#2\relax#3#4\relax{%
  \tikztiming@namelet{#1#2}{#3#4}%
  \tikztiming@namelet{#1#2@general}{#3#4@general}%
  \tikztiming@iflower{#1}{}%
    {\tikztiming@iflower{#2}%
      {%
        \lowercase{\tikztiminglet@{#1}{#2}\relax{#3}{#4}}\relax
      }%
      {%
        \uppercase{\lowercase{%
        \uppercase{\lowercase{\tikztiminglet@{#1}}{#2}}\relax{#3}}{#4}}\relax
        \lowercase{\uppercase{%
        \lowercase{\uppercase{\tikztiminglet@{#1}}{#2}}\relax{#3}}{#4}}\relax
      }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@chars}[1]{Comma to gobble}
% Initial definition of character list. Will gobble the separation comma in 
% front of the first character which is added to the list.
% \begin{macrocode}
\def\tikztiming@chars#1{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@ifcharexists}[1]{Character to check if in list}
%    \begin{macrocode}
\def\tikztiming@ifcharexists#1{%
  \def\tikztiming@ifcharexists@##1,#1,##2\relax{%
    \ifx\relax##2\relax%
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
  \expandafter\tikztiming@ifcharexists@
  \expandafter,\tikztiming@chars,#1,\relax%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\tikztiming@addchar}[1]{Character}
%    \begin{macrocode}
\def\tikztiming@addchar#1{%
  \tikztiming@ifcharexists{#1}{%
    \edef\tikztiming@chars{\tikztiming@chars,#1}%
  }{}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingchar}[1]{New character}
%    \begin{macrocode}
\def\tikztimingchar#1{%
  \uppercase{%
  \tikztiming@addchar{#1}%
  \tikztimingchar@{#1}}%
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\expandafter\def\csname\tikztiming@prefix @start\endcsname#1{}%
%    \end{macrocode}
%
% \begin{macro}{\tikztimingchar@}[3]{Character}{Start position}{Character 
% drawing code}
%    \begin{macrocode}
\def\tikztimingchar@#1#2#3{%
  \tikztiming@nameedef[#1]{#1@start}{#2 coordinate (timing/start) }%
  \tikztiming@nameedef[#1]{#1}{#2 coordinate (timing/start) #3}%
  \tikztimingdef{#1#1}{#3}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingalias}[2]{Original character}{New character}
%    \begin{macrocode}
\def\tikztimingalias#1#2{%
  \uppercase{\tikztimingalias@{#1}{#2}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingalias@}[2]{New character}{Original character}
%    \begin{macrocode}
\def\tikztimingalias@#1#2{%
  \tikztiming@namelet{#1}{#2}%
  \tikztiming@namelet{#1@start}{#2@start}%
  \lowercase{%
  \tikztiming@namelet{#1}{#2}%
  \tikztiming@namelet{#1@start}{#2@start}%
  }%
  \tikztiminglet{#1#1}{#2#2}%
  \@for\@tempa:=\tikztiming@chars\do{%
    \expandafter\tikztiminglet@@
    \expandafter{\@tempa}{#1}{#2}%
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingecopy}[2]{New character}{Original character}
%    \begin{macrocode}
\def\tikztimingecopy#1#2{%
  \uppercase{\tikztimingecopy@{#1}{#2}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztimingecopy@}[2]{New character}{Original character}
%    \begin{macrocode}
\def\tikztimingecopy@#1#2{%
  \tikztimingchar{#1}{}{}%
  \tikztimingdef{#1}{\tikztiminguse{#2}{##1}}%
  \tikztiming@nameedef[#1]{#1@start}{\tikztiminguse{#2@start}{##1}}%
  \lowercase{%
    \@ifundefined{\tikztiming@prefix#2}{}{%
      \tikztimingdef{#1}{\tikztiminguse{#2}{##1}}%
      \tikztiming@nameedef[#1]{#1@start}{\tikztiminguse{#2@start}{##1}}%
    }%
  }%
  \tikztimingdef{#1#1}{\tikztiminguse{#2#2}{##1}}%
  \@for\@tempa:=\tikztiming@chars\do{%
    \expandafter\tikztimingdef@@
    \expandafter{\@tempa}{#1}{#2}%
%    \end{macrocode}
%    Handle lowercase macros:
%    \begin{macrocode}
    \expandafter\lowercase\expandafter{\expandafter\def\expandafter\@tempb
    \expandafter{\@tempa}}%
    \@ifundefined{\tikztiming@prefix#2\@tempb}{}{%
      \expandafter\tikztimingdef@@
      \expandafter{\@tempb}{#1}{#2}%
    }%
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiminglet@@}[3]{Character from list}{New 
% character}{Original character}
%    \begin{macrocode}
\def\tikztiminglet@@#1#2#3{%
  \tikztiminglet@@@#1#2#3%
  % Should stay, cause no harm:
  \lowercase{\tikztiminglet@@@#1}#2#3%
  \lowercase{\tikztiminglet@@@#1#2#3}%
  \lowercase{\uppercase{\tikztiminglet@@@#1}#2#3}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiminglet@@@}[3]{Character from list}{New 
% character}{Original character}
%    \begin{macrocode}
\def\tikztiminglet@@@#1#2#3{%
  \tikztiminglet{#1#2}{#1#3}%
  \tikztiminglet{#2#1}{#3#1}%
}
%    \end{macrocode}
% \end{macro}

%
% \begin{macro}{\tikztimingdef@@}[3]{Character from list}{New 
% character}{Original character}
%    \begin{macrocode}
\def\tikztimingdef@@#1#2#3{%
  \tikztimingdef{#1#2}{\tikztiminguse{#1#3}{##1}}%
  \tikztimingdef{#2#1}{\tikztiminguse{#3#1}{##1}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@savesettings}
%    \begin{macrocode}
\def\tikztiming@savesettings{%
  \xdef\tikztiming@saved@settings{%
    {\tikztiming@slope}%
    {\tikztiming@dslope}%
    {\tikztiming@zslope}%
    {\the\pgflinewidth}%
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@restoresettings}
%    \begin{macrocode}
\def\tikztiming@restoresettings{%
  \expandafter\tikztiming@restoresettings@
  \tikztiming@saved@settings\relax
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@restoresettings@}[4]{Slope}{D-Slope}{Z-Slope}{Line 
% width}
%    \begin{macrocode}
\def\tikztiming@restoresettings@#1#2#3#4\relax{%
  \tikztimingsetslope{#1}%
  \tikztimingsetdslope{#2}%
  \tikztimingsetzslope{#3}%
  \pgfsetlinewidth{#4}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tikztiming@newdraw}
%    \begin{macrocode}
\def\tikztiming@newdraw{%
  node [timing/save] (timing@save) {};%
  \draw [timing/restore] (timing@save) ++(0,0)
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\tikztiming@newdraw}
%    \begin{macrocode}
\def\tikztiming@newdraw@nosave{%
  node [timing/coord] (timing@save) {};%
  \draw (timing@save) ++(0,0)
}
%    \end{macrocode}
% \end{macro}

% \subsection{Definition of Timing Characters}
%    \begin{macrocode}
\tikztimingchar{H}{++(0,\height)}{-- ++(#1,0)}

\tikztimingchar{L}{++(0,0)}{-- ++(#1,0)}

\tikztimingchar{Z}{++(0,\height/2.)}{%
  \newdraw [\style]
  -- ++(#1,0)
}

\tikztimingchar{X}{}{}%
\tikztimingchar{D}{}{}%
\tikztimingchar{U}{}{}%
%\tikztimingchar{O}{}{}%
\tikztimingchar{M}{}{}%

\tikztimingchar{G}{++(0,0)}{-- ++(\gslope,\height) -- ++(\gslope,-\height)}
\tikztimingchar{S}{++(0,0)}{++(#1,0)}

\tikztimingdef{DD}{
  node [timing/save] (timing@save) {}; \path [\bgstyle] (timing@save) ++(0,0)
     +(0.5*\dslope,0.5*\height) -- +(\dslope,0)
  -- +(#1,0)
  -- +($ (#1,0) + 0.5*(\dslope,\height) $)
  -- +(#1,\height)
  -- +(\dslope,\height) -- cycle;
  \draw [timing/restore,\style] (timing@save) ++(0,0)
  node [timing/save] (timing@dstart) at +(\dslope/2.,\height/2.) {}
  --  +(\dslope,+\height) --  +(#1,+\height) ++(0,+\height)
  --  +(\dslope,-\height) -- ++(#1,-\height)
}
\tikztiming@namelet{D@edge@D}{DD}
\tikztiming@namelet{D@edge@D@general}{DD@general}

\tikztimingchar{D}{++(0,0)}{
  node [timing/save] (timing@save) {}; \path [\bgstyle] (timing@save) ++(0,0)
  -- +(#1,0)
  -- +($ (#1,0) + 0.5*(\dslope,\height) $)
  -- +(#1,\height)
  -- +(0,\height)
  -- cycle;
  \draw [timing/restore,\style] (timing@save) ++(0,0)
  node [timing/save] (timing@dstart) at +(-\dslope/2.,\height/2.0) {}
  --  +(#1,0) ++(0,+\height)
  -- ++(#1,0) ++(0,-\height)
}

\tikztimingdef{DD}{
  node [timing/save] (timing@save) {}; \path [\bgstyle] (timing@save) ++(0,0)
  -- +(#1,0)
  -- +($ (#1,0) + 0.5*(\dslope,\height) $)
  -- +(#1,\height)
  -- +(0,\height)
  -- cycle;
  \newdraw [\style]
  --  +(#1,0) ++(0,+\height)
  -- ++(#1,0) ++(0,-\height)
}

\tikztiming@namelet{D@edge@@start}{D@start}
\tikztiming@namelet{d@edge@@start}{d@start}

%    \end{macrocode}
%
% \begin{macro}{\tikztiming@trans@D@fill}[2]{Original width}{Width to subtract}
%    \begin{macrocode}
\def\tikztiming@trans@D@fill#1#2{%
  node [timing/save] (timing@save) {}; \path [\bgstyle] (timing@save) ++(0,0)
  -- +(0.5*\dslope,-0.5*\height)
  -- ++($ (#1,-0.5*\height) - (#2,0) $)
  -- +(0.5*\dslope,0.5*\height)
  -- +(0,\height)
  -- ++($ (#2,\height) - (#1,0) + (0.5*\dslope,0) $)
  -- cycle;
  \draw [timing/restore,\style] (timing@save) ++(0,0)
  node [timing/save] (timing@dstart) {}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\tikztimingdef{HH}{-- ++(#1,0)}
\tikztimingdef{LL}{-- ++(#1,0)}
\tikztimingdef{HL}{-- ++(\slope,-\height) \tikztiminguse{HH}{#1-\slope}}
\tikztimingdef{LH}{-- ++(\slope, \height) \tikztiminguse{LL}{#1-\slope}}

\tikztimingdef{HG}{-- ++(\gslope,-\height) -- ++(\gslope,+\height)}
\tikztimingdef{LG}{-- ++(\gslope,+\height) -- ++(\gslope,-\height)}
\tikztimingdef{ZG}{
  -- ++(\gslope,-\height/2.0)
  -- ++(\gslope,+\height)
  -- ++(\gslope,-\height/2.0)
}
\tikztiminglet{DG}{LG}

\tikztiminglet{HS}{S}
\tikztiminglet{LS}{S}
\tikztiminglet{ZS}{S}
\tikztiminglet{DS}{S}
\tikztiminglet{TS}{S}

\tikztimingdef{LZ}{
  \newdraw [\style]
  -- ++(\zslope,+\height/2.) -- ++($ (#1,0) - (\zslope,0) $)
}
\tikztimingdef{HZ}{%
  \newdraw [\style]
  -- ++(\zslope,-\height/2.) -- ++($ (#1,0) - (\zslope,0) $)
}
\tikztimingdef{ZH}{
    \newdraw
  -- ++(\zslope,+\height/2.) -- ++($ (#1,0) - (\zslope,0) $)
}
\tikztimingdef{ZL}{%
  \newdraw
  -- ++(\zslope,-\height/2.) -- ++($ (#1,0) - (\zslope,0) $)
}

\tikztimingdef{DZ}{
  -- ++( \dslope/2.,+\height/2.)
     ++(-\dslope/2.,+\height/2.)
  -- ++( \dslope/2.,-\height/2.)
  \newdraw [\style]
  -- ++($ (#1,0) - (\dslope/2.,0) $)
}

\tikztimingdef{ZD}{
  \tikztiming@trans@D@fill{#1}{0}%
  -- ++(\dslope/2.,\height/2.)  -- ++($ (#1,0) - (\dslope/2.,0) $)
     ++($ -1*(#1,0) + (0,-\height/2.) $)
  -- ++(\dslope/2.,-\height/2.) -- ++($ (#1,0) - (\dslope/2.,0) $)
}

\tikztimingdef{LD}{
  -- ++(0.5*\dslope,0.5*\height)
  \tikztiming@trans@D@fill{#1}{0.5*\dslope}%
  -- ++(0.5*\dslope,0.5*\height)
  -- ++($ (#1,0) - (\dslope,0) $)
     ++($ -1*(#1,0) + (0,-\height) $)          ++(\dslope/2.,+\height/2.)
  -- ++(\dslope/2.,-\height/2.) -- ++($ (#1,0) - (\dslope,0) $)
}

\tikztimingdef{DL}{
  -- ++( \dslope/2.,+\height/2.)
     ++(-\dslope/2.,+\height/2.)
  -- ++(\dslope/2.,-\height/2.)
  \newdraw [\style]
  -- ++(\dslope/2.,-\height/2.)
  -- ++($ (#1,0) - (\dslope,0) $)
}

\tikztimingdef{HD}{
  -- ++(0.5*\dslope,-0.5*\height)
  \tikztiming@trans@D@fill{#1}{0.5*\dslope}%
  -- ++(0.5*\dslope,-0.5*\height)
  -- ++($ (#1,0) - (\dslope,0) $)
     ++($ -1*(#1,0) + (0,+\height) $)          ++(\dslope/2.,-\height/2.)
  -- ++(\dslope/2.,+\height/2.) -- ++($ (#1,0) - (\dslope,0) $)
     ++(0,-\height)
}

\tikztimingdef{DH}{
     ++(0,+\height)
  -- ++(+\dslope/2.,-\height/2.)
     ++(-\dslope/2.,-\height/2.)
  -- ++(\dslope/2.,+\height/2.)
  \newdraw [\style]
  -- ++(\dslope/2.,+\height/2.)
  -- ++($ (#1,0) - (\dslope,0) $)
}


\tikztimingalias{M}{Z}
\tikztimingchar{M}{++(0,\height/2.)}{
  \newdraw [\style/decoration,\style]
  -- ++(#1,0)
}
\tikztimingdef{MG}{
  \newdraw [timing/m]
  -- ++(\gslope,-\height/2.0)
  -- ++(\gslope,+\height)
  -- ++(\gslope,-\height/2.0)
}

\tikztimingdef{MZ}{
  \newdraw [\style]
  \tikztiminguse{ZZ}{#1}
}

\tikztimingdef{ZM}{
  \newdraw [\style]
  \tikztiminguse{MM}{#1}
}

\tikztimingdef{LM}{
  \newdraw [\style]
  -- ++($ (1/8,0) + (0,\height/2) $)
  \newdraw [\style/decoration,\style]
  -- ++($ (-1/8,0) + (#1,0) $)
}

\tikztimingdef{HM}{
  \newdraw [\style]
  -- ++($ (1/8,0) + (0,-1*\height/2) $)
  \newdraw [\style/decoration,\style]
  -- ++($ (-1/8,0) + (#1,0) $)
}

\tikztimingdef{DM}{
  --  +($  (1/8,0) + (0,\height*.50) $)
      +(0,\height)
  -- ++($  (1/8,0) + (0,\height*.50) $)
  \newdraw [\style/decoration,\style]
  -- ++($ (-1/8,0) + (#1,0) $)
}

\newcounter{tikztimingtrans}
\newcounter{tikztimingtranspos}

\tikztimingchar{T}{++(0,0)}{
  -- ++(#1,0)
}

\tikztimingdef{HT}{%
  {[\style]
  \code{\setcounter{tikztimingtrans}{-1}}
  -- ++(\slope,\value{tikztimingtrans}*\height) -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{LT}{%
  {[\style]
  \code{\setcounter{tikztimingtrans}{+1}}
  -- ++(\slope,\value{tikztimingtrans}*\height) -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{TL}{%
  \code{\setcounter{tikztimingtranspos}{\value{tikztimingtrans}}%
  \addtocounter{tikztimingtranspos}{+1}}
  -- ++(\slope, -0.5*\value{tikztimingtranspos}*\height) -- ++($ (#1,0) - (\slope,0) $)
}

\tikztimingdef{TH}{%
  \code{\setcounter{tikztimingtranspos}{\value{tikztimingtrans}}%
  \addtocounter{tikztimingtranspos}{-1}}
  -- ++(\slope, -0.5*\value{tikztimingtranspos}*\height) -- ++($ (#1,0) - (\slope,0) $)
}

\tikztimingdef{TZ}{%
  \newdraw [\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++(\slope,\value{tikztimingtrans}*\height/2.)
  -- ++($ (#1,0) - (\slope,0) $)
}

\tikztimingdef{TG}{%
  -- +(\gslope,-1*\value{tikztimingtrans}*\height)
  -- +(\gslope,0)
}

\tikztimingdef{ZT}{%
  \newdraw
  {[\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++(\slope,\value{tikztimingtrans}*\height/2.)
  -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{TT}{%
  {[\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++(\slope,\value{tikztimingtrans}*\height) -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{TD}{
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  \code{\setcounter{tikztimingtranspos}{\value{tikztimingtrans}}%
  \addtocounter{tikztimingtranspos}{-1}}
  -- ++(0.5*\dslope,+0.5*\value{tikztimingtrans} * \height)
  \tikztiming@trans@D@fill{#1}{0.5*\dslope}%
  -- ++(0.5*\dslope,+0.5*\value{tikztimingtrans} * \height)
  -- ++($ (#1,0) - (\dslope,0) $)
     ++($ -1*(#1,\value{tikztimingtrans}*\height) $)
     ++(\dslope/2.,+1*\value{tikztimingtrans}*\height/2.)
  -- ++(\dslope/2.,-1*\value{tikztimingtrans}*\height/2.)
  -- ++($ (#1,0) - (\dslope,0) $)
     ++(0,\value{tikztimingtranspos}*\height/2.)
}

\tikztimingdef{DT}{
  \code{\setcounter{tikztimingtrans}{-1}}
  \tikztiminguse{DL}{#1}%
}

\tikztimingdef{MT}{%
  \newdraw
  {[\style]
  -- ++(\slope,\value{tikztimingtrans}*\height/2.) -- ++($ (#1,0) - (\slope,0) $)
  }
}

\tikztimingdef{TM}{%
  \newdraw [\style]
  \code{\setcounter{tikztimingtrans}{-\value{tikztimingtrans}}}
  -- ++($ (1/8,0) + (0,\value{tikztimingtrans}*\height/2) $)
  \newdraw [\style/decoration,\style]
  -- ++($ (-1/8,0) + (#1,0) $)
}

\tikztimingecopy{C}{T}
\def\tikztiming@nocombine@T{}%
\def\tikztiming@nocombine@C{}%
\def\tikztiming@nocombine@t{}%
\def\tikztiming@nocombine@c{}%
\def\tikztiming@nocombine@M{}%
\def\tikztiming@nocombine@m{}%


\tikztimingecopy{U}{D}
\tikztimingdef{UD}{\tikztiminguse{D@edge@D}{#1}}
\tikztimingdef{DU}{\tikztiminguse{D@edge@D}{#1}}

%\tikztimingecopy{O}{D}
\tikztimingecopy{X}{Z}
%    \end{macrocode}
%
% \Finale
\endinput
%</package>