docs: cover `nmigen.lib.coding`.
authorCatherine <whitequark@whitequark.org>
Mon, 13 Dec 2021 05:48:31 +0000 (05:48 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 31 Dec 2021 20:20:30 +0000 (20:20 +0000)
docs/conf.py
docs/index.rst
docs/stdlib.rst [new file with mode: 0644]
docs/stdlib/coding.rst [new file with mode: 0644]
nmigen/lib/coding.py

index 22ab5cd251f0cb6ed0144779fd93de0df03eb521..234fcb830ee23fa71f52452e0bd92499e8acd4c3 100644 (file)
@@ -12,6 +12,8 @@ extensions = [
        "sphinx.ext.intersphinx",
        "sphinx.ext.doctest",
     "sphinx.ext.todo",
+    "sphinx.ext.autodoc",
+    "sphinx.ext.napoleon",
     "sphinx_rtd_theme",
     "sphinxcontrib.platformpicker",
 ]
@@ -25,6 +27,10 @@ intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
 
 todo_include_todos = True
 
+napoleon_google_docstring = False
+napoleon_numpy_docstring = True
+napoleon_use_ivar = True
+
 html_theme = "sphinx_rtd_theme"
 html_static_path = ["_static"]
 html_css_files = ["custom.css"]
index cade2898a523ad5b2eb1f26c232a64ca78a58eb1..97a51ca94c687d2288e058af5fdeb20f9fb642d1 100644 (file)
@@ -13,3 +13,4 @@ Language & toolchain
    start
    tutorial
    lang
+   stdlib
diff --git a/docs/stdlib.rst b/docs/stdlib.rst
new file mode 100644 (file)
index 0000000..333db16
--- /dev/null
@@ -0,0 +1,11 @@
+Standard library
+################
+
+.. todo::
+
+   Write this section.
+
+.. toctree::
+   :maxdepth: 2
+
+   stdlib/coding
diff --git a/docs/stdlib/coding.rst b/docs/stdlib/coding.rst
new file mode 100644 (file)
index 0000000..1f1732f
--- /dev/null
@@ -0,0 +1,27 @@
+Code conversion
+###############
+
+.. py:module:: nmigen.lib.coding
+
+The ``nmigen.lib.coding`` package provides modules for conversion between different encodings of binary numbers.
+
+
+One-hot coding
+==============
+
+.. autoclass:: Encoder()
+.. autoclass:: Decoder()
+
+
+Priority coding
+===============
+
+.. autoclass:: PriorityEncoder()
+.. autoclass:: PriorityDecoder()
+
+
+Gray coding
+===========
+
+.. autoclass:: GrayEncoder()
+.. autoclass:: GrayDecoder()
index 5abfbd71351308df1636f58c2f4c774c04965cab..aedff65b752af64af871a87511bdc8d992533c66 100644 (file)
@@ -1,5 +1,3 @@
-"""Encoders and decoders between binary and one-hot representation."""
-
 from .. import *
 
 
@@ -26,7 +24,7 @@ class Encoder(Elaboratable):
     i : Signal(width), in
         One-hot input.
     o : Signal(range(width)), out
-        Encoded binary.
+        Encoded natural binary.
     n : Signal, out
         Invalid: either none or multiple input bits are asserted.
     """
@@ -65,7 +63,7 @@ class PriorityEncoder(Elaboratable):
     i : Signal(width), in
         Input requests.
     o : Signal(range(width)), out
-        Encoded binary.
+        Encoded natural binary.
     n : Signal, out
         Invalid: no input bits are asserted.
     """
@@ -88,7 +86,7 @@ class PriorityEncoder(Elaboratable):
 class Decoder(Elaboratable):
     """Decode binary to one-hot.
 
-    If ``n`` is low, only the ``i``th bit in ``o`` is asserted.
+    If ``n`` is low, only the ``i``-th bit in ``o`` is asserted.
     If ``n`` is high, ``o`` is ``0``.
 
     Parameters
@@ -141,7 +139,7 @@ class GrayEncoder(Elaboratable):
     Attributes
     ----------
     i : Signal(width), in
-        Input natural binary.
+        Natural binary input.
     o : Signal(width), out
         Encoded Gray code.
     """
@@ -168,7 +166,7 @@ class GrayDecoder(Elaboratable):
     Attributes
     ----------
     i : Signal(width), in
-        Input Gray code.
+        Gray code input.
     o : Signal(width), out
         Decoded natural binary.
     """