|
22 | 22 | "source": [ |
23 | 23 | "%pip install pyrtl\n", |
24 | 24 | "\n", |
25 | | - "import io\n", |
26 | 25 | "import random\n", |
27 | 26 | "\n", |
28 | 27 | "import pyrtl\n", |
|
374 | 373 | "print(\"\\n--- Probe w/ debugging: ---\")\n", |
375 | 374 | "pyrtl.set_debug_mode()\n", |
376 | 375 | "pyrtl.probe(multout - 16, \"debugsubtr_probe\")\n", |
377 | | - "pyrtl.set_debug_mode(debug=False)\n" |
| 376 | + "pyrtl.set_debug_mode(False)\n" |
378 | 377 | ] |
379 | 378 | }, |
380 | 379 | { |
|
521 | 520 | "cell_type": "markdown", |
522 | 521 | "metadata": {}, |
523 | 522 | "source": [ |
524 | | - " Remove the [WireVector](https://pyrtl.readthedocs.io/en/latest/basic.html#pyrtl.WireVector) from the [Block](https://pyrtl.readthedocs.io/en/latest/blocks.html#pyrtl.Block) to prevent problems with the rest of this\n", |
525 | | - " example.\n" |
526 | | - ] |
527 | | - }, |
528 | | - { |
529 | | - "cell_type": "code", |
530 | | - "execution_count": null, |
531 | | - "metadata": { |
532 | | - "collapsed": true |
533 | | - }, |
534 | | - "outputs": [], |
535 | | - "source": [ |
536 | | - "pyrtl.working_block().remove_wirevector(dummy_wv)\n" |
537 | | - ] |
538 | | - }, |
539 | | - { |
540 | | - "cell_type": "markdown", |
541 | | - "metadata": {}, |
542 | | - "source": [ |
543 | | - " ## Trivial Graph Format\n", |
| 523 | + " ## Graphviz\n", |
544 | 524 | "\n", |
545 | | - " Finally, there is a handy way to view your hardware creations as a graph. The function\n", |
546 | | - " [output_to_trivialgraph()](https://pyrtl.readthedocs.io/en/latest/export.html#pyrtl.output_to_trivialgraph) will render your hardware in a format that you can then\n", |
547 | | - " open with the free software \"yEd\" (http://en.wikipedia.org/wiki/YEd). There are\n", |
548 | | - " options under the \"hierarchical\" rendering to draw something that looks quite like a\n", |
549 | | - " circuit.\n", |
| 525 | + " Finally, there is a handy way to view your hardware creations.\n", |
| 526 | + " [block_to_graphviz_string()](https://pyrtl.readthedocs.io/en/latest/export.html#pyrtl.block_to_graphviz_string) produces a description of your hardware in the `graphviz`\n", |
| 527 | + " language, which can be converted to an image with the `dot` graph drawing tool\n", |
| 528 | + " (https://graphviz.org/docs/layouts/dot/).\n", |
550 | 529 | "\n", |
551 | | - " Also see [block_to_svg()](https://pyrtl.readthedocs.io/en/latest/export.html#pyrtl.block_to_svg).\n" |
| 530 | + " Also see [block_to_svg()](https://pyrtl.readthedocs.io/en/latest/export.html#pyrtl.block_to_svg), which automates running `dot`.\n" |
552 | 531 | ] |
553 | 532 | }, |
554 | 533 | { |
|
559 | 538 | }, |
560 | 539 | "outputs": [], |
561 | 540 | "source": [ |
562 | | - "pyrtl.working_block().sanity_check()\n" |
563 | | - ] |
564 | | - }, |
565 | | - { |
566 | | - "cell_type": "markdown", |
567 | | - "metadata": {}, |
568 | | - "source": [ |
569 | | - " So that `output_to_trivial_graph()` will work.\n" |
570 | | - ] |
571 | | - }, |
572 | | - { |
573 | | - "cell_type": "code", |
574 | | - "execution_count": null, |
575 | | - "metadata": { |
576 | | - "collapsed": true |
577 | | - }, |
578 | | - "outputs": [], |
579 | | - "source": [ |
580 | | - "pyrtl.passes._remove_unused_wires(pyrtl.working_block())\n", |
581 | | - "\n", |
582 | | - "print(\"\\n--- Trivial Graph Format (first 10 lines) ---\")\n", |
583 | | - "with io.StringIO() as tgf:\n", |
584 | | - " pyrtl.output_to_trivialgraph(tgf)\n", |
585 | | - " for i, line in enumerate(tgf.getvalue().split(\"\\n\")):\n", |
586 | | - " if i == 10:\n", |
587 | | - " break\n", |
588 | | - " print(line)\n", |
| 541 | + "print(\"\\n--- Graphviz Format (first 10 lines) ---\")\n", |
| 542 | + "graphviz_string = pyrtl.block_to_graphviz_string()\n", |
589 | 543 | "\n", |
590 | | - " print(\"...\")\n" |
| 544 | + "for line in graphviz_string.split(\"\\n\")[:10]:\n", |
| 545 | + " print(line)\n", |
| 546 | + "print(\"...\")\n" |
591 | 547 | ] |
592 | 548 | } |
593 | 549 | ], |
|
0 commit comments