<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">

<guide link="index.xml" lang="en">
<title>Test benches</title>
<date>2007-04-20</date>

<author title="Author">
<mail link="calchan@gentoo.org">Denis Dupeyron</mail>
</author>

<abstract>Test benches for all software maintained by the Electronics subproject</abstract>

<chapter>
<title>Help wanted</title>
<body>
<p>
Help us create test benches for the tools we maintain. See <uri link="../todo.xml#doc_chap2">the 'Test benches'
entry in our TODO list</uri>.
</p>
<p>
Instructions on how to test our packages and verify they work properly should get listed below.
Developers, please remember that a non-specialist must be able to execute your test bench. List
packages alphabetically, and store any required additional material in a bz2 tarball in the
same directory as this guide.
</p>
</body>
</chapter>

<chapter>
<title>sci-electronics/gnucap</title>
<body>
<p>
A set of example netlists is available in the source tarball.
You can install them files by emerging Gnucap with USE=examples,
which is what we are going to assume in the following instructions.
Then&nbsp;:
</p>
<pre caption="run the Gnucap examples">
# <i>cd /usr/share/gnucap/examples</i>
# <i>source runall gnucap > ~/gnucap.out</i>
</pre>
<p>
You can compare your gnucap.out to <uri link="gnucap-0.35-output.bz2">this one</uri> and verify your
Gnucap installation works properly. You may get slightly different numerical results in some
instances, this is OK. The convergence algorithms do not always give the exact same results
depending on the architecture.
</p>
</body>
</chapter>

<chapter>
<title>sci-electronics/gtkwave</title>
<body>
<p>
An example is available in the source tarball. You can install its files by emerging
GTKWave with USE=examples, which is what we are going to assume in the following instructions.
You should replace ${PV} with the corresponding number of the version you want to test.
</p>
<pre caption="run the GTKWave example">
# <i>cp -R /usr/share/doc/gtkwave-${PV}/examples .</i>
# <i>cd examples</i>
# <i>vzt2vcd des.vzt > des.vcd</i>
VZTLOAD | 1432 facilities
VZTLOAD | Total value bits: 22921
VZTLOAD | Read 1 block header OK
VZTLOAD | [0] start time
VZTLOAD | [704] end time
VZTLOAD | 
VZTLOAD | block [0] processing 0 / 704
# <i>gtkwave des.vcd</i>
</pre>
<figure link="GTKWave.png" short="GTKWave" caption="an example GTKWave window"/>
<p>
In the SST window (left side, towards the top) navigate down the hierarchy of signals, then drag and
drop a few signals from the 'Signals' window below the SST window, to the other 'Signals' window
just right of SST. Play with signals a bit, zoom in, zoom out, etc...
</p>
</body>
</chapter>

<chapter>
<title>sci-electronics/kicad</title>
<body>
<p>A good number of examples will be installed if you emerge KiCad with USE=examples. Start KiCad from
your desktop environment's main menu (in Gnome its in the Other submenu). In the KiCad main window, you
should then select 'Open&nbsp;Project&nbsp;Descr' (first item in the Project menu), and navigate to
/usr/lib/kicad/demos. The test_xil_95108 and video projects are the most interesting. Enter one of the
demo directories and double-click the .pro file. You can then double-click on the .sch or .brd file in
the left pane of the main window to display either the schematic or the board layout. Play with the
interface a bit, move and add or remove devices, and zoom in or out with the mouse wheel. For the most WOW! effect, be
sure to select the 3D Display feature while in the layout window (in the top menu). A 3D view of your
prototype will come up.
</p>
<figure link="kicad-3D.png" short="kicad 3D" caption="a board layout in 3D"/>
<p>
You can zoom in and out with the mouse wheel, rotate the board by dragging a corner with the left mouse
button, and move it with the arrow keys on your keyboard. There may be some image refresh issues, this is a known
fact.
</p>
</body>
</chapter>

<chapter>
<title>sci-electronics/magic</title>
<body>
<p>
You should download <uri link="magic.tar.bz2">this archive</uri> of a compact low-power VCO I designed.
Actually, it's more current-controlled than voltage-controlled, but I consider this an advantage.  
Then, do the following&nbsp;:</p>
<pre caption="load Calchan's VCO">
# <i>tar xvfj magic.tar.bz2</i>
# <i>cd magic</i>
# <i>magic -w -T SCN3ME_SUBM.30 VCO.mag</i>
</pre>
<p>
Two windows will pop up. One contains the layout itself, and the other is the Magic console.
</p>
<figure link="magic-layout.png" short="magic-layout" caption="the Magic layout window"/>
<p>
You can play with the layout a bit to check that a few simple things work&nbsp;: z for zooming in, Z for
zooming out, v for full view, g to toggle the grid on and off (you may not see the grid if its step is too
tight compared to the resolution of your screen), G to switch to a 2-square grid, etc...
</p>
<figure link="magic-console.png" short="magic-console" caption="the Magic console"/>
<p>
Entering the following commands in the console will enable you to test Magic's extraction capabilities&nbsp;:
</p>
<pre caption="">
# <i>extract</i>
# <i>ext2spice</i>
</pre>
<p>
You will end up with two new files, VCO.ext and VCO.spice, in your working directory. You can compare them
to VCO.ext.orig and VCO.spice.orig from the archive to verify that everything went OK. You do not want to use
diff for the comparison, as Magic doesn't rarely generates devices in the same order. Just make a quick visual
check that the files look the same, devices and pin numbers will differ. Timestamps will differ too.
</p>
</body>
</chapter>

<chapter>
<title>sci-electronics/systemc-2.2_beta20060605</title>
<body>
<p>
A set of examples is available in the source tarball. You need an account at
<uri link="http://www.systemc.org/">the official SystemC website</uri> in order to download it, but
you should have everything handy if you already have SystemC installed. Don't be afraid to register there,
they don't ask for anything special, and they won't spam you.
</p>
<pre caption="run the Gnucap examples">
# <i>tar xvfz /usr/portage/disfiles/systemc-2.2.05jun06.tgz</i>
# <i>cd systemc-2.2.05jun06_beta</i>
# <i>find examples -name 'Makefile.*' -exec sed -i -e 's/-lm/-lm -lpthread/' '{}' \;</i>
# <i>./configure</i>
# <i>cd examples</i>
# <i>make check</i>
</pre>
<p>
This will compile the examples, run them, and check the results. They will run unattended, except for
one that requires you to hit return at some point. You should get a 'PASS' at the end of each test.
</p>
</body>
</chapter>

</guide>
