mirror of https://github.com/YosysHQ/yosys.git
Improvements in CodingReadme
This commit is contained in:
parent
ba48b6b1e6
commit
539dd805f4
33
CodingReadme
33
CodingReadme
|
@ -1,5 +1,10 @@
|
||||||
|
|
||||||
|
This file contains some very brief documentation on things like programming APIs.
|
||||||
|
Also consult the Yosys manual and the section about programming in the presentation.
|
||||||
|
(Both can be downloaded as PDF from the yosys webpage.)
|
||||||
|
|
||||||
|
|
||||||
|
--snip-- only the lines below this mark are included in the yosys manual --snip--
|
||||||
Getting Started
|
Getting Started
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
@ -42,13 +47,21 @@ defined when "kernel/yosys.h" is included and USING_YOSYS_NAMESPACE is used.
|
||||||
1. Yosys Container Classes
|
1. Yosys Container Classes
|
||||||
|
|
||||||
Yosys uses dict<K, T> and pool<T> as main container classes. dict<K, T> is
|
Yosys uses dict<K, T> and pool<T> as main container classes. dict<K, T> is
|
||||||
essentially a replacement for std::unordered_map<K, T> and pool<T> is
|
essentially a replacement for std::unordered_map<K, T> and pool<T> is a
|
||||||
essentially a replacement for std::unordered_set<T>. The main differences are:
|
replacement for std::unordered_set<T>. The main characteristics are:
|
||||||
|
|
||||||
- dict<K, T> and pool<T> are about 2x faster than the std containers
|
- dict<K, T> and pool<T> are about 2x faster than the std containers
|
||||||
|
|
||||||
- references to elements in a dict<K, T> or pool<T> are invalidated by
|
- references to elements in a dict<K, T> or pool<T> are invalidated by
|
||||||
insert operations (just like you are used from std::vector<T>).
|
insert and remove operations (similar to std::vector<T> on push_back()).
|
||||||
|
|
||||||
|
- some iterators are invalidated by erase(). specifically, iterators
|
||||||
|
that have not passed the erased element yet are invalidated. (erase()
|
||||||
|
itself returns valid iterator to the next element.)
|
||||||
|
|
||||||
|
- no iterators are invalidated by insert(). elements are inserted at
|
||||||
|
begin(). i.e. only a new iterator that starts at begin() will see the
|
||||||
|
inserted elements.
|
||||||
|
|
||||||
- dict<K, T> and pool<T> will have the same order of iteration across
|
- dict<K, T> and pool<T> will have the same order of iteration across
|
||||||
all compilers and architectures.
|
all compilers and architectures.
|
||||||
|
@ -97,12 +110,12 @@ namespace.
|
||||||
4. SigMap and other Helper Classes
|
4. SigMap and other Helper Classes
|
||||||
|
|
||||||
There are a couple of additional helper classes that are in wide use
|
There are a couple of additional helper classes that are in wide use
|
||||||
in Yosys. Most importantly there is SigMap (declared in kernel.sigtools.h).
|
in Yosys. Most importantly there is SigMap (declared in kernel/sigtools.h).
|
||||||
|
|
||||||
When a design has many wires in it that are connected to each other, then
|
When a design has many wires in it that are connected to each other, then a
|
||||||
a single signal bit can have multiple valid names. The SigMap object can
|
single signal bit can have multiple valid names. The SigMap object can be used
|
||||||
be used to map SigSpecs or SigBits to unique SigSpecs and SigBits that
|
to map SigSpecs or SigBits to unique SigSpecs and SigBits that consitently
|
||||||
consitently only uses one wire from a group of connected wires. For example:
|
only use one wire from such a group of connected wires. For example:
|
||||||
|
|
||||||
SigBit a = module->addWire(NEW_ID);
|
SigBit a = module->addWire(NEW_ID);
|
||||||
SigBit b = module->addWire(NEW_ID);
|
SigBit b = module->addWire(NEW_ID);
|
||||||
|
@ -162,7 +175,7 @@ C++ Langugage
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Yosys is written in C++11. At the moment only constructs supported by
|
Yosys is written in C++11. At the moment only constructs supported by
|
||||||
gcc 4.6 is allowed in Yosys code. This will change in future releases.
|
gcc 4.6 are allowed in Yosys code. This will change in future releases.
|
||||||
|
|
||||||
In general Yosys uses "int" instead of "size_t". To avoid compiler
|
In general Yosys uses "int" instead of "size_t". To avoid compiler
|
||||||
warnings for implicit type casts, always use "GetSize(foobar)" instead
|
warnings for implicit type casts, always use "GetSize(foobar)" instead
|
||||||
|
@ -171,6 +184,8 @@ of "foobar.size()". (GetSize() is defined in kernel/yosys.h)
|
||||||
Use range-based for loops whenever applicable.
|
Use range-based for loops whenever applicable.
|
||||||
|
|
||||||
|
|
||||||
|
--snap-- only the lines above this mark are included in the yosys manual --snap--
|
||||||
|
|
||||||
|
|
||||||
Creating the Visual Studio Template Project
|
Creating the Visual Studio Template Project
|
||||||
===========================================
|
===========================================
|
||||||
|
|
|
@ -2,16 +2,21 @@
|
||||||
\chapter{Programming Yosys Extensions}
|
\chapter{Programming Yosys Extensions}
|
||||||
\label{chapter:prog}
|
\label{chapter:prog}
|
||||||
|
|
||||||
\begin{fixme}
|
This chapter contains some bits and pieces of information about programming
|
||||||
This chapter will contain a guided tour to the Yosys APIs and conclude
|
yosys extensions. Also consult the section on programming in the ``Yosys
|
||||||
with an example module.
|
Presentation'' (can be downloaded from the Yosys website as PDF) and don't
|
||||||
\end{fixme}
|
be afraid to ask questions on the Yosys Subreddit.
|
||||||
|
|
||||||
\section{Programming with RTLIL}
|
\section{The ``CodingReadme'' File}
|
||||||
\section{Internal Utility Libraries}
|
|
||||||
\section{Loadable Modules}
|
The following is an excerpt of the {\tt CodingReadme} file from the Yosys source tree.
|
||||||
|
|
||||||
|
\lstinputlisting[title=CodingReadme,rangeprefix=--,rangesuffix=--,includerangemarker=false,linerange=snip-snap,numbers=left,frame=single]{../CodingReadme}
|
||||||
|
|
||||||
|
\section{The ``stubsnets'' Example Module}
|
||||||
|
|
||||||
|
The following is the complete code of the ``stubsnets'' example module. It is included in the Yosys source distribution as {\tt manual/CHAPTER\_Prog/stubnets.cc}.
|
||||||
|
|
||||||
\section{Example Module}
|
|
||||||
|
|
||||||
\lstinputlisting[title=stubnets.cc,numbers=left,frame=single,language=C++]{CHAPTER_Prog/stubnets.cc}
|
\lstinputlisting[title=stubnets.cc,numbers=left,frame=single,language=C++]{CHAPTER_Prog/stubnets.cc}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue