<!DOCTYPE html>
<html lang='en'>
<head>
<title>openwrt/upstream - upstream openwrt</title>
<meta name='generator' content='cgit v1.2.3'/>
<meta name='robots' content='index, nofollow'/>
<link rel='stylesheet' type='text/css' href='/cgit.css'/>
<link rel='shortcut icon' href='/favicon.ico'/>
<link rel='alternate' title='Atom feed' href='http://git.panaceas.org/cgit.cgi/openwrt/upstream/atom/tools/lzma-old?h=master' type='application/atom+xml'/>
<link rel='vcs-git' href='git://git.panaceas.org/openwrt/upstream' title='openwrt/upstream Git repository'/>
<link rel='vcs-git' href='ssh://git@git.panaceas.org/git/openwrt/upstream' title='openwrt/upstream Git repository'/>
</head>
<body>
<div id='cgit'><table id='header'>
<tr>
<td class='logo' rowspan='2'><a href='/cgit.cgi/'><img src='/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/cgit.cgi/'>index</a> : <a title='openwrt/upstream' href='/cgit.cgi/openwrt/upstream/'>openwrt/upstream</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='c0561a42e758e0373354b4bd25341a40343a226d'/><select name='h' onchange='this.form.submit();'>
<option value='attitude_adjustment'>attitude_adjustment</option>
<option value='barrier_breaker'>barrier_breaker</option>
<option value='chaos_calmer'>chaos_calmer</option>
<option value='lede-17.01'>lede-17.01</option>
<option value='less-old-master'>less-old-master</option>
<option value='master' selected='selected'>master</option>
<option value='old-master'>old-master</option>
<option value='openwrt-18.06'>openwrt-18.06</option>
<option value='openwrt-19.07'>openwrt-19.07</option>
<option value='upstream'>upstream</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>upstream openwrt</td><td class='sub right'>James</td></tr></table>
<table class='tabs'><tr><td>
<a href='/cgit.cgi/openwrt/upstream/about/'>about</a><a href='/cgit.cgi/openwrt/upstream/'>summary</a><a href='/cgit.cgi/openwrt/upstream/refs/?id=c0561a42e758e0373354b4bd25341a40343a226d'>refs</a><a href='/cgit.cgi/openwrt/upstream/log/tools/lzma-old'>log</a><a href='/cgit.cgi/openwrt/upstream/tree/tools/lzma-old?id=c0561a42e758e0373354b4bd25341a40343a226d'>tree</a><a href='/cgit.cgi/openwrt/upstream/commit/tools/lzma-old?id=c0561a42e758e0373354b4bd25341a40343a226d'>commit</a><a class='active' href='/cgit.cgi/openwrt/upstream/diff/tools/lzma-old?id=c0561a42e758e0373354b4bd25341a40343a226d'>diff</a><a href='/cgit.cgi/openwrt/upstream/stats/tools/lzma-old'>stats</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/openwrt/upstream/log/tools/lzma-old'>
<input type='hidden' name='id' value='c0561a42e758e0373354b4bd25341a40343a226d'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/openwrt/upstream/diff/?id=c0561a42e758e0373354b4bd25341a40343a226d'>root</a>/<a href='/cgit.cgi/openwrt/upstream/diff/tools?id=c0561a42e758e0373354b4bd25341a40343a226d'>tools</a>/<a href='/cgit.cgi/openwrt/upstream/diff/tools/lzma-old?id=c0561a42e758e0373354b4bd25341a40343a226d'>lzma-old</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='c0561a42e758e0373354b4bd25341a40343a226d'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><div class='diffstat-header'><a href='/cgit.cgi/openwrt/upstream/diff/?id=c0561a42e758e0373354b4bd25341a40343a226d'>Diffstat</a> (limited to 'tools/lzma-old')</div><table summary='diffstat' class='diffstat'></table><div class='diffstat-summary'>0 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td></td></tr></table></div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2025-12-07 01:48:23 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
n72' href='#n72'>72</a>
<a id='n73' href='#n73'>73</a>
<a id='n74' href='#n74'>74</a>
<a id='n75' href='#n75'>75</a>
<a id='n76' href='#n76'>76</a>
<a id='n77' href='#n77'>77</a>
<a id='n78' href='#n78'>78</a>
<a id='n79' href='#n79'>79</a>
<a id='n80' href='#n80'>80</a>
<a id='n81' href='#n81'>81</a>
<a id='n82' href='#n82'>82</a>
<a id='n83' href='#n83'>83</a>
<a id='n84' href='#n84'>84</a>
<a id='n85' href='#n85'>85</a>
<a id='n86' href='#n86'>86</a>
<a id='n87' href='#n87'>87</a>
<a id='n88' href='#n88'>88</a>
<a id='n89' href='#n89'>89</a>
<a id='n90' href='#n90'>90</a>
<a id='n91' href='#n91'>91</a>
<a id='n92' href='#n92'>92</a>
<a id='n93' href='#n93'>93</a>
<a id='n94' href='#n94'>94</a>
<a id='n95' href='#n95'>95</a>
<a id='n96' href='#n96'>96</a>
<a id='n97' href='#n97'>97</a>
<a id='n98' href='#n98'>98</a>
</pre></td>
<td class='lines'><pre><code><style>pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="k">\chapter</span><span class="nb">{</span>Introduction<span class="nb">}</span>
<span class="k">\label</span><span class="nb">{</span>chapter:intro<span class="nb">}</span>

