diff --git a/index.html b/index.html index 8eaf1d2..258f678 100644 --- a/index.html +++ b/index.html @@ -2,155 +2,155 @@ - + - Paying It Forward: Documenting your Hardware + Paying It Forward: Documenting your Hardware - - + + - - + + - + - - + + - - + + - - + + - + - + .reveal .slides > section > section[data-transition=zoomrev].future, + .reveal .slides > section > section[data-transition~=zoomrev-in].future, + .reveal.zoomrev .slides > section > section:not([data-transition]).future { + -webkit-transform: translate(0, -150%); + transform: translate(0, -150%); + } + - -
- -
-
-

Paying it Forward: Documenting Your Hardware Project

-

Approaches to documenting a hardware description language using lxsocdoc

-

- Sean Cross - https://xobs.io/ - @xobs -

-
+ +
+ +
+
+

Paying it Forward: Documenting Your Hardware Project

+

Approaches to documenting a hardware description language using lxsocdoc

+

+ Sean Cross - https://xobs.io/ - @xobs +

+
-
-

Introduction

- -
+
+

Introduction

+ +
-
-

About Me

- -
+
+

About Me

+ +
-
-

Undocumented Hardware = Bad

-

(But so easy to do!)

- +
-
-

Talk Outline

-
    -
  1. How to write HDL Code
  2. -
  3. Rationale behind lxsocdoc
  4. -
  5. Examples of lxsocdoc
  6. -
  7. Benefits of this approach
  8. -
- -
+
+

Talk Outline

+
    +
  1. How to write HDL Code
  2. +
  3. Rationale behind lxsocdoc
  4. +
  5. Examples of lxsocdoc
  6. +
  7. Benefits of this approach
  8. +
+ +
-
-

Motivation

-
// Hardware definitions of the SoC. Also is the main repo of
+            
+

Motivation

+
// Hardware definitions of the SoC. Also is the main repo of
 // documentation for the programmer-centric view
 // of the hardware.
 /* Start of memory range for the UART peripheral */
@@ -165,46 +165,55 @@
    The debug UART is always configured as 8N1. */
 #define UART_DATA_REG   0x00

mach_defines.h, Hackaday 2019 Con Badge

- -
+ +
-
-

About LiteX and lxsocdoc

- -
+
+

About LiteX

+
    +
  1. Hardware Description Language embedded in Python
  2. +
      +
    1. Doesn't run Python in hardware!
    2. +
    +
  3. Emits Verilog (or Yosys netlists)
  4. +
  5. Makes it easy to create a SoC
  6. +
  7. Powers the LCA2020 video production setup
  8. +
+ +
-
+

LiteX Primitives

class GPIOOut(Module, AutoCSR):
     def __init__(self, signal):
         self._out = CSRStorage(len(signal))
         self.comb += signal.eq(self._out.storage)
- -
+ +
-
-

SPI Bitbang Module

-
self.bitbang = CSRStorage(4)
+            
+

Case Study: SPI Bitbang Module

+
self.bitbang = CSRStorage(4)
 If(self.bitbang.storage[3],
     dq.oe.eq(0)
 ).Else(
@@ -217,33 +226,47 @@ If(self.bitbang.storage[1],
 dq.o.eq(
     Cat(self.bitbang.storage[0], Replicate(1, spi_width-1))
 )
-
+ You can kind of understand it, but it does take a lot of mental power to + work through it. I started by creating aliases for the various elements + in the storage array, but then I thought: There has to be a better way! + +
-
-

Aside: Python Docstrings

- -
+
+

Aside: Python Docstrings

+
def _format_cmd(cmd, spi_width):
+    """
+    `cmd` is the read instruction. Since everything is
+    transmitted on all dq lines (cmd, adr and data), extend/
+    interleave cmd to full pads.dq width even if dq1-dq3 are
+    don't care during the command phase: For example, for
+    N25Q128, 0xeb is the quad i/o fast read, and extended
+    to 4 bits (dq1,dq2,dq3 high) is: 0xfffefeff
+    """
+    c = 2**(8*spi_width)-1
+    for b in range(8):
+        if not (cmd>>b)%2:
+            c &= ~(1<<(b*spi_width))
+    return c
+ +
-
-

New Register Definition

-
self.bitbang = CSRStorage(4, fields=[
+            
+

New Register Definition

+
self.bitbang = CSRStorage(4, fields=[
     CSRField("mosi", description="Output value for MOSI..."
     CSRField("clk", description="Output value for SPI CLK..."
     CSRField("cs_n", description="Output value for SPI C..."
@@ -252,22 +275,22 @@ dq.o.eq(
         ("1", "IN", "SPI pins are all input"),
     ])
 ], description="""Bitbang controls for SPI output.  Only
-	standard 1x SPI is supported, and as a result all
-	four wires are ganged together.  This means that it
-	is only possible to perform half-duplex operations,
-	using this SPI core.""")
- -
+ standard 1x SPI is supported, and as a result all + four wires are ganged together. This means that it + is only possible to perform half-duplex operations, + using this SPI core.""")
+ +
-
-

Refactored SPI Bitbang

-
If(self.bitbang.fields.dir,
+            
+

Refactored SPI Bitbang

+
If(self.bitbang.fields.dir,
     dq.oe.eq(0)
 ).Else(
     dq.oe.eq(1)
@@ -279,198 +302,198 @@ If(self.bitbang.fields.clk,
 dq.o.eq(
     Cat(self.bitbang.fields.mosi, Replicate(1, spi_width-1))
 )
-
+ This is a little bit easier to understand -- no longer are we looking at indices + in an array to determine what field does what. Instead we get actual named fields. + But because Python can introspect Python very easily, this is just the beginning. + +
-
+

Generating a Manual

-
+ This is already pretty useful. You can hand this file to someone and show them + how your design works. But the title of this talk is called "Paying it Forward", + and I can tell you from experience that having such a reference manual for yourself + while developing software for your own hardware is still invaluable. Hardware + designs are complex things, and not having to decode bitfield offsets in your + head or constantly referring to various sections of code to see how it's implemented + saves valuable time. + +
-
-

Undocumented Fields

- -
+
+

Undocumented Fields

+ +
-
-

Interrupts

+
+

Interrupts

- -
+ +
-
-

More Documentation: ModuleDoc

+
+

More Documentation: ModuleDoc

- -
+ +
-
-

Protocol Documentation

+
+

Protocol Documentation

- -
+ +
-
-

SVD: Documentation for Machines

- -
+
+

SVD: Documentation for Machines

+ +
-
-

SVD2Rust: Generating Safe Accessors

- -
+
+

SVD2Rust: Generating Safe Accessors

+ +
-
-

Renode: Fancy Register Logging

- -
+
+

Renode: Fancy Register Logging

+ +
-
-

Benefits of Higher Level Languages

- -
+
+

Benefits of Higher Level Languages

+ +
-
-

Documentation helps you

-

Documentation helps others

- -
+
+

Documentation helps you

+

Documentation helps others

+ +
-
-

Thank you

-

Questions

-
-
-
- +
+

Thank you

+

Questions

+
+
+
+ - - - + + + - + { src: 'lib/js/socket.io.js', async: true }, + { + src: presenter ? + 'plugin/multiplex/master.js' : + 'plugin/multiplex/client.js', async: true + }, + ] + }); +