add slides
[libreriscv.git] / pinmux / pinmux_chennai_2018.tex
1 \documentclass[slidestop]{beamer}
2 \usepackage{beamerthemesplit}
3 \usepackage{graphics}
4 \usepackage{pstricks}
5
6 \title{Pin Multiplexer}
7 \author{Rishabh Jain}
8 \author{Luke Kenneth Casson Leighton}
9
10
11 \begin{document}
12
13 \frame{
14 \begin{center}
15 \huge{Pin Multiplexer}\\
16 \vspace{32pt}
17 \Large{Auto-generating documentation, code \\
18 and resources for a Pinmux}\\
19 \vspace{16pt}
20 \Large{Saving time and money for SoC / EC designers\\
21 in the RISC-V Ecosystem and beyond}\\
22 \vspace{24pt}
23 \Large{[proposed for] Chennai 9th RISC-V Workshop}\\
24 \vspace{16pt}
25 \large{\today}
26 \end{center}
27 }
28
29
30 \frame{\frametitle{Credits and Acknowledgements}
31
32 \begin{itemize}
33 \item TODO\vspace{10pt}
34 \end{itemize}
35 }
36
37
38 \frame{\frametitle{Glossary}
39
40 \begin{itemize}
41 \item GPIO: general-purpose reconfigureable I/O (Input/Output).
42 \item Pin: an I/O pad. May be driven (input) or may drive (output).
43 \item FN: term for a single-wire "function", such as UART\_TX,
44 I2C\_SDA, SDMMC\_D0 etc. may be an input, output or both
45 (bi-directional case: two wires are {\it always} allocated, one
46 for input to the function and one for output from the function).
47 \item Bus: a group of bi-directional functions (SDMMC D0 to D3)
48 where the direction is ganged and {\it under the Bus's control}
49 \item Input Priority Muxer: a multiplexer with N selector
50 wires and N associated inputs. The lowest (highest?) indexed
51 "selector" enabled results in its
52 input being routed to the output.
53 \item Output Muxer: a many-to-one "redirector" where any one
54 input is "routed" to the output, based on a selector "address".
55 \end{itemize}
56 }
57
58
59 \frame{\frametitle{Why, How and What is a Pinmux?}
60
61 \begin{itemize}
62 \item Why? To save cost, increase yield, and to target multiple
63 markets with the same design, thereby increasing uptake
64 and consequently taking advantage of volume pricing.\vspace{4pt}
65 \\
66 Summary: it's all about making more money!\vspace{4pt}
67 \item How? By multiplexing many more functions (100 to 1,200) than there
68 are actual available pins (48 to 500), the required chip package
69 is cheaper, smaller, and more versatile\vspace{4pt}
70 \item What? A many-to-many dynamically-configureable router of
71 I/O functions to I/O pins
72 \end{itemize}
73 \bf{Note: actual muxing is deceptively simple, but like a DRAM cell
74 it's actually about the extras (routing, docs, specs etc).\\
75 Just as DRAM Cell != DDR3/4, Muxer Cell != Pinmux}
76 }
77
78
79 \frame{\frametitle{What options are available (at time of writing)? [1]}
80
81 \vspace{6pt}
82 {\bf Commercial licensed}:
83 \vspace{4pt}
84 \begin{itemize}
85 \item Cost: unknown (and ultimately doesn't matter)
86 \item Flexibility: unknown (NDAs required in order to find out)
87 \item Language: unknown (NDAs required in order to find out)
88 \item Capability for auto-generation of Docs: unknown.
89 \item Capability for auto-generation of ancillary resources: unknown.
90 \item Suitability for wide range of systems: unknown.
91 \vspace{4pt}
92 \item Suitability for saving RISC-V ecosystem money: {\bf NONE }
93 \item Suitability for collaboration: {\bf ZERO} (prohibitive licensing)
94 \end{itemize}
95 \vspace{6pt}
96 Commercial licensees are isolated and cut off from the benefits
97 and resources of the Libre world. Translation: USD \$200k+ NREs.
98 }
99
100
101 \frame{\frametitle{What options are available (at time of writing)? [2]}
102
103 \vspace{6pt}
104 {\bf SiFive IOF (Freedom E310, Unleashed U540)}:
105 \vspace{4pt}
106 \begin{itemize}
107 \item License: Good!
108 \item Flexibility: not so good.
109 \item Language: chisel3.
110 \item Capability for auto-generation of Docs: none.
111 \item Capability for auto-generation of ancillary resources: partial.
112 \item Suitability for wide range of systems: not so good.
113 \vspace{4pt}
114 \item Suitability for saving RISC-V ecosystem money: {\bf Low }\\
115 \item Suitability for collaboration: {\bf GOOD} (but: written in Chisel3)
116 \end{itemize}
117 \vspace{6pt}
118 Using SiFive IOF has Libre benefits, but it's incomplete and
119 harder to find Chisel3 programmers (than e.g. for python).
120 }
121
122
123 \frame{\frametitle{What options are available (at time of writing)? [3]}
124
125 \vspace{10pt}
126 \begin{center}
127 {\Huge
128 None. No suitable\vspace{20pt}\\
129 Libre-licensed\vspace{20pt}\\
130 pinmux exists\vspace{20pt}
131 }
132 \\
133 (which is really weird, given how there's so many libre UART,
134 SPI and other peripheral libraries, even libre-licensed PCIe and
135 SATA PHYs and even USB3 Pipe. Hence the reason for this initiative)
136 \end{center}
137
138 }
139
140
141 \frame{\frametitle{Associated Extras}
142
143 \begin{itemize}
144 \item Design Specification ({\bf what} markets to target)
145 \item Scenario analysis ({\bf whether} the chip will fit "markets")
146 \item Documentation: Summary sheet, Technical Reference Manual.
147 \item Test suites
148 \item Control Interface (AXI4 / Wishbone / TileLink / other)
149 \item Simulation
150 \item Linux kernel drivers, DTB, libopencm3, Arduino libraries etc.
151 \end{itemize}
152 Example context:
153 \begin{itemize}
154 \item Shakti M-Class has 160 pins with a 99.5\% full 4-way mux
155 \item Almost 640-way routing, 6 "scenarios" (7th TBD),
156 100+ page Manual needed,
157 \bf{17,500 lines of auto-generated code}
158 \end{itemize}
159 }
160
161
162 \frame{
163 \vspace{30pt}
164 \begin{center}
165 {\Huge
166 ALL of these\vspace{20pt}\\
167 can be\vspace{20pt}\\
168 auto-generated\vspace{30pt}
169 }
170 \\
171 (from the Design Specification, after Scenario Analysis)
172 \end{center}
173
174 }
175
176
177 \frame{\frametitle{Example: 7 banks, 4-way mux, 160 pins}
178 \begin{center}
179 \includegraphics[height=1.5in]{example_pinmux.jpg}\\
180 7 "banks" with separate VCC. Each no more than 32 bits
181 \end{center}
182 \begin{itemize}
183 \item { \bf 17,500 lines of auto-generated HDL (and climbing)}
184 \item { \bf 12,500 lines of auto-generated Summary/Analysis}
185 \item Technical Reference Manual expected to be 100+ pages
186 \end{itemize}
187 }
188
189
190 \frame{\frametitle{Reduce workload, reduce duplication, reduce risk and cost}
191
192 \begin{itemize}
193 \item Auto-generate everything: documentation, code, libraries etc.\\
194 (including device-tree files, FreeBSD / Linux / RTOS kernel
195 drivers, Arduino, libopencm3 and other EC firmware libraries)
196 \vspace{4pt}
197 \item Standardise: similar to PLIC, propose GPIO and Pinmux\\
198 saves engineering effort, design effort and much more
199 \vspace{4pt}
200 \item Standardise format of configuration registers:
201 saves code duplication effort (multiple software environments)
202 \vspace{4pt}
203 \item Add support for multiple code formats: Chisel3 (SiFive IOF),
204 BSV (Bluespec), Verilog, VHDL, MyHDL.
205 \vspace{4pt}
206 \item Multiple auto-generated code-formats permits cross-validation:\\
207 auto-generated test suite in one HDL can validate a muxer
208 generated for a different target HDL.
209 \vspace{4pt}
210 \end{itemize}
211 }
212
213
214 \frame{\frametitle{Design Spec and Scenario Analysis}
215
216 \begin{itemize}
217 \item Analyse the target markets (scenarios) that the chip will sell in\\
218 (multiple markets increases sales volume, reduces chip cost)
219 \vspace{4pt}
220 \item Scenarios represent target markets: ICs to be connected\\
221 (GPS, NAND IC, WIFI etc. May require prototype schematics
222 drawn up, or client-supplied schematics analysed).
223 \vspace{4pt}
224 \item Create a formal (python-based) specification for the pinmux
225 \vspace{4pt}
226 \item Add scenarios (in python), check that they meet requirements\\
227 { \bf (before spending money on hardware engineers!) }
228 \vspace{4pt}
229 \item Analyse the scenarios: if pins are missing, alter and repeat.\\
230 \vspace{4pt}
231 \item Eventually the pinmux meets all requirements...\\
232 { \bf without spending USD \$5-50m to find out it doesn't!}
233 \end{itemize}
234 }
235
236
237
238 \frame{\frametitle{Muxer cases to handle (One/Many to One/Many) etc.}
239
240 \begin{itemize}
241 \item One FN output to Many Pins: no problem\\
242 (weird configuration by end-user, but no damage to ASIC)
243 \item One Pin to Many FN inputs: no problem\\
244 (weird configuration by end-user, but no damage to ASIC)
245 \item Many FN outputs simultaneously to one Pin: {\bf does not occur}\\
246 (not desirable and not possible, as part of the pinmux design)
247 \item Many Pins to One FN input: {\bf Priority Mux needed}\\
248 No priority mux: Pin1=HI, Pin0=LO and ASIC is destroyed
249 \item Some FNs (I2C\_SDA, SD\_D0..3) are I/O Buses\\
250 Bi-directional control of the Pin must be handed to the
251 FN
252 \item Nice to have: Bus sets pintype, signal strength etc.\\
253 e.g. selecting SD/MMC doesn't need manual pin-config.\\
254 \bf{caveat: get that wrong and the ASIC can't be sold}
255 \end{itemize}
256 }
257
258
259 \frame{\frametitle{Pin Configuration, input and output}
260
261 In/out: {\bf Note: these all require multiplexing }
262 \begin{itemize}
263 \item Output-Enable (aka Input disable): switches pad to Out or In
264 \item Output (actually an input wire controlling pin's level, HI/LO)
265 \item Input (actually an output wire set based on pin's driven level)
266 \end{itemize}
267 Characteristics: {\bf Note: these do not require multiplexing }
268 \begin{itemize}
269 \item Output current level: 10mA / 20mA / 30mA / 40mA
270 \item Input hysteresis: low / middle / high. Stops signal noise
271 \item Pin characteristics: CMOS Push-Push / Open-Drain
272 \item Pull-up enable: built-in 10k (50k?) resistor
273 \item Pull-down enable: built-in 10k (50k?) resistor
274 \item Muxing and IRQ Edge-detection not part of the I/O pin
275 \item Other? (impedance? not normally part of commercial pinmux)
276 \end{itemize}
277 }
278
279
280 \frame{\frametitle{Standard GPIO 4-way in/out Mux and I/O pad}
281 \begin{center}
282 \includegraphics[height=2.5in]{../shakti/m_class/mygpiomux.jpg}\\
283 {\bf 4-in, 4-out, pullup/down, hysteresis, edge-detection (EINT)}
284 \end{center}
285 }
286
287 \frame{\frametitle{Separating Pin Configuration, input and output}
288
289 \begin{itemize}
290 \item Standard Mux design {\bf cannot deal with many-to-one inputs}\\
291 (SiFive IOF source code from Freedom E310 cannot, either)
292 \vspace{4pt}
293 \item I/O pad configuration conflated with In-Muxer conflated with
294 Out-Muxer conflated with GPIO conflated with EINT.
295 \vspace{4pt}
296 \end{itemize}
297 {\bf IMPORTANT to separate all of these out:
298 \vspace{4pt}}
299 \begin{itemize}
300 \item EINTs to be totally separate FNs. managed by RISC-V PLIC\\
301 (If every GPIO was an EINT it would mean 100+ IRQs)
302 \vspace{4pt}
303 \item GPIO In/Out/Direction treated just like any other FN\\
304 (but happen to have AXI4 - or other - memory-mapping)
305 \vspace{4pt}
306 \item Pad configuration separated and given one-to-one Registers\\
307 (SRAMs set by AXI4 to control mux, pullup, current etc.)
308 \end{itemize}
309 }
310
311 \frame{\frametitle{Register-to-pad "control" settings}
312 \begin{center}
313 \includegraphics[height=2.5in]{reg_gpio_cap_ctrl.jpg}\\
314 {\bf pullup/down, hysteresis, current, edge-detection}
315 \end{center}
316 }
317
318
319 \frame{\frametitle{GPIO (only): Simplified I/O pad Diagram (FN only)}
320 \begin{center}
321 \includegraphics[height=1.3in]{reg_gpio_pinblock.jpg}
322 \end{center}
323 \begin{itemize}
324 \item GPIO In/Out/Direction is just another FN (effectively)
325 \item 3 wires: IN, OUT, OUTEN (=INEN\#)
326 \item FN however may be output-only (UART\_TX), input-only (UART\_RX)
327 or bi-directional (I2C\_SDA) and Bus-controlled.
328 \item GPIO is definitely bi-directional and under Register control
329 \end{itemize}
330 }
331
332
333 \frame{\frametitle{Output Muxer (very simple)}
334 \begin{center}
335 \includegraphics[height=1.1in]{reg_gpio_out_mux.jpg}\\
336 {\bf Output Muxer using 2-bit address selection}\\
337 \end{center}
338 \begin{itemize}
339 \item Very straightforward (deceptively so, like SRAM cells)
340 \item Used in both OUT routing and Direction-control routing\\
341 (same address for each, connected to same FNs)
342 \item More complex pinmux will have 3-bit addressing (8 FNs)\\
343 (Note: not all outputs will be connected, depends on pinmux)
344 \end{itemize}
345 }
346
347
348 \frame{\frametitle{In/Out muxing, direction control: GPIO just a FN}
349 \begin{center}
350 \includegraphics[height=2.5in]{reg_gpio_fn_ctrl.jpg}\\
351 {\bf Note: function can control I/O direction (bus)}
352 \end{center}
353 }
354
355
356 \frame{\frametitle{Direction Control: Function not bi-directional (bus)}
357 \begin{center}
358 \includegraphics[height=2.5in]{reg_gpio_fn_ctrl2.jpg}\\
359 Note: Function {\bf does not} control I/O direction
360 \end{center}
361 }
362
363
364 \frame{\frametitle{Output (and OUTEN) Wiring. 2 pins, 2 GPIO, 2 Fns}
365 \begin{center}
366 \includegraphics[height=2.5in]{reg_gpio_out_wiring.jpg}\\
367 {\bf Reg0 for Pin0, Reg1 for Pin1, Output and OUTEN same mux }
368 \end{center}
369 }
370
371
372 \frame{\frametitle{Input Selection and Priority Muxing}
373 \begin{center}
374 \includegraphics[height=0.75in]{reg_gpio_comparator.jpg}\\
375 {\bf Muxer enables input selection}\\
376 \vspace{10pt}
377 \includegraphics[height=1.25in]{reg_gpio_in_prioritymux.jpg}\\
378 {\bf However multiple inputs must be prioritised }
379 \end{center}
380 }
381
382
383 \frame{\frametitle{Input Priority-Mux Wiring: very different from Out-Mux}
384 \begin{center}
385 \includegraphics[height=2.5in]{reg_gpio_in_wiring.jpg}\\
386 {\bf Pin Mux selection vals NOT same as FN selection vals}
387 \end{center}
388 }
389
390
391 \frame{\frametitle{Input Priority-Mux Wiring}
392
393 \begin{itemize}
394 \item In-Muxer selection number (0,1,2,3) obviously has to match
395 with Out-Muxer order (otherwise a bi-directional FN
396 needs different Mux-register settings for
397 selecting either IN or OUT)
398 \vspace{6pt}
399 \item Priority-mux selection values do not actually matter,
400 and have nothing to do with the actual Muxer settings.
401 \vspace{6pt}
402 \item GPIO FN's input muxer is nothing more than an AND gate\\
403 (you never route more than one pin to one GPIO)
404 \vspace{6pt}
405 \item Any other FN with only 1:1 on its IN also just an AND gate \\
406 (this just always happens to be true for GPIO)
407 \vspace{6pt}
408 \item Not all FNs have input capability: clearly they will not
409 be included in the In-Muxing.
410 \end{itemize}
411 }
412
413
414 \frame{\frametitle{Summary}
415
416 \begin{itemize}
417 \item Value of Libre/Open pimux dramatically underestimated\\
418 (and does not presently exist: SiFive's IOF not suitable as-is)\\
419 {\bf Only current option: license a commercial Pinmux }
420 \item Actual muxing (like SRAM cells) is deceptively simple
421 \item Actual pinmuxes are enormous: auto-generation essential
422 \item HDLs completely unsuited to auto-generation task\\
423 (TRM, docs): {\bf Modern OO language needed i.e. python}
424 \item Scenario Analysis / Verification and auto-generation of
425 different HDLs far easier in a Modern OO language\\
426 (better libraries, more developers)
427 \item Standardisation for RISC-V saves implementors from huge
428 duplication cost (HDL, firmware, docs, maintenance)
429 \item { \bf Ultimately it's about saving money and reducing risk }
430 \end{itemize}
431 }
432
433
434 \frame{
435 \begin{center}
436 {\Huge The end\vspace{20pt}\\
437 Thank you\vspace{20pt}\\
438 Questions?\vspace{20pt}
439 }
440 \end{center}
441
442 \begin{itemize}
443 \item http://libre-riscv.org/shakti/m\_class/pinmux/
444 \end{itemize}
445 }
446
447
448 \end{document}