This document presents the Free and Open Source (FOSS) Verilog HDL synthesis tool ``Yosys&#39;&#39;.
Its design and implementation as well as its performance on real-world designs
is discussed in this document.

<span class="k">\section</span><span class="nb">{</span>History of Yosys<span class="nb">}</span>

A Hardware Description Language (HDL) is a computer language used to describe
circuits. A HDL synthesis tool is a computer program that takes a formal
description of a circuit written in an HDL as input and generates a netlist
that implements the given circuit as output.

Currently the most widely used and supported HDLs for digital circuits are
Verilog <span class="k">\cite</span><span class="nb">{</span>Verilog2005<span class="nb">}</span><span class="k">\cite</span><span class="nb">{</span>VerilogSynth<span class="nb">}</span> and
VHDL<span class="k">\footnote</span><span class="nb">{</span>VHDL is an acronym for ``VHSIC hardware description language&#39;&#39;
and VHSIC is an acronym for ``Very-High-Speed Integrated
Circuits&#39;&#39;.<span class="nb">}</span> <span class="k">\cite</span><span class="nb">{</span>VHDL<span class="nb">}</span><span class="k">\cite</span><span class="nb">{</span>VHDLSynth<span class="nb">}</span>.
Both HDLs are used for test and verification purposes as well as logic
synthesis, resulting in a set of synthesizable and a set of non-synthesizable
language features. In this document we only look at the synthesizable subset
of the language features.

In recent work on heterogeneous coarse-grain reconfigurable
logic <span class="k">\cite</span><span class="nb">{</span>intersynth<span class="nb">}</span> the need for a custom application-specific HDL synthesis
tool emerged. It was soon realised that a synthesis tool that understood Verilog
or VHDL would be preferred over a synthesis tool for a custom HDL. Given an
existing Verilog or VHDL front end, the work for writing the necessary
additional features and integrating them in an existing tool can be estimated to be
about the same as writing a new tool with support for a minimalistic custom HDL.

The proposed custom HDL synthesis tool should be licensed under a Free
and Open Source Software (FOSS) licence. So an existing FOSS Verilog or VHDL
synthesis tool would have been needed as basis to build upon. The main advantages
of choosing Verilog or VHDL is the ability to synthesize existing HDL code and
to mitigate the requirement for circuit-designers to learn a new language. In order to take full advantage of any existing FOSS Verilog or VHDL tool,
such a tool would have to provide a feature-complete implementation of the
synthesizable HDL subset.

Basic RTL synthesis is a well understood field <span class="k">\cite</span><span class="nb">{</span>LogicSynthesis<span class="nb">}</span>. Lexing,
parsing and processing of computer languages <span class="k">\cite</span><span class="nb">{</span>Dragonbook<span class="nb">}</span> is a thoroughly
researched field. All the information required to write such tools has been openly
available for a long time, and it is therefore likely that a FOSS HDL synthesis tool
with a feature-complete Verilog or VHDL front end must exist which can be used as a basis for a custom RTL synthesis tool.

Due to the author&#39;s preference for Verilog over VHDL it was decided early
on to go for Verilog instead of VHDL<span class="k">\footnote</span><span class="nb">{</span>A quick investigation into FOSS
VHDL tools yielded similar grim results for FOSS VHDL synthesis tools.<span class="nb">}</span>.
So the existing FOSS Verilog synthesis tools were evaluated (see
App.~<span class="k">\ref</span><span class="nb">{</span>chapter:sota<span class="nb">}</span>).  The results of this evaluation are utterly
devastating. Therefore a completely new Verilog synthesis tool was implemented
and is recommended as basis for custom synthesis tools. This is the tool that
is discussed in this document.

<span class="k">\section</span><span class="nb">{</span>Structure of this Document<span class="nb">}</span>

The structure of this document is as follows:

Chapter~<span class="k">\ref</span><span class="nb">{</span>chapter:intro<span class="nb">}</span> is this introduction.

Chapter~<span class="k">\ref</span><span class="nb">{</span>chapter:basics<span class="nb">}</span> covers a short introduction to the world of HDL
synthesis. Basic principles and the terminology are outlined in this chapter.

Chapter~<span class="k">\ref</span><span class="nb">{</span>chapter:approach<span class="nb">}</span> gives the quickest possible outline to how the
problem of implementing a HDL synthesis tool is approached in the case of
Yosys.

Chapter~<span class="k">\ref</span><span class="nb">{</span>chapter:overview<span class="nb">}</span> contains a more detailed overview of the
implementation of Yosys. This chapter covers the data structures used in
Yosys to represent a design in detail and is therefore recommended reading
for everyone who is interested in understanding the Yosys internals.

Chapter~<span class="k">\ref</span><span class="nb">{</span>chapter:celllib<span class="nb">}</span> covers the internal cell library used by Yosys.
This is especially important knowledge for anyone who wants to understand the
intermediate netlists used internally by Yosys.

Chapter~ <span class="k">\ref</span><span class="nb">{</span>chapter:prog<span class="nb">}</span> gives a tour to the internal APIs of Yosys. This
is recommended reading for everyone who actually wants to read or write
Yosys source code. The chapter concludes with an example loadable module
for Yosys.

Chapters~<span class="k">\ref</span><span class="nb">{</span>chapter:verilog<span class="nb">}</span>, <span class="k">\ref</span><span class="nb">{</span>chapter:opt<span class="nb">}</span>, and <span class="k">\ref</span><span class="nb">{</span>chapter:techmap<span class="nb">}</span>
cover three important pieces of the synthesis pipeline: The Verilog frontend,
the optimization passes and the technology mapping to the target architecture,
respectively.

Chapter~<span class="k">\ref</span><span class="nb">{</span>chapter:eval<span class="nb">}</span> covers the evaluation of the performance
(correctness and quality) of Yosys on real-world input data.
The chapter concludes the main part of this document with conclusions and
outlook to future work.

Various appendices, including a command reference manual
(App.~<span class="k">\ref</span><span class="nb">{</span>commandref<span class="nb">}</span>) and an evaluation of pre-existing FOSS Verilog
synthesis tools (App.~<span class="k">\ref</span><span class="nb">{</span>chapter:sota<span class="nb">}</span>) complete this document.
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2025-12-07 01:48:24 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
