kernel: TimingInfo to clamp -ve setup/edge-sensitive delays to zero
[yosys.git] / manual / PRESENTATION_Intro.tex
1
2 \section{Introduction to Yosys}
3
4 \begin{frame}
5 \sectionpage
6 \end{frame}
7
8 \iffalse
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10
11 \subsection{Representations of (digital) Circuits}
12
13 \begin{frame}[t]{\subsecname}
14 \begin{itemize}
15 \item Graphical
16 \begin{itemize}
17 \item \alert<1>{Schematic Diagram}
18 \item \alert<2>{Physical Layout}
19 \end{itemize}
20 \bigskip
21 \item Non-graphical
22 \begin{itemize}
23 \item \alert<3>{Netlists}
24 \item \alert<4>{Hardware Description Languages (HDLs)}
25 \end{itemize}
26 \end{itemize}
27 \bigskip
28 \begin{block}{Definition:
29 \only<1>{Schematic Diagram}%
30 \only<2>{Physical Layout}%
31 \only<3>{Netlists}%
32 \only<4>{Hardware Description Languages (HDLs)}}
33 \only<1>{
34 Graphical representation of the circuit topology. Circuit elements
35 are represented by symbols and electrical connections by lines. The geometric
36 layout is for readability only.
37 }%
38 \only<2>{
39 The actual physical geometry of the device (PCB or ASIC manufacturing masks).
40 This is the final product of the design process.
41 }%
42 \only<3>{
43 A list of circuit elements and a list of connections. This is the raw circuit
44 topology.
45 }%
46 \only<4>{
47 Computer languages (like programming languages) that can be used to describe
48 circuits. HDLs are much more powerful in describing huge circuits than
49 schematic diagrams.
50 }%
51 \end{block}
52 \end{frame}
53
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55 \fi
56
57 \subsection{Levels of Abstraction for Digital Circuits}
58
59 \begin{frame}[t]{\subsecname}
60 \begin{itemize}
61 \item \alert<1>{System Level}
62 \item \alert<2>{High Level}
63 \item \alert<3>{Behavioral Level}
64 \item \alert<4>{Register-Transfer Level (RTL)}
65 \item \alert<5>{Logical Gate Level}
66 \item \alert<6>{Physical Gate Level}
67 \item \alert<7>{Switch Level}
68 \end{itemize}
69 \bigskip
70 \begin{block}{Definition:
71 \only<1>{System Level}%
72 \only<2>{High Level}%
73 \only<3>{Behavioral Level}%
74 \only<4>{Register-Transfer Level (RTL)}%
75 \only<5>{Logical Gate Level}%
76 \only<6>{Physical Gate Level}%
77 \only<7>{Switch Level}}
78 \only<1>{
79 Overall view of the circuit. E.g. block-diagrams or instruction-set architecture descriptions.
80 }%
81 \only<2>{
82 Functional implementation of circuit in high-level programming language (C, C++, SystemC, Matlab, Python, etc.).
83 }%
84 \only<3>{
85 Cycle-accurate description of circuit in hardware description language (Verilog, VHDL, etc.).
86 }%
87 \only<4>{
88 List of registers (flip-flops) and logic functions that calculate the next state from the previous one. Usually
89 a netlist utilizing high-level cells such as adders, multipliers, multiplexer, etc.
90 }%
91 \only<5>{
92 Netlist of single-bit registers and basic logic gates (such as AND, OR,
93 NOT, etc.). Popular form: And-Inverter-Graphs (AIGs) with pairs of primary
94 inputs and outputs for each register bit.
95 }%
96 \only<6>{
97 Netlist of cells that actually are available on the target architecture
98 (such as CMOS gates in an ASIC or LUTs in an FPGA). Optimized for
99 area, power, and/or speed (static timing or number of logic levels).
100 }%
101 \only<7>{
102 Netlist of individual transistors.
103 }%
104 \end{block}
105 \end{frame}
106
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108
109 \subsection{Digital Circuit Synthesis}
110
111 \begin{frame}{\subsecname}
112 Synthesis Tools (such as Yosys) can transform HDL code to circuits:
113
114 \bigskip
115 \begin{center}
116 \begin{tikzpicture}[scale=0.8, every node/.style={transform shape}]
117 \tikzstyle{lvl} = [draw, fill=MyBlue, rectangle, minimum height=2em, minimum width=15em]
118 \node[lvl] (sys) {System Level};
119 \node[lvl] (hl) [below of=sys] {High Level};
120 \node[lvl] (beh) [below of=hl] {Behavioral Level};
121 \node[lvl] (rtl) [below of=beh] {Register-Transfer Level (RTL)};
122 \node[lvl] (lg) [below of=rtl] {Logical Gate Level};
123 \node[lvl] (pg) [below of=lg] {Physical Gate Level};
124 \node[lvl] (sw) [below of=pg] {Switch Level};
125
126 \draw[dotted] (sys.east) -- ++(1,0) coordinate (sysx);
127 \draw[dotted] (hl.east) -- ++(1,0) coordinate (hlx);
128 \draw[dotted] (beh.east) -- ++(1,0) coordinate (behx);
129 \draw[dotted] (rtl.east) -- ++(1,0) coordinate (rtlx);
130 \draw[dotted] (lg.east) -- ++(1,0) coordinate (lgx);
131 \draw[dotted] (pg.east) -- ++(1,0) coordinate (pgx);
132 \draw[dotted] (sw.east) -- ++(1,0) coordinate (swx);
133
134 \draw[gray,|->] (sysx) -- node[right] {System Design} (hlx);
135 \draw[|->|] (hlx) -- node[right] {High Level Synthesis (HLS)} (behx);
136 \draw[->|] (behx) -- node[right] {Behavioral Synthesis} (rtlx);
137 \draw[->|] (rtlx) -- node[right] {RTL Synthesis} (lgx);
138 \draw[->|] (lgx) -- node[right] {Logic Synthesis} (pgx);
139 \draw[gray,->|] (pgx) -- node[right] {Cell Library} (swx);
140
141 \draw[dotted] (behx) -- ++(4,0) coordinate (a);
142 \draw[dotted] (pgx) -- ++(4,0) coordinate (b);
143 \draw[|->|] (a) -- node[right] {Yosys} (b);
144 \end{tikzpicture}
145 \end{center}
146 \end{frame}
147
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149
150 \subsection{What Yosys can and can't do}
151
152 \begin{frame}{\subsecname}
153
154 Things Yosys can do:
155 \begin{itemize}
156 \item Read and process (most of) modern Verilog-2005 code.
157 \item Perform all kinds of operations on netlist (RTL, Logic, Gate).
158 \item Perform logic optimizations and gate mapping with ABC\footnote[frame]{\url{http://www.eecs.berkeley.edu/~alanmi/abc/}}.
159 \end{itemize}
160
161 \bigskip
162 Things Yosys can't do:
163 \begin{itemize}
164 \item Process high-level languages such as C/C++/SystemC.
165 \item Create physical layouts (place\&route).
166 \end{itemize}
167
168 \bigskip
169 A typical flow combines Yosys with with a low-level implementation tool, such
170 as Qflow\footnote[frame]{\url{http://opencircuitdesign.com/qflow/}} for ASIC designs.
171
172 \end{frame}
173
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175
176 \subsection{Yosys Data- and Control-Flow}
177
178 \begin{frame}{\subsecname}
179 A (usually short) synthesis script controls Yosys.
180
181 This scripts contain three types of commands:
182 \begin{itemize}
183 \item {\bf Frontends}, that read input files (usually Verilog).
184 \item {\bf Passes}, that perform transformations on the design in memory.
185 \item {\bf Backends}, that write the design in memory to a file (various formats are available: Verilog, BLIF, EDIF, SPICE, BTOR, \dots).
186 \end{itemize}
187
188 \bigskip
189 \begin{center}
190 \begin{tikzpicture}[scale=0.6, every node/.style={transform shape}]
191 \path (-1.5,3) coordinate (cursor);
192 \draw[-latex] ($ (cursor) + (0,-1.5) $) -- ++(1,0);
193 \draw[fill=orange!10] ($ (cursor) + (1,-3) $) rectangle node[rotate=90] {Frontend} ++(1,3) coordinate (cursor);
194 \draw[-latex] ($ (cursor) + (0,-1.5) $) -- ++(1,0);
195 \draw[fill=green!10] ($ (cursor) + (1,-3) $) rectangle node[rotate=90] {Pass} ++(1,3) coordinate (cursor);
196 \draw[-latex] ($ (cursor) + (0,-1.5) $) -- ++(1,0);
197 \draw[fill=green!10] ($ (cursor) + (1,-3) $) rectangle node[rotate=90] {Pass} ++(1,3) coordinate (cursor);
198 \draw[-latex] ($ (cursor) + (0,-1.5) $) -- ++(1,0);
199 \draw[fill=green!10] ($ (cursor) + (1,-3) $) rectangle node[rotate=90] {Pass} ++(1,3) coordinate (cursor);
200 \draw[-latex] ($ (cursor) + (0,-1.5) $) -- ++(1,0);
201 \draw[fill=orange!10] ($ (cursor) + (1,-3) $) rectangle node[rotate=90] {Backend} ++(1,3) coordinate (cursor);
202 \draw[-latex] ($ (cursor) + (0,-1.5) $) -- ++(1,0);
203
204 \path (-3,-0.5) coordinate (cursor);
205 \draw (cursor) -- node[below] {HDL} ++(3,0) coordinate (cursor);
206 \draw[|-|] (cursor) -- node[below] {Internal Format (RTLIL)} ++(8,0) coordinate (cursor);
207 \draw (cursor) -- node[below] {Netlist} ++(3,0);
208
209 \path (-3,3.5) coordinate (cursor);
210 \draw[-] (cursor) -- node[above] {High-Level} ++(3,0) coordinate (cursor);
211 \draw[-] (cursor) -- ++(8,0) coordinate (cursor);
212 \draw[->] (cursor) -- node[above] {Low-Level} ++(3,0);
213 \end{tikzpicture}
214 \end{center}
215 \end{frame}
216
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218
219 \subsection{Program Components and Data Formats}
220
221 \begin{frame}{\subsecname}
222 \begin{center}
223 \begin{tikzpicture}[scale=0.6, every node/.style={transform shape}]
224 \tikzstyle{process} = [draw, fill=green!10, rectangle, minimum height=3em, minimum width=10em, node distance=15em]
225 \tikzstyle{data} = [draw, fill=blue!10, ellipse, minimum height=3em, minimum width=7em, node distance=15em]
226 \node[process] (vlog) {Verilog Frontend};
227 \node[process, dashed, fill=green!5] (vhdl) [right of=vlog] {VHDL Frontend};
228 \node[process] (ilang) [right of=vhdl] {Other Frontends};
229 \node[data] (ast) [below of=vlog, node distance=5em, xshift=7.5em] {AST};
230 \node[process] (astfe) [below of=ast, node distance=5em] {AST Frontend};
231 \node[data] (rtlil) [below of=astfe, node distance=5em, xshift=7.5em] {RTLIL};
232 \node[process] (pass) [right of=rtlil, node distance=5em, xshift=7.5em] {Passes};
233 \node[process] (vlbe) [below of=rtlil, node distance=7em, xshift=-13em] {Verilog Backend};
234 \node[process] (ilangbe) [below of=rtlil, node distance=7em, xshift=0em] {ILANG Backend};
235 \node[process, fill=green!5] (otherbe) [below of=rtlil, node distance=7em, xshift=+13em] {Other Backends};
236
237 \draw[-latex] (vlog) -- (ast);
238 \draw[-latex] (vhdl) -- (ast);
239 \draw[-latex] (ast) -- (astfe);
240 \draw[-latex] (astfe) -- (rtlil);
241 \draw[-latex] (ilang) -- (rtlil);
242 \draw[latex-latex] (rtlil) -- (pass);
243 \draw[-latex] (rtlil) -- (vlbe);
244 \draw[-latex] (rtlil) -- (ilangbe);
245 \draw[-latex] (rtlil) -- (otherbe);
246 \end{tikzpicture}
247 \end{center}
248 \end{frame}
249
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251
252 \subsection{Example Project}
253
254 \begin{frame}[t]{\subsecname}
255 The following slides cover an example project. This project contains three files:
256 \begin{itemize}
257 \item A simple ASIC synthesis script
258 \item A digital design written in Verilog
259 \item A simple CMOS cell library
260 \end{itemize}
261 \vfill
262 Direct link to the files: \\ \footnotesize
263 \url{https://github.com/cliffordwolf/yosys/tree/master/manual/PRESENTATION_Intro}
264 \end{frame}
265
266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
267
268 \begin{frame}[t]{\subsecname{} -- Synthesis Script}
269
270 \setbeamercolor{alerted text}{fg=white,bg=red}
271
272 \begin{minipage}[t]{6cm}
273 \tt\scriptsize
274 {\color{YosysGreen}\# read design}\\
275 \boxalert<1>{read\_verilog counter.v}\\
276 \boxalert<2>{hierarchy -check -top counter}
277
278 \medskip
279 {\color{YosysGreen}\# the high-level stuff}\\
280 \boxalert<3>{proc}; \boxalert<4>{opt}; \boxalert<5>{fsm}; \boxalert<6>{opt}; \boxalert<7>{memory}; \boxalert<8>{opt}
281
282 \medskip
283 {\color{YosysGreen}\# mapping to internal cell library}\\
284 \boxalert<9>{techmap}; \boxalert<10>{opt}
285 \end{minipage}
286 \begin{minipage}[t]{5cm}
287 \tt\scriptsize
288 {\color{YosysGreen}\# mapping flip-flops to mycells.lib}\\
289 \boxalert<11>{dfflibmap -liberty mycells.lib}
290
291 \medskip
292 {\color{YosysGreen}\# mapping logic to mycells.lib}\\
293 \boxalert<12>{abc -liberty mycells.lib}
294
295 \medskip
296 {\color{YosysGreen}\# cleanup}\\
297 \boxalert<13>{clean}
298
299 \medskip
300 {\color{YosysGreen}\# write synthesized design}\\
301 \boxalert<14>{write\_verilog synth.v}
302 \end{minipage}
303
304 \vskip1cm
305
306 \begin{block}{Command: \tt
307 \only<1>{read\_verilog counter.v}%
308 \only<2>{hierarchy -check -top counter}%
309 \only<3>{proc}%
310 \only<4>{opt}%
311 \only<5>{fsm}%
312 \only<6>{opt}%
313 \only<7>{memory}%
314 \only<8>{opt}%
315 \only<9>{techmap}%
316 \only<10>{opt}%
317 \only<11>{dfflibmap -liberty mycells.lib}%
318 \only<12>{abc -liberty mycells.lib}%
319 \only<13>{clean}%
320 \only<14>{write\_verilog synth.v}}
321 \only<1>{
322 Read Verilog source file and convert to internal representation.
323 }%
324 \only<2>{
325 Elaborate the design hierarchy. Should always be the first
326 command after reading the design. Can re-run AST front-end.
327 }%
328 \only<3>{
329 Convert ``processes'' (the internal representation of behavioral
330 Verilog code) into multiplexers and registers.
331 }%
332 \only<4>{
333 Perform some basic optimizations and cleanups.
334 }%
335 \only<5>{
336 Analyze and optimize finite state machines.
337 }%
338 \only<6>{
339 Perform some basic optimizations and cleanups.
340 }%
341 \only<7>{
342 Analyze memories and create circuits to implement them.
343 }%
344 \only<8>{
345 Perform some basic optimizations and cleanups.
346 }%
347 \only<9>{
348 Map coarse-grain RTL cells (adders, etc.) to fine-grain
349 logic gates (AND, OR, NOT, etc.).
350 }%
351 \only<10>{
352 Perform some basic optimizations and cleanups.
353 }%
354 \only<11>{
355 Map registers to available hardware flip-flops.
356 }%
357 \only<12>{
358 Map logic to available hardware gates.
359 }%
360 \only<13>{
361 Clean up the design (just the last step of {\tt opt}).
362 }%
363 \only<14>{
364 Write final synthesis result to output file.
365 }%
366 \end{block}
367
368 \end{frame}
369
370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
371
372 \begin{frame}[fragile]{\subsecname{} -- Verilog Source: \tt counter.v}
373 \lstinputlisting[xleftmargin=1cm, language=Verilog]{PRESENTATION_Intro/counter.v}
374 \end{frame}
375
376 \begin{frame}[fragile]{\subsecname{} -- Cell Library: \tt mycells.lib}
377 \begin{columns}
378 \column[t]{5cm}
379 \lstinputlisting[basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=liberty, lastline=20]{PRESENTATION_Intro/mycells.lib}
380 \column[t]{5cm}
381 \lstinputlisting[basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=liberty, firstline=21]{PRESENTATION_Intro/mycells.lib}
382 \end{columns}
383 \end{frame}
384
385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
386
387 \subsection{Running the Synthesis Script}
388
389 \begin{frame}[t, fragile]{\subsecname{} -- Step 1/4}
390 \begin{verbatim}
391 read_verilog counter.v
392 hierarchy -check -top counter
393 \end{verbatim}
394
395 \vfill
396 \includegraphics[width=\linewidth,trim=0 0cm 0 0cm]{PRESENTATION_Intro/counter_00.pdf}
397 \end{frame}
398
399 \begin{frame}[t, fragile]{\subsecname{} -- Step 2/4}
400 \begin{verbatim}
401 proc; opt; fsm; opt; memory; opt
402 \end{verbatim}
403
404 \vfill
405 \includegraphics[width=\linewidth,trim=0 0cm 0 0cm]{PRESENTATION_Intro/counter_01.pdf}
406 \end{frame}
407
408 \begin{frame}[t, fragile]{\subsecname{} -- Step 3/4}
409 \begin{verbatim}
410 techmap; opt
411 \end{verbatim}
412
413 \vfill
414 \includegraphics[width=\linewidth,trim=0 0cm 0 2cm]{PRESENTATION_Intro/counter_02.pdf}
415 \end{frame}
416
417 \begin{frame}[t, fragile]{\subsecname{} -- Step 4/4}
418 \begin{verbatim}
419 dfflibmap -liberty mycells.lib
420 abc -liberty mycells.lib
421 clean
422 \end{verbatim}
423
424 \vfill\hfil
425 \includegraphics[width=10cm,trim=0 0cm 0 0cm]{PRESENTATION_Intro/counter_03.pdf}
426 \end{frame}
427
428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429
430 \subsection{The synth command}
431
432 \begin{frame}[fragile]{\subsecname{}}
433 Yosys contains a default (recommended example) synthesis script in form of the
434 {\tt synth} command. The following commands are executed by this synthesis command:
435
436 \begin{columns}
437 \column[t]{5cm}
438 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
439 begin:
440 hierarchy -check [-top <top>]
441
442 coarse:
443 proc
444 opt
445 wreduce
446 alumacc
447 share
448 opt
449 fsm
450 opt -fast
451 memory -nomap
452 opt_clean
453 \end{lstlisting}
454 \column[t]{5cm}
455 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
456 fine:
457 opt -fast -full
458 memory_map
459 opt -full
460 techmap
461 opt -fast
462
463 abc:
464 abc -fast
465 opt -fast
466 \end{lstlisting}
467 \end{columns}
468 \end{frame}
469
470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
471
472 \subsection{Yosys Commands}
473
474 \begin{frame}[fragile]{\subsecname{} 1/3 \hspace{0pt plus 1 filll} (excerpt)}
475 Command reference:
476 \begin{itemize}
477 \item Use ``{\tt help}'' for a command list and ``{\tt help \it command}'' for details.
478 \item Or run ``{\tt yosys -H}'' or ``{\tt yosys -h \it command}''.
479 \item Or go to \url{http://www.clifford.at/yosys/documentation.html}.
480 \end{itemize}
481
482 \bigskip
483 Commands for design navigation and investigation:
484 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
485 cd # a shortcut for 'select -module <name>'
486 ls # list modules or objects in modules
487 dump # print parts of the design in ilang format
488 show # generate schematics using graphviz
489 select # modify and view the list of selected objects
490 \end{lstlisting}
491
492 \bigskip
493 Commands for executing scripts or entering interactive mode:
494 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
495 shell # enter interactive command mode
496 history # show last interactive commands
497 script # execute commands from script file
498 tcl # execute a TCL script file
499 \end{lstlisting}
500 \end{frame}
501
502 \begin{frame}[fragile]{\subsecname{} 2/3 \hspace{0pt plus 1 filll} (excerpt)}
503 Commands for reading and elaborating the design:
504 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
505 read_ilang # read modules from ilang file
506 read_verilog # read modules from Verilog file
507 hierarchy # check, expand and clean up design hierarchy
508 \end{lstlisting}
509
510 \bigskip
511 Commands for high-level synthesis:
512 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
513 proc # translate processes to netlists
514 fsm # extract and optimize finite state machines
515 memory # translate memories to basic cells
516 opt # perform simple optimizations
517 \end{lstlisting}
518
519 \bigskip
520 Commands for technology mapping:
521 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
522 techmap # generic technology mapper
523 abc # use ABC for technology mapping
524 dfflibmap # technology mapping of flip-flops
525 hilomap # technology mapping of constant hi- and/or lo-drivers
526 iopadmap # technology mapping of i/o pads (or buffers)
527 flatten # flatten design
528 \end{lstlisting}
529 \end{frame}
530
531 \begin{frame}[fragile]{\subsecname{} 3/3 \hspace{0pt plus 1 filll} (excerpt)}
532 Commands for writing the results:
533 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
534 write_blif # write design to BLIF file
535 write_btor # write design to BTOR file
536 write_edif # write design to EDIF netlist file
537 write_ilang # write design to ilang file
538 write_spice # write design to SPICE netlist file
539 write_verilog # write design to Verilog file
540 \end{lstlisting}
541
542 \bigskip
543 Script-Commands for standard synthesis tasks:
544 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
545 synth # generic synthesis script
546 synth_xilinx # synthesis for Xilinx FPGAs
547 \end{lstlisting}
548
549 \bigskip
550 Commands for model checking:
551 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=ys]
552 sat # solve a SAT problem in the circuit
553 miter # automatically create a miter circuit
554 scc # detect strongly connected components (logic loops)
555 \end{lstlisting}
556
557 \bigskip
558 ... and many many more.
559 \end{frame}
560
561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562
563 \subsection{More Verilog Examples}
564
565 \begin{frame}[fragile]{\subsecname{} 1/3}
566 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=Verilog]
567 module detectprime(a, y);
568 input [4:0] a;
569 output y;
570
571 integer i, j;
572 reg [31:0] lut;
573
574 initial begin
575 for (i = 0; i < 32; i = i+1) begin
576 lut[i] = i > 1;
577 for (j = 2; j*j <= i; j = j+1)
578 if (i % j == 0)
579 lut[i] = 0;
580 end
581 end
582
583 assign y = lut[a];
584 endmodule
585 \end{lstlisting}
586 \end{frame}
587
588 \begin{frame}[fragile]{\subsecname{} 2/3}
589 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=Verilog]
590 module carryadd(a, b, y);
591 parameter WIDTH = 8;
592 input [WIDTH-1:0] a, b;
593 output [WIDTH-1:0] y;
594
595 genvar i;
596 generate
597 for (i = 0; i < WIDTH; i = i+1) begin:STAGE
598 wire IN1 = a[i], IN2 = b[i];
599 wire C, Y;
600 if (i == 0)
601 assign C = IN1 & IN2, Y = IN1 ^ IN2;
602 else
603 assign C = (IN1 & IN2) | ((IN1 | IN2) & STAGE[i-1].C),
604 Y = IN1 ^ IN2 ^ STAGE[i-1].C;
605 assign y[i] = Y;
606 end
607 endgenerate
608 endmodule
609 \end{lstlisting}
610 \end{frame}
611
612 \begin{frame}[fragile]{\subsecname{} 3/3}
613 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{7pt}{8.5pt}\selectfont, language=Verilog]
614 module cam(clk, wr_enable, wr_addr, wr_data, rd_data, rd_addr, rd_match);
615 parameter WIDTH = 8;
616 parameter DEPTH = 16;
617 localparam ADDR_BITS = $clog2(DEPTH-1);
618
619 input clk, wr_enable;
620 input [ADDR_BITS-1:0] wr_addr;
621 input [WIDTH-1:0] wr_data, rd_data;
622 output reg [ADDR_BITS-1:0] rd_addr;
623 output reg rd_match;
624
625 integer i;
626 reg [WIDTH-1:0] mem [0:DEPTH-1];
627
628 always @(posedge clk) begin
629 rd_addr <= 'bx;
630 rd_match <= 0;
631 for (i = 0; i < DEPTH; i = i+1)
632 if (mem[i] == rd_data) begin
633 rd_addr <= i;
634 rd_match <= 1;
635 end
636 if (wr_enable)
637 mem[wr_addr] <= wr_data;
638 end
639 endmodule
640 \end{lstlisting}
641 \end{frame}
642
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644
645 \subsection{Currently unsupported Verilog-2005 language features}
646
647 \begin{frame}{\subsecname}
648 \begin{itemize}
649 \item Tri-state logic
650 \item The wor/wand wire types (maybe for 0.5)
651 \item Latched logic (is synthesized as logic with feedback loops)
652 \item Some non-synthesizable features that should be ignored in synthesis are not supported by the parser and cause a parser error (file a bug report if you encounter this problem)
653 \end{itemize}
654 \end{frame}
655
656 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
657
658 \subsection{Verification of Yosys}
659
660 \begin{frame}{\subsecname}
661 Continuously checking the correctness of Yosys and making sure that new features
662 do not break old ones is a high priority in Yosys.
663
664 \bigskip
665 Two external test suites have been built for Yosys: VlogHammer and yosys-bigsim
666 (see next slides)
667
668 \bigskip
669 In addition to that, yosys comes with $\approx\!200$ test cases used in ``{\tt make test}''.
670
671 \bigskip
672 A debug build of Yosys also contains a lot of asserts and checks the integrity of
673 the internal state after each command.
674 \end{frame}
675
676 \begin{frame}[fragile]{\subsecname{} -- VlogHammer}
677 VlogHammer is a Verilog regression test suite developed to test the different
678 subsystems in Yosys by comparing them to each other and to the output created
679 by some other tools (Xilinx Vivado, Xilinx XST, Altera Quartus II, ...).
680
681 \bigskip
682 Yosys Subsystems tested: Verilog frontend, const folding, const eval, technology mapping,
683 simulation models, SAT models.
684
685 \bigskip
686 Thousands of auto-generated test cases containing code such as:
687 \begin{lstlisting}[xleftmargin=1cm, basicstyle=\ttfamily\fontsize{8pt}{10pt}\selectfont, language=Verilog]
688 assign y9 = $signed(((+$signed((^(6'd2 ** a2))))<$unsigned($unsigned(((+a3))))));
689 assign y10 = (-((+((+{2{(~^p13)}})))^~(!{{b5,b1,a0},(a1&p12),(a4+a3)})));
690 assign y11 = (~&(-{(-3'sd3),($unsigned($signed($unsigned({p0,b4,b1}))))}));
691 \end{lstlisting}
692
693 \bigskip
694 Some bugs in Yosys where found and fixed thanks to VlogHammer. Over 50 bugs in
695 the other tools used as external reference where found and reported so far.
696 \end{frame}
697
698 \begin{frame}{\subsecname{} -- yosys-bigsim}
699 yosys-bigsim is a collection of real-world open-source Verilog designs and test
700 benches. yosys-bigsim compares the testbench outputs of simulations of the original
701 Verilog code and synthesis results.
702
703 \bigskip
704 The following designs are included in yosys-bigsim (excerpt):
705 \begin{itemize}
706 \item {\tt openmsp430} -- an MSP430 compatible 16 bit CPU
707 \item {\tt aes\_5cycle\_2stage} -- an AES encryption core
708 \item {\tt softusb\_navre} -- an AVR compatible 8 bit CPU
709 \item {\tt amber23} -- an ARMv2 compatible 32 bit CPU
710 \item {\tt lm32} -- another 32 bit CPU from Lattice Semiconductor
711 \item {\tt verilog-pong} -- a hardware pong game with VGA output
712 \item {\tt elliptic\_curve\_group} -- ECG point-add and point-scalar-mul core
713 \item {\tt reed\_solomon\_decoder} -- a Reed-Solomon Error Correction Decoder
714 \end{itemize}
715 \end{frame}
716
717 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
718
719 \subsection{Benefits of Open Source HDL Synthesis}
720
721 \begin{frame}{\subsecname}
722 \begin{itemize}
723 \item Cost (also applies to ``free as in free beer'' solutions)
724 \item Availability and Reproducibility
725 \item Framework- and all-in-one-aspects
726 \item Educational Tool
727 \end{itemize}
728
729 \bigskip
730
731 Yosys is open source under the ISC license.
732 \end{frame}
733
734 \begin{frame}{\subsecname{} -- 1/3}
735 \begin{itemize}
736 \item Cost (also applies to ``free as in free beer'' solutions): \smallskip\par
737 Today the cost for a mask set in $\unit[180]{nm}$ technology is far less than
738 the cost for the design tools needed to design the mask layouts. Open Source
739 ASIC flows are an important enabler for ASIC-level Open Source Hardware.
740
741 \bigskip
742 \item Availability and Reproducibility: \smallskip\par
743 If you are a researcher who is publishing, you want to use tools that everyone
744 else can also use. Even if most universities have access to all major
745 commercial tools, you usually do not have easy access to the version that was
746 used in a research project a couple of years ago. With Open Source tools you
747 can even release the source code of the tool you have used alongside your data.
748 \end{itemize}
749 \end{frame}
750
751 \begin{frame}{\subsecname{} -- 2/3}
752 \begin{itemize}
753 \item Framework: \smallskip\par
754 Yosys is not only a tool. It is a framework that can be used as basis for other
755 developments, so researchers and hackers alike do not need to re-invent the
756 basic functionality. Extensibility was one of Yosys' design goals.
757
758 \bigskip
759 \item All-in-one: \smallskip\par
760 Because of the framework characteristics of Yosys, an increasing number of features
761 become available in one tool. Yosys not only can be used for circuit synthesis but
762 also for formal equivalence checking, SAT solving, and for circuit analysis, to
763 name just a few other application domains. With proprietary software one needs to
764 learn a new tool for each of these applications.
765 \end{itemize}
766 \end{frame}
767
768 \begin{frame}{\subsecname{} -- 3/3}
769 \begin{itemize}
770 \item Educational Tool: \smallskip\par
771 Proprietary synthesis tools are at times very secretive about their inner
772 workings. They often are ``black boxes''. Yosys is very open about its
773 internals and it is easy to observe the different steps of synthesis.
774 \end{itemize}
775
776 \bigskip
777 \begin{block}{Yosys is licensed under the ISC license:}
778 Permission to use, copy, modify, and/or distribute this software for any
779 purpose with or without fee is hereby granted, provided that the above
780 copyright notice and this permission notice appear in all copies.
781 \end{block}
782 \end{frame}
783
784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785
786 \subsection{Typical Applications for Yosys}
787
788 \begin{frame}{\subsecname}
789 \begin{itemize}
790 \item Synthesis of final production designs
791 \item Pre-production synthesis (trial runs before investing in other tools)
792 \item Conversion of full-featured Verilog to simple Verilog
793 \item Conversion of Verilog to other formats (BLIF, BTOR, etc)
794 \item Demonstrating synthesis algorithms (e.g. for educational purposes)
795 \item Framework for experimenting with new algorithms
796 \item Framework for building custom flows\footnote[frame]{Not limited to synthesis
797 but also formal verification, reverse engineering, ...}
798 \end{itemize}
799 \end{frame}
800
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802
803 \subsection{Projects (that I know of) using Yosys}
804
805 \begin{frame}{\subsecname{} -- (1/2)}
806 \begin{itemize}
807 \item Ongoing PhD project on coarse grain synthesis \\
808 {\setlength{\parindent}{0.5cm}\footnotesize
809 Johann Glaser and Clifford Wolf. Methodology and Example-Driven Interconnect
810 Synthesis for Designing Heterogeneous Coarse-Grain Reconfigurable
811 Architectures. In Jan Haase, editor, \it Models, Methods, and Tools for Complex
812 Chip Design. Lecture Notes in Electrical Engineering. Volume 265, 2014, pp
813 201-221. Springer, 2013.}
814
815 \bigskip
816 \item I know several people that use Yosys simply as Verilog frontend for other
817 flows (using either the BLIF and BTOR backends).
818
819 \bigskip
820 \item I know some analog chip designers that use Yosys for small digital
821 control logic because it is simpler than setting up a commercial flow.
822 \end{itemize}
823 \end{frame}
824
825 \begin{frame}{\subsecname{} -- (2/2)}
826 \begin{itemize}
827 \item Efabless
828 \begin{itemize}
829 \smallskip \item Not much information on the website (\url{http://efabless.com}) yet.
830 \smallskip \item Very cheap 180nm prototyping process (partnering with various fabs)
831 \smallskip \item A semiconductor company, NOT an EDA company
832 \smallskip \item Web-based design environment
833 \smallskip \item HDL Synthesis using Yosys
834 \smallskip \item Custom place\&route tool
835
836 \bigskip
837 \item efabless is building an Open Source IC as reference design. \\
838 \hskip1cm (to be announced soon: \url{http://www.openic.io})
839 \end{itemize}
840 \end{itemize}
841 \end{frame}
842
843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
844
845 \subsection{Supported Platforms}
846
847 \begin{frame}{\subsecname}
848 \begin{itemize}
849 \item Main development OS: Kubuntu 14.04
850 \item There is a PPA for ubuntu (not maintained by me)
851 \item Any current Debian-based system should work out of the box
852 \item When building on other Linux distributions:
853 \begin{itemize}
854 \item Needs compiler with some C++11 support
855 \item See README file for build instructions
856 \item Post to the subreddit if you get stuck
857 \end{itemize}
858 \item Ported to OS X (Darwin) and OpenBSD
859 \item Native win32 build with VisualStudio
860 \item Cross win32 build with MXE
861 \end{itemize}
862 \end{frame}
863
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
865
866 \subsection{Other Open Source Tools}
867
868 \begin{frame}{\subsecname}
869 \begin{itemize}
870 \item Icarus Verilog \\
871 \smallskip\hskip1cm{}Verilog Simulation (and also a good syntax checker) \\
872 \smallskip\hskip1cm{}\url{http://iverilog.icarus.com/}
873
874 \bigskip
875 \item Qflow (incl. TimberWolf, qrouter and Magic) \\
876 \smallskip\hskip1cm{}A complete ASIC synthesis flow, using Yosys and ABC \\
877 \smallskip\hskip1cm{}\url{http://opencircuitdesign.com/qflow/}
878
879 \bigskip
880 \item ABC \\
881 \smallskip\hskip1cm{}Logic optimization, technology mapping, and more \\
882 \smallskip\hskip1cm{}\url{http://www.eecs.berkeley.edu/~alanmi/abc/}
883 \end{itemize}
884 \end{frame}
885
886 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
887
888 \subsection{Yosys needs you}
889
890 \begin{frame}{\subsecname}
891 \dots as an active user:
892 \begin{itemize}
893 \item Use Yosys for on your own projects
894 \item .. even if you are not using it as final synthesis tool
895 \item Join the discussion on the Subreddit
896 \item Report bugs and send in feature requests
897 \end{itemize}
898
899 \bigskip
900 \dots as a developer:
901 \begin{itemize}
902 \item Use Yosys as environment for your (research) work
903 \item .. you might also want to look into ABC for logic-level stuff
904 \item Fork the project on github or create loadable plugins
905 \item We need a VHDL frontend or a good VHDL-to-Verilog converter
906 \end{itemize}
907 \end{frame}
908
909 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
910
911 \subsection{Documentation, Downloads, Contacts}
912
913 \begin{frame}{\subsecname}
914 \begin{itemize}
915 \item Website: \\
916 \smallskip\hskip1cm\url{http://www.clifford.at/yosys/}
917
918 \bigskip
919 \item Manual, Command Reference, Application Notes: \\
920 \smallskip\hskip1cm\url{http://www.clifford.at/yosys/documentation.html}
921
922 \bigskip
923 \item Instead of a mailing list we have a SubReddit: \\
924 \smallskip\hskip1cm\url{http://www.reddit.com/r/yosys/}
925
926 \bigskip
927 \item Direct link to the source code: \\
928 \smallskip\hskip1cm\url{https://github.com/cliffordwolf/yosys}
929 \end{itemize}
930 \end{frame}
931
932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
933
934 \subsection{Summary}
935
936 \begin{frame}{\subsecname}
937 \begin{itemize}
938 \item Yosys is a powerful tool and framework for Verilog synthesis.
939 \item It uses a command-based interface and can be controlled by scripts.
940 \item By combining existing commands and implementing new commands Yosys can
941 be used in a wide range of application far beyond simple synthesis.
942 \end{itemize}
943
944 \bigskip
945 \bigskip
946 \begin{center}
947 Questions?
948 \end{center}
949
950 \bigskip
951 \bigskip
952 \begin{center}
953 \url{http://www.clifford.at/yosys/}
954 \end{center}
955 \end{frame}
956