<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>George Frazier Blog</title><link>http://www.cadence.com/Community/search/SearchResults.aspx?&amp;u=45941&amp;un=georgef&amp;Scope=Blogs</link><description>Search results by user ID 45941</description><dc:language>en-US</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/cadence/community/blogs/45941" /><feedburner:info uri="cadence/community/blogs/45941" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>Search results by user ID 45941</itunes:subtitle><item><title>Speeding up SystemC compilation with Incisive SystemC</title><link>http://feedproxy.google.com/~r/cadence/community/blogs/45941/~3/O4k6UCWw3yk/speeding-up-systemc-compilation-with-incisive-systemc.aspx</link><pubDate>Fri, 19 Jun 2009 13:00:00 GMT</pubDate><guid isPermaLink="false">75bcbcf9-38a3-4e2e-b84b-26c8c46a9500:18568</guid><dc:creator>georgef</dc:creator><description>&lt;p&gt;
If you&amp;rsquo;re a C++ and &lt;a href="http://www.systemc.org/home" target="_blank"&gt;SystemC&lt;/a&gt; programmer you know that when you&amp;rsquo;ve spent all day tracking down a nasty bug, nothing can bum your trip more than having to wait around for a long recompile. Compile time is a bottleneck for SystemC development. Long compile times can come as a particular surprise for HDL programmers who aren&amp;rsquo;t used to the lag time caused by template instantiation, dependency checking, and the mysterious thinking that goes on the in the guts of g++ as it creates object code from source.
&lt;/p&gt;
&lt;p&gt;
Incisive SystemC offers three tool-based methodologies for easing the burden of long compile times: precompiled headers, &lt;font face="Courier New"&gt;catcxx&lt;/font&gt;, and &lt;font face="Courier New"&gt;distcomp&lt;/font&gt;. We&amp;rsquo;ll explore all three in this posting.
&lt;/p&gt;
&lt;p&gt;
Precompiled headers can dramatically speed up compilation for some projects. There are two ways to gain the advantages of precompiled headers in NC-SC. One is free (if you are using GCC 4.1 &amp;ndash; GCC 3.2.3 does not support precompiled headers). By default, &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt;, irun, and the example makefiles get the main SystemC and SCV header files from a special directory that contains precompiled versions. In many cases, this speeds up compilation from 10 to 40%.
&lt;/p&gt;
&lt;p&gt;
If you&amp;rsquo;re working with your own Makefiles you can still use the precompiled versions of the SystemC headers. Just keep the following rules in mind. A precompiled header is either a file or directory that exists in the same directory as the base header file and contains the suffix .gch. So, systemc_h.h.gch is a precompiled header version of systemc_h.h. Your source files that include either systemc.h, systemc, scv.h, and so on, as the very first line can use the precompiled version with the following caveats:
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
Only one precompiled header can be used in a particular compilation.
&lt;/li&gt;&lt;li&gt;
A precompiled header cannot be used once the first C token is seen. You can have preprocessor directives before a precompiled header; you can even include a precompiled header from inside another header, as long as there are no C tokens before the #include.
&lt;/li&gt;&lt;li&gt;
The precompiled header file must be produced for the same language as the current compilation. You cannot use a C precompiled header for a C++ compilation.
&lt;/li&gt;&lt;li&gt;
The precompiled header file must be produced by the same compiler version and configuration as the current compilation is using. The easiest way to guarantee this is to use the same compiler binary for creating and using precompiled headers.
&lt;/li&gt;&lt;li&gt;
Any macros defined before the precompiled header (including with -D) must either be defined in the same way as when the precompiled header was generated, or must not affect the precompiled header, which usually means that they do not appear in the precompiled header at all.
&lt;/li&gt;&lt;li&gt;
Certain command-line options must be defined in the same way as when the precompiled header was generated. At present, it is not clear which options are safe to change and which are not; the safest choice is to use exactly the same options when generating and using the precompiled header.
&lt;/li&gt;&lt;/ul&gt;





&lt;p&gt;
The second and preferred method for using precompiled headers is to carefully organize your project so that large header files that seldom change are all included (with #include) into a single header file that you can then precompile along with systemc.h, scv.h, and so on. This might require code reorganization in your project, but usually it&amp;rsquo;s worth it since you can gain significant compile time improvement.
&lt;/p&gt;
&lt;p&gt;
An example shipped based on the OSCI simple_bus (found at www.systemc.org) unit test in:
&lt;/p&gt;
&lt;p&gt;
`ncroot`/tools/systemc/examples/precompiled_headers 
&lt;/p&gt;
&lt;p&gt;
demonstrates how to organize your code. The header files have all been included in project_h.h. Note especially that the file systemc.h is also included. &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt; is used to compile the header file: 
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="margin-left:40px;"&gt;&lt;font face="Courier New"&gt;% ncsc_run &amp;ndash;noscv &amp;ndash;gnu &amp;ndash;GCC_VERS 3.4 &amp;ndash;stop comp project_h.h&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;Another file, project.h, is introduced that includes (with #include) project_h.h. This extra layer is necessary, so we can use #ifdef guards around the inclusion of project_h.h. Then each .cpp file in the project includes (with #include) project.h as the first line in the source. This code arrangement leads to roughly a 20% improvement in compile-time performance for this example.
&lt;/p&gt;
&lt;p&gt;
Moving on from precompiled headers, &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt; offers a more exotic approach to compile time reduction. When you specify the &amp;ndash;catcxx option, i.e:
&lt;/p&gt;
&lt;div style="margin-left:40px;"&gt;&lt;font face="Courier New"&gt;&lt;p&gt;%ncsc_run &amp;ndash;catcxx file1.cpp file2.cpp file3.cpp&lt;/p&gt;&lt;/font&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt; creates a temporary file that includes (with the #include directive) all of the .cpp files in your model. Instead of compiling each file, it compiles the single &amp;quot;catcxx&amp;quot; file. I&amp;rsquo;ve seen compile time speedup with &lt;font face="Courier New"&gt;catcxx&lt;/font&gt; on the order of 80%, so in certain cases it will make your compiles sizzle.
&lt;/p&gt;
&lt;p&gt;
It is important that you prepare the files for compilation first. In particular, to avoid multiple definitions of symbols caused by inclusion of header files in multiple source files, protect the header files with the #ifndef and #endif directives. Also, be aware that the #define directive will affect all of the .cpp files in the model that are included in the temporary file. This situation can cause unexpected results (for example redefinition warnings that can be suppressed by the use of the #ifndef macros in front of any #define). Also, include files are passed forward to every .cpp file in the model. If, for example, you need to define NCSC_INCLUDE_TASK_CALLS for one .cpp file that is not the first file in the list, then if systemc.h is already included before the #define comes into effect, you get a compilation failure. In cases like this, you should use the -D option on the command line, instead of #define in the .cpp file. &lt;font face="Courier New"&gt;Catcxx&lt;/font&gt; works best if the number of files in your model is between two and ten. When the number of files exceeds ten, the compilation improvement starts to diminish. 
&lt;/p&gt;
&lt;p&gt;
The third tool Incisive SystemC offers for compilation speed-up is LSF support for distributed compilation of SystemC/C++ source files on multiple machines. You have to use&lt;font face="Courier New"&gt; ncsc_run -distcomp&lt;/font&gt; to get this support and you must have LSF installed on your local. First point the path environment variable to the LSF bin directory. LSF provides various commands, but &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt; uses only bsub, LSF&amp;#39;s batch job facility used by &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt; to run compile commands on remote machines.
&lt;/p&gt;
&lt;p&gt;
The &lt;font face="Courier New"&gt;bsub&lt;/font&gt; command can take optional arguments that give you more flexibility: -x for exclusive execute mode, -c to set maximum cpu time, -m to specify host machines. You can pass these arguments to &lt;font face="Courier New"&gt;bsub&lt;/font&gt; using the -&lt;font face="Courier New"&gt;distcompargs&lt;/font&gt; option to &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt;. Because these options are supported by &lt;font face="Courier New"&gt;bsub&lt;/font&gt; and not &lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt;, you should refer to the documentation that came with the distributed platform to resolve any issues related to using these options. By default, ncsc_run passes the -K option to &lt;font face="Courier New"&gt;bsub&lt;/font&gt; (to indicate waiting for the command to finish), and the -o option to log the &lt;font face="Courier New"&gt;bsub&lt;/font&gt; results into the bsub_results.log file located in the working directory.
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;ncsc_run&lt;/font&gt; uses make &amp;ndash;j num to spawn concurrent &lt;font face="Courier New"&gt;bsub&lt;/font&gt;jobs; the number of jobs is controlled by the - &lt;font face="Courier New"&gt;distcompjobs&lt;/font&gt; option, the default being 20 parallel &lt;font face="Courier New"&gt;bsub&lt;/font&gt; jobs. For example, for a design containing 40 C++ source files, a new &lt;font face="Courier New"&gt;bsub&lt;/font&gt; call will be issued when one of the first 20 &lt;font face="Courier New"&gt;bsub&lt;/font&gt; calls finishes up, until all 40 are compiled. The purpose of the - &lt;font face="Courier New"&gt;distcompjobs&lt;/font&gt; option is to prevent flooding of &lt;font face="Courier New"&gt;bsub&lt;/font&gt; calls for very large designs. The other options used by ncsc_run to control distributed compilation are: -&lt;font face="Courier New"&gt;distplat&lt;/font&gt;, -&lt;font face="Courier New"&gt;distcomp&lt;/font&gt;, and &lt;font face="Courier New"&gt;nodistcomp&lt;/font&gt;.
&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example:&lt;/p&gt;&lt;div style="margin-left:40px;"&gt;&lt;font face="Courier New"&gt;&lt;p&gt;-DISTPLAT lsf -NODISTCOMP file1.cpp file2.cpp -DISTCOMP file3.cpp file4.cpp&lt;/p&gt;&lt;/font&gt;&lt;/div&gt;&lt;p&gt;With this option applied, &lt;font face="Courier New"&gt;file1&lt;/font&gt; and &lt;font face="Courier New"&gt;file2&lt;/font&gt; are compiled locally, &lt;font face="Courier New"&gt;file3 &lt;/font&gt;and&lt;font face="Courier New"&gt; file4 &lt;/font&gt;are distributed.&lt;/p&gt;&lt;p&gt;So the next time you&amp;rsquo;re feeling the blues of a long build, consider one of Incisive SystemC&amp;rsquo;s strategies for speeding things up. Then get back to debugging.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;George Frazier &lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/cadence/community/blogs/45941/~4/O4k6UCWw3yk" height="1" width="1"/&gt;</description><feedburner:origLink>http://www.cadence.com/Community/blogs/sd/archive/2009/06/19/speeding-up-systemc-compilation-with-incisive-systemc.aspx</feedburner:origLink></item><item><title>Tracing TLM 2.0 Activity in an ESL Design – Part 3</title><link>http://feedproxy.google.com/~r/cadence/community/blogs/45941/~3/1TfRBxNYB3U/tracing-tlm-2-0-activity-in-an-esl-design-part-3.aspx</link><pubDate>Thu, 07 May 2009 13:00:00 GMT</pubDate><guid isPermaLink="false">75bcbcf9-38a3-4e2e-b84b-26c8c46a9500:17399</guid><dc:creator>georgef</dc:creator><description>&lt;p&gt;&lt;a href="http://www.cadence.com/Community/blogs/sd/archive/2009/03/09/systemc-save-and-restore-part-2-advanced-usage.aspx?postID=15561" target="_blank"&gt;Last time&lt;/a&gt; I discussed how to use &lt;font face="Courier New"&gt;&amp;ndash;sctlmrecord&lt;/font&gt; to produce an SST2 database of TLM 2.0 transaction data (&lt;a href="http://www.systemc.org/home" target="_blank"&gt;http://www.systemc.org&lt;/a&gt;). In this post, we&amp;rsquo;ll explore the data in the Simvision Waveform Viewer, the Transaction Explorer, and with TxE. This is the first step towards tying TLM 2.0 trace data to TLM 2.0 debug, a topic I&amp;rsquo;ll explore in greater detail in future entries.&lt;/p&gt;


&lt;p&gt;The example can be found in an IUS 8.2 install at `ncroot`/tools/systemc/examples/tlm2/tutorial. If you want to follow along type:
&lt;/p&gt;



&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;%ncsc_run \&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
+txscmain \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
simple_dma.cpp \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
simple_rxtx.cpp \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
sc_main.cpp \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
simple_host.cpp \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
simple_memory.cpp \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-nocopyright \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-DNCSC_INCLUDE_TASK_CALLS \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-scupdate \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-sctlmrecord \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-tlm2 \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-sctlmdbname tlm.shm \&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;
-debug&lt;/span&gt;&lt;/blockquote&gt;

&lt;p&gt;And then launch Simvision to view the results:&lt;/p&gt;

&lt;p&gt;
&lt;font face="Courier New"&gt;%simvision tlm.shm/tlm.trn1&lt;/font&gt;
&lt;/p&gt;

&lt;p&gt;
Previously, we produced a transaction stream and zeroed in on an area of interest: activity clustered around time 5400 ns for transaction stream &lt;font face="Courier New"&gt;isocket_1_0_SCTLMX.&lt;/font&gt;. In Simvision, you can drill down to time range 5400ns : 5500ns by typing in the time range box to the left of the magnifying glass. You will see a rectangle representing a transaction that begins at time 5400 ns (the rectangle is left-aligned with 5400 ns). Select that transaction by pressing the shift key and selecting with the left mouse button. If you are using the default color scheme in Simvision, the transaction outline will turn yellow. Next display a quick-view of the attributes by selecting the red resizing icon at the bottom left of the transaction and pulling it down until the entire transaction is visible (Figure 1).
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt; 

&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508779372/" title="Figure1 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3324/3508779372_6537ab29b5.jpg" alt="Figure1" width="500" height="310" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 1
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Some of the attribute values are visible in the Waveform viewer. A powerful feature of Simvision is the ability to expand a stream by attribute value. Here, it would be interesting to separate transactions into rows of &lt;font face="Courier New"&gt;READS&lt;/font&gt; and &lt;font face="Courier New"&gt;WRITES&lt;/font&gt;. To do this, hover over the &amp;quot;Command&amp;quot; attribute of the selected transaction in the right window and right-click select the option &amp;quot;Expand Stream By Command&amp;quot; (see Figure 2): 
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508779382/" title="Figure2 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3615/3508779382_ecc4e78f7c.jpg" alt="Figure2" width="500" height="333" /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 2
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;


&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;To see the resulting rows expand the time range 0 ns &amp;ndash; 20,000 ns. You will see two new rows below the original row (Figure 3). 
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508779390/" title="Figure3 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3578/3508779390_bdf27a2e3f.jpg" alt="Figure3" width="500" height="312" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 3
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;It is easy to see that the dma is performing a block of &lt;font face="Courier New"&gt;READS&lt;/font&gt; (the topmost of the two new rows) followed by a series of &lt;font face="Courier New"&gt;WRITES&lt;/font&gt; followed later by another block of &lt;font face="Courier New"&gt;READS&lt;/font&gt;. You can move the &lt;font face="Courier New"&gt;WRITE&lt;/font&gt; row above the &lt;font face="Courier New"&gt;READ&lt;/font&gt; row by grabbing the [&lt;font face="Courier New"&gt;Command == &amp;quot;WRITE&amp;quot;&lt;/font&gt;] row heading in the name column on the left and dragging it by pressing the middle mouse button up above the [&lt;font face="Courier New"&gt;Command == &amp;quot;READ&amp;quot;&lt;/font&gt;] row. These expansions can be done by any attribute value (and the resulting rows can be rearranged or deleted as necessary). 
&lt;/p&gt;
&lt;p&gt;
Now change the time range back to 5400ns : 5500ns. Sometimes multiple transactions are recorded at the same time. In the default view only one of those transactions will be visible. Note that the original transaction at time 5400ns is still selected. To see if any other transactions are recorded in this time range right-click on the selected transaction and choose &amp;quot;Expand Stream.&amp;quot; The resulting view (Figure 4) shows that one transaction begins at time 5400ns and three transactions begin at time 5410 ns. Selecting the transaction at time 5400 ns shows the three transactions aligned at 5400 ns all colored yellow: they are different views of the same transaction &amp;ndash; one in the default stream, one broken out by time, the other broken out by command &lt;font face="Courier New"&gt;READ&lt;/font&gt;&lt;/p&gt;&lt;p&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508779392/" title="Figure4 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3577/3508779392_27a9718b20.jpg" alt="Figure4" width="500" height="311" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 4
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Next, select the transaction that begins at time 5400 ns in the Waveform viewer. The best way to examine the value of its attributes is to display them in the Transaction Explorer. On the Transaction Explorer toolbar (which you can bring up by clicking the TxE button on the topmost tool bar) immediately to the right of the TxE button is a button that displays the detailed attributes of the transaction. Clicking the button brings up the Transaction Explorer Window (Figure 5):
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508779396/" title="Figure5 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3409/3508779396_1932736535.jpg" alt="Figure5" width="500" height="426" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;&lt;i&gt;Figure 5&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This transaction corresponds to the first &amp;ldquo;hop&amp;rdquo; in an attempt to read 8 bytes from address 0x6000 with the blocking transport protocol (b_transport).  ID 34 indicates this is the 34&lt;sup&gt;th&lt;/sup&gt; TLM 2.0 read or write operation attempted during this simulation. All of the remaining hops in the transaction sequence will share this ID because the same generic payload object is being passed across each transport boundary.  This transaction is the initial transaction that connections &lt;font face="Courier New"&gt;simple_dma&lt;/font&gt; to &lt;font face="Courier New"&gt;memory_1&lt;/font&gt;. Since the operation is blocking, the start and end times represent the total time needed to complete the operation.  However, there are three more hops remaining:
&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;

&lt;font face="Courier New"&gt;
1. TOP_TB.TOP.dma_0.isocket_1_0 to TOP_TB.TOP.arbiter_0.tsocket_1_0&lt;/font&gt;&lt;br /&gt;
&lt;font face="Courier New"&gt;
2. TOP_TB.TOP.arbiter_0.isocket_0 to TOP_TB.TOP.router_0.tsocket_0&lt;/font&gt;&lt;br /&gt; 
&lt;font face="Courier New"&gt;
3. TOP_TB.TOP.router_0.isocket_2_0 to TOP_TB.TOP.arbiter_1.tsocket_0_0&lt;/font&gt;&lt;br /&gt;
&lt;font face="Courier New"&gt;
4. TOP_TB.TOP.arbiter_1.isocket_0 to TOP_TB.TOP.mem_1.tsocket_0&lt;/font&gt;&lt;br /&gt;

&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;
Simvision can build a graph representing this path based on the information recorded by TLM 2.0 tracing. To see the relations, open the View menu and select family_tree (Figure 6).
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508779404/" title="Figure6 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3369/3508779404_99fddb7c06.jpg" alt="Figure6" width="500" height="426" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 6
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The yellow node corresponds to the Initiator transaction.&lt;span&gt;&amp;nbsp;  The arrows show the order of transaction initiation which also corresponds to the connections in Figure 7. 
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508780920/" title="Figure7 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3640/3508780920_4f2f20ac2b.jpg" alt="Figure7" width="500" height="369" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 7
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Selecting any of the other graph nodes will update the attribute values in the Attribute window to the left.  If you click the &amp;ldquo;See&amp;rdquo; button the Waveform window will be brought into focus with the transaction highlighted.  The Waveform Viewer also reflects the information in the family tree (Figure 8). 
&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/37146452@N02/3508780922/" title="Figure8 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3339/3508780922_076973268c.jpg" alt="Figure8" width="500" height="278" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;
&lt;i&gt;Figure 8
&lt;/i&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
The last four rows on the right show the Initiator transaction in yellow followed by the three succeeding transactions in green (the top row is the unexpanded view).  The database generated by TLM 2.0 represents a complete history of the life spans of generic payload objects in a TLM 2.0 simulation.  Within this data is a wealth of information about the functioning and performance of the design.  Future versions of Cadence IUS will include a rich set of TLM data anlysis capabilities. One way to unlock this information in IUS 8.2 is through the use of TxE scripts.  Here I present one script you can use as a starting point if you are interested in mining TLM 2.0 data.  The script is simple, but you can expand it to include more of the generic payload fields or computed fields such as latency.  The script prints basic information about each transaction to a file named &amp;ldquo;dump.log&amp;rdquo;.  The attributes printed are start_time, end_time, Initiator, Target, and ID.  To customize you can choose any attribute generate by TLM 2.0 tracing and add a &amp;ldquo;col&amp;rdquo; entry in the table section.
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;txe_file_version
4&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;txe_search_create
search dump_log {&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;source {}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;init {}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;apply { &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fiber * { &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;trans_type * { &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;accept&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;} &lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;exit {&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;table {&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;col {Begin Time} [tformat 12.2ns
[start_time]]&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;col {End Time} [tformat 12.2ns [end_time]]&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;col {Initiator} [attribute
&amp;quot;Initiator&amp;quot;]&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;col {Target} [attribute
&amp;quot;Target&amp;quot;]&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;col {ID} [attribute &amp;quot;ID&amp;quot;]&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sort {Begin Time}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;doc {}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;set
text_file [open &amp;quot;dump.log&amp;quot; &amp;quot;w&amp;quot;]&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;foreach
s [txe_search_get_list] {&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;# Execute the search.&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;txe_search_execute $s&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;# Write the results table&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;puts $text_file &amp;quot;[txe_search_get_path
$s]&amp;quot;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;puts $text_file
&amp;quot;-------------------------------&amp;quot;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;txe_table_write $text_file text $s&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&lt;span&gt;&amp;nbsp; &lt;/span&gt;puts $text_file &amp;quot;&amp;quot;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;#
Close the text files.&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;close
$text_file&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Here&amp;rsquo;s the
output from running the script on our database:&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;%txe
&amp;ndash;input dump.txe tlm.shm/tlm.trn&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;% more dump.log&lt;/span&gt;&lt;/p&gt;

&lt;p class="MsoNormal"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/36223644@N04/3504843635/" title="log by cadencedesign, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3625/3504843635_c87fa1d784.jpg" alt="log" width="476" height="548" /&gt;&lt;/a&gt;

&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;My three posts on TLM 2.0 tracing in Incisive provide a small peek at the capabilities built into Incisive for working natively with TLM 2.0 data.  This is just the beginning though, look for a richer set of TLM 2.0 tool features coming in IUS 9.2.
&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;George Frazier&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/cadence/community/blogs/45941/~4/1TfRBxNYB3U" height="1" width="1"/&gt;</description><feedburner:origLink>http://www.cadence.com/Community/blogs/sd/archive/2009/05/07/tracing-tlm-2-0-activity-in-an-esl-design-part-3.aspx</feedburner:origLink></item><item><title>Tracing TLM 2.0 Activity in an ESL Design – Part 2</title><link>http://feedproxy.google.com/~r/cadence/community/blogs/45941/~3/NfiCVKgVHdw/tracing-tlm-2-0-activity-in-an-esl-design-part-2.aspx</link><pubDate>Tue, 07 Apr 2009 13:05:00 GMT</pubDate><guid isPermaLink="false">75bcbcf9-38a3-4e2e-b84b-26c8c46a9500:16532</guid><dc:creator>georgef</dc:creator><description>&lt;p&gt;In my &lt;a href="http://www.cadence.com/Community/blogs/sd/archive/2009/03/23/tracing-tlm-2-0-activity-in-an-esl-design-part-i.aspx?postID=16041" target="_blank"&gt;last post&lt;/a&gt; I discussed two ad hoc approaches for tracing TLM 2.0 activity in a design: using output statements to write to a text file or the terminal and using SCV transaction recording to write to a database such as SST2. If your goal is to debug the TLM-specific aspects of a design, you need to get a handle on the values of generic payload objects as they flow through the transport methods of your system. Whether or not you think printf debugging is barbaric, both ad hoc approaches force you to modify your design. More importantly for debugging, critical TLM 2.0 connectivity information is difficult to capture in trace logs.&lt;/p&gt;&lt;p&gt;Here&amp;rsquo;s what I mean by connectivity information. In TLM 2.0, the transport interfaces &amp;ndash; &lt;font face="Courier New"&gt;b_transport&lt;/font&gt;, &lt;font face="Courier New"&gt;nb_transport_fw&lt;/font&gt;, and &lt;font face="Courier New"&gt;nb_transport_bw&lt;/font&gt; &amp;ndash; model reads and writes between initiators and targets. An initiator is a module that initiates transactions (for example a processor); a target is a module that serves as the destination for transactions (for example a memory). An interconnect module such as an arbiter or a router is both an initiator and a target, but it doesn&amp;rsquo;t serve as the beginning or ending point of a transaction. As generic payload objects travel between initiators and targets, their &amp;quot;passports&amp;quot; might receive several stamps along the way. Figure &lt;i&gt;1&lt;/i&gt; shows a design with a Processor, a Bus Bridge, and a Memory. Each arrow represents a &amp;quot;hop&amp;quot; in the lifespan of the generic payload object. A successful read or write will consist of four &amp;quot;hops&amp;quot; between the Processor and the Memory, two along the forward path and two along the backward path.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.flickr.com/photos/37146452@N02/3420807455/" title="tlm2_fig1 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3550/3420807455_71a16b3131.jpg" alt="tlm2_fig1" height="296" width="500" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;i&gt;&amp;nbsp;&amp;nbsp; Figure 1 &amp;ndash; a TLM 2.0 Design with an Initiator, an Interconnect, and a Target. &lt;/i&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The &lt;font face="Courier New"&gt;&amp;ndash;sctlmrecord&lt;/font&gt; feature of ncsim is based on the observation that to completely trace activity between an initiator and a target, each read or write should be broken up into a sequence of snapshots as generic payload objects progress through a series of hops. &lt;font face="Courier New"&gt;-sctlmrecord&lt;/font&gt; traces all the fields of the generic payload object and the before and after values of transport function parameters at each hop by recording an SST2 transaction into the database. Each read or write is modeled as a sequence of transactions. Connectivity information is captured by linking those transactions through SST2 parent/child relationships. The rules of TLM 2.0 determine when to terminate a transaction sequence (i.e. when the read or write has finished). Transactions that pass through calls to &lt;font face="Courier New"&gt;b_transport&lt;/font&gt; have completed when the call (which blocks) returns. Thus the timing points of a b_&lt;font face="Courier New"&gt;transport&lt;/font&gt; call can be determined by calling &lt;font face="Courier New"&gt;sc_time_stamp&lt;/font&gt; immediately before and after the call to &lt;font face="Courier New"&gt;b_transport&lt;/font&gt;. Determining when a transaction that passes through calls to &lt;font face="Courier New"&gt;nb_transport_fw &lt;/font&gt;and &lt;font face="Courier New"&gt;nb_transport_bw&lt;/font&gt; is complete is handled by the generic payload&amp;rsquo;s memory manager. The use of the non-blocking interfaces requires that a memory manager be set for each generic payload object. When the last component relinquishes control of the object and is available for pooling or deletion, the last &amp;quot;hop&amp;quot; of the transport chain has been finished. &lt;/p&gt;&lt;p&gt;&lt;b&gt;The following ncsim command line options control TLM 2.0 tracing:&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;font face="Courier New"&gt;&lt;p&gt;sctlmrecord&lt;/p&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt;Turns on TLM 2.0 tracing mode for designs using transport calls:&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;font face="Courier New"&gt;&lt;p&gt;sctlmdbname &amp;lt;dbname&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt;Specifies the database for TLM 2.0 tracing data: &lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;font size="+0"&gt;&lt;font face="Courier New"&gt;sctlmnodata&lt;/font&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Excludes recording of data transferred across the transport boundary, which improves efficiency because transferred data could be very large. Without this flag the data field is recorded as a string in hexadecimal format.&lt;/p&gt;&lt;p&gt;When you launch ncsim with &lt;font face="Courier New"&gt;&amp;ndash;sctlmrecord&lt;/font&gt;, a transaction stream is created for each Initiator that actively participates in the design. &lt;i&gt;Figure 2&lt;/i&gt; shows two TLM 2.0 tracing streams in the Simvision Design Browser that are associated with initiator sockets in a DMA block (sc_main.TOP_TB.TOP.dma_0):&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.flickr.com/photos/37146452@N02/3421618850/" title="tlm2_fig2 by georgefrazier, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3404/3421618850_3bb4c40532.jpg" alt="tlm2_fig2" height="374" width="500" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Figure 2 &amp;ndash; A design with two initiator sockets. &lt;/i&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Either during or after simulation, you can send TLM 2.0 tracing streams to the Simvision Waveform viewer to get a quick view of TLM 2.0 activity (&lt;i&gt;Figure 3&lt;/i&gt;). For this design there is some activity between 4000 and 9000 ns, but things don&amp;rsquo;t really get &amp;ldquo;warmed up&amp;rdquo; until 10000 ns.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;
&lt;a href="http://www.flickr.com/photos/36223644@N04/3652062836/" title="tlm2_fig3 by cadencedesign, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3347/3652062836_3f683bf169.jpg" alt="tlm2_fig3" height="311" width="500" /&gt;&lt;/a&gt;

&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Figure 3 &amp;ndash; High Level view of TLM 2.0 tracing activity. &lt;/p&gt;&lt;p&gt;Here&amp;rsquo;s a typical debugging scenario. You notice a latency in your design and have narrowed it down to activity between 5400 and 6000 ns. To use sctlmrecord to help shine light on the problem, first launch &lt;font face="Courier New"&gt;ncsim&lt;/font&gt; with &lt;font face="Courier New"&gt;&amp;ndash;sctlmrecord&lt;/font&gt;. At the tcl prompt, immediately turn recording off. That&amp;rsquo;s right. You don&amp;rsquo;t want to record transactions until you get to the interesting part of your simulation, which is 5400 ns. Note that any read or write in progress at time 5400 will not be recorded. Only reads and writes that begin after the start time make it into the database. Future versions of Incisive SystemC will support a full command interface for toggling tracing, but in IUS 8.2 you turn tracing off by issuing the following c function call:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;font face="Courier New"&gt;&lt;p&gt;ncsim&amp;gt; call sc_tlm_record_off&lt;/p&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt;Next, run to ahead:&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;font face="Courier New"&gt;&lt;p&gt;ncsim&amp;gt; run 5400 ns&lt;/p&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt;Now you&amp;rsquo;re ready to go. Turn tracing back on and run until time 6000 ns:&lt;/b&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;font face="Courier New"&gt;&lt;p&gt;ncsim&amp;gt; call sc_tlm_record_on&lt;/p&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;font face="Courier New"&gt;&lt;p&gt;ncsim&amp;gt; run 600 ns&lt;/p&gt;&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;When control returns, you&amp;rsquo;ll be ready to analyze the interesting part of your design &amp;ndash; the bottleneck.&amp;nbsp; In my next post, I&amp;rsquo;ll cover exactly how to do this using Simvision, the database produced by sctlmrecord, and TxE.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;George Frazier &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/cadence/community/blogs/45941/~4/NfiCVKgVHdw" height="1" width="1"/&gt;</description><feedburner:origLink>http://www.cadence.com/Community/blogs/sd/archive/2009/04/07/tracing-tlm-2-0-activity-in-an-esl-design-part-2.aspx</feedburner:origLink></item><item><title>Tracing TLM 2.0 Activity In An ESL Design – Part I</title><link>http://feedproxy.google.com/~r/cadence/community/blogs/45941/~3/Fp3xNnqaihY/tracing-tlm-2-0-activity-in-an-esl-design-part-i.aspx</link><pubDate>Mon, 23 Mar 2009 15:28:00 GMT</pubDate><guid isPermaLink="false">75bcbcf9-38a3-4e2e-b84b-26c8c46a9500:16041</guid><dc:creator>georgef</dc:creator><description>&lt;p&gt;Many design teams that use SystemC&amp;nbsp; are in various stages of evaluating TLM 2.0 &amp;ndash; the Open SystemC Initiative&amp;rsquo;s transaction level library designed for modeling memory-mapped buses and on-chip communication networks. The new &lt;a href="http://www.systemc.org/downloads/standards"&gt;standard&lt;/a&gt;&amp;nbsp; takes us one step closer to creating an ecosystem where ESL models can interoperate across the boundaries of design teams, IP providers, and tool vendors. TLM 2.0 designs are much faster than equivalent RTL designs. TLM 2.0 processor models often run faster than the actual hardware they&amp;rsquo;re emulating.&lt;/p&gt;&lt;p&gt;But this doesn&amp;rsquo;t mean it&amp;rsquo;s easy to fish out a particular sequence of reads or writes from the ocean of transport calls a simulation session might produce. If you&amp;rsquo;ve worked with real TLM 2.0 designs, you know that a typical loosely timed model can generate millions of calls between sockets. Consider a virtual platform where a processor can read from a number of memories connected via multiple layers of interconnects. The volume of information &amp;ndash; expressed as the set of all data member values of generic payload objects traveling through &lt;font face="Courier New"&gt;b_transport(), nb_transport_fw(), &lt;font face="Arial"&gt;and &lt;/font&gt;nb_transport_bw()&lt;/font&gt; calls &amp;ndash; can be formidable. Sure, looking through sequences of TLM 2.0 reads and writes might be easier than making sense of the equivalent RTL-level information, but it&amp;rsquo;s still like searching for a lost grain of sand &amp;ndash; it doesn&amp;rsquo;t much matter whether you&amp;rsquo;re at Destin Beach or in the Sahara Desert. Without proper tools you might as well grab a Corona Light and look for an umbrella.&lt;/p&gt;&lt;p&gt;The quickest way to get a sense for what&amp;rsquo;s happening in the guts of a TLM 2.0 target is to instrument your transport methods with print statements. Almost every TLM 2.0 example I see on the Internet does this. Here&amp;rsquo;s an example of a simple memory block that reports some data for each successful operation:&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;#include &amp;lt;systemc&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;#include &amp;quot;tlm.h&amp;quot;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;void
simple_memory::b_transport(tlm_generic_payload&amp;amp; tx, sc_time&amp;amp; dt) &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;{&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;tlm_command opcode = tx.get_command();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;uint64 addr = tx.get_address();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;unsigned length = tx.get_data_length();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;unsigned char * data_ptr =
tx.get_data_ptr();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; wait(10*(length/4), SC_NS);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; if (tx.get_byte_enable_length() != 0) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
tx.set_response_status(TLM_BYTE_ENABLE_ERROR_RESPONSE);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; int strw = tx.get_streaming_width();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; int nb_cpy;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; if (tx.get_streaming_width() &amp;lt; length) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nb_cpy = length / strw;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; } &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; else {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nb_cpy = 1;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; strw = length;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; if (nb_cpy*strw != length) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
tx.set_response_status(TLM_BURST_ERROR_RESPONSE);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; if (addr + strw &amp;lt;= size) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(int cpy = 0; cpy &amp;lt; nb_cpy;
cpy++) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (opcode ==
TLM_READ_COMMAND) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
memcpy(data_ptr+cpy*strw, &amp;amp;mem_array[addr], strw);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (opcode ==
TLM_WRITE_COMMAND) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
memcpy(&amp;amp;mem_array[addr], data_ptr+cpy*strw, strw);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int
i=0; i&amp;lt;strw; i++) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
notify_write_access(addr+i);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
tx.set_response_status(TLM_OK_RESPONSE);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; } &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; else {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
tx.set_response_status(TLM_ADDRESS_ERROR_RESPONSE);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;if (tx.get_response_status() ==
TLM_OK_RESPONSE){&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (opcode == TLM_READ_COMMAND) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; std::cout &amp;lt;&amp;lt;
&amp;quot;Reading
&amp;quot; &amp;lt;&amp;lt; length &amp;lt;&amp;lt; &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;quot; bytes from &amp;quot; addr &amp;lt;&amp;lt; std::endl;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; std::cout &amp;lt;&amp;lt;
&amp;quot;Writing &amp;quot; &amp;lt;&amp;lt; length &amp;lt;&amp;lt; &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;quot; bytes from &amp;quot; addr &amp;lt;&amp;lt; std::endl; &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;This might be OK for small examples, but you can&amp;rsquo;t do much with text output. A better approach, though still manual, is to use the SCV transaction recording API to create an SST2 database of memory accesses. SCV transaction recording fits naturally into the TLM 2.0 paradigm. Presuming our &lt;font face="Courier New"&gt;simple_memory&lt;/font&gt; class has the following members:&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;scv_tr_stream *m_streamHandle;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;scv_tr_generator&amp;lt;
&amp;gt; *m_genHandle;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;scv_tr_db* m_db;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;and some initialization code in the constructor to create the database:&lt;/p&gt;&lt;font face="Courier New"&gt;&lt;p&gt;m_db = new scv_tr_db(&amp;quot;MemoryDatabase&amp;quot;);&lt;/p&gt;&lt;/font&gt;&lt;p&gt;we can change our transport routine to write generic payload information to a database. Now our &lt;font face="Courier New"&gt;simple_memory&lt;/font&gt; class creates a transaction for each successful read or write. It uses &lt;font face="Courier New"&gt;scv_tr_handle::record_attribute()&lt;/font&gt; to write attribute data to the transaction.&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;#include &amp;lt;systemc&amp;gt;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;#include &amp;quot;scv.h&amp;quot;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;#include &amp;quot;tlm.h&amp;quot;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;void simple_memory::b_transport&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; (tlm_generic_payload&amp;amp; tx, sc_time&amp;amp;
dt) &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;{&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; tlm_command opcode = tx.get_command();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; uint64 addr = tx.get_address();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; unsigned length = tx.get_data_length();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; unsigned char * data_ptr = tx.get_data_ptr();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; // Create a transaction stream &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; // and a transaction generator if they don&amp;rsquo;t
exist&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; if (!m_genHandle)&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_streamHandle = &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new
scv_tr_stream(&amp;quot;MemoryStream&amp;quot;, &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;quot;TRANSACTOR&amp;quot;, m_db);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
m_genHandle = &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;new scv_tr_generator&amp;lt;
&amp;gt;(&amp;quot;MemoryTx&amp;quot;, &lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
*m_streamHandle), &amp;quot;addr&amp;quot;, &amp;quot;data&amp;quot;);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; // Get a handle for the new transaction&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; scv_tr_handle h =
m_genHandle-&amp;gt;begin_transaction();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; wait(10*(length/4), SC_NS);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;hellip;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; // Write the command type&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp; if (tx.get_response_status() ==
TLM_OK_RESPONSE){&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (opcode == TLM_READ_COMMAND) {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
h.record_attribute(&amp;quot;command&amp;quot;, &amp;quot;READ&amp;quot;);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;} else {&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
h.record_attribute(&amp;quot;command&amp;quot;, &amp;quot;READ&amp;quot;);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;// Write the address and data length&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;h.record_attribute(&amp;quot;addr&amp;quot;,
addr);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;h.record_attribute(&amp;quot;length&amp;quot;,
length);&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;// End the transaction&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;&amp;nbsp;&amp;nbsp;h.end_transaction();&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin:0in 0in 0.0001pt;"&gt;&lt;span style="font-size:10pt;font-family:&amp;#39;Courier New&amp;#39;;"&gt;}&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;The resulting SST2 database is better than text, but for complex designs you might end up writing a significant amount of transaction recording code. Unless you add the ability to turn tracing on and off, large designs can slow significantly depending on how much data they produce. Also, this strategy doesn&amp;rsquo;t capture information about the connectivity of the design. There is no history of where reads and writes initiated or which interconnects they traveled across to reach the memory. &lt;/p&gt;&lt;p&gt;In my &lt;a href="http://www.cadence.com/Community/blogs/sd/archive/2009/04/06/tracing-tlm-2-0-activity-in-an-esl-design-part-2.aspx" target="_blank"&gt;next post&lt;/a&gt; I&amp;rsquo;ll cover a new feature in IUS 8.2 that addresses these problems and provides a framework for debugging TLM 2.0 designs. The feature, called &lt;font face="Courier New"&gt;sctlmrecord&lt;/font&gt;, automatically creates a complete transaction history of generic payload values as they flow through a TLM 2.0 design. You can simulate up to a point of interest in a design and then turn on recording, capturing only the information you need to debug your problem. The database can be viewed in the Simvision Waveform Viewer or Transaction Explorer. You can query it with TxE scripts.&lt;/p&gt;&lt;p&gt;Best of all, you don&amp;rsquo;t have to write a single line of code to get it to work.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;font size="2" face="Arial"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://feeds.feedburner.com/~r/cadence/community/blogs/45941/~4/Fp3xNnqaihY" height="1" width="1"/&gt;</description><feedburner:origLink>http://www.cadence.com/Community/blogs/sd/archive/2009/03/23/tracing-tlm-2-0-activity-in-an-esl-design-part-i.aspx</feedburner:origLink></item><item><title>SystemC Save and Restore Part 2 - Advanced Usage</title><link>http://feedproxy.google.com/~r/cadence/community/blogs/45941/~3/ZMnK0uIStwk/systemc-save-and-restore-part-2-advanced-usage.aspx</link><pubDate>Mon, 09 Mar 2009 13:00:00 GMT</pubDate><guid isPermaLink="false">75bcbcf9-38a3-4e2e-b84b-26c8c46a9500:15561</guid><dc:creator>georgef</dc:creator><description>&lt;p&gt;In my &lt;a href="http://www.cadence.com/Community/blogs/sd/archive/2009/02/18/how-to-save-os-boot-time-in-your-systemc-virtual-platform-with-save-and-restore.aspx?postID=14893"&gt;last post&lt;/a&gt; I discussed how to use save / restore in the &lt;a href="http://www.cadence.com/products/sd/Pages/default.aspx"&gt;Cadence Incisive Simulator&lt;/a&gt; to create checkpoints for designs that contain SystemC. The algorithm for SystemC save / restore is fundamentally different than the algorithm for HDL designs. Although most of the functionality is equivalent between the two styles, there are a few differences. &lt;/p&gt;&lt;p&gt;During restart, all internal variables are restored to their saved values (for example, C variables declared static). While this behavior helps assure that SystemC state information is properly saved and restored, it can also leave variables that reference the process environment (like file descriptor and sockets to other processes) in limbo. To allow control before and after both save and restart, IUS provides the following virtual function definitions:&lt;/p&gt;&lt;p&gt;virtual void start_of_save()&lt;/p&gt;&lt;p&gt;virtual void end_of_save()&lt;/p&gt;&lt;p&gt;virtual void start_of_restore()&lt;/p&gt;&lt;p&gt;virtual void end_of_restore()&lt;/p&gt;&lt;p&gt;These methods are defined for those class definitions that have similar phase callback methods currently defined (for example, start_of_simulation or end_of_simulation). &lt;/p&gt;&lt;p&gt;Here&amp;rsquo;s a simple example. Class scchild has a thread that writes some data to a log file. If a save operation is performed when the file is open then problems can arise if the program attempts to write to the same file after restore (because the file descriptor associated with the open file will be in a different state after restore). Keep in mind that you could decide to restore this session weeks or months after the original save. The file could be modified or even deleted in that time. Here, in the start_of_restore method, we &amp;quot;fix up&amp;quot; the file by opening it again. Granted, things would be trickier if this was an input file, but you get the idea.&lt;/p&gt;&lt;p&gt;class scchild : public sc_module {&lt;/p&gt;&lt;p&gt;public:&lt;/p&gt;&lt;p&gt;sc_in&amp;lt;sc_logic&amp;gt; in;&lt;/p&gt;&lt;p&gt;SC_CTOR(scchild): in(&amp;quot;in&amp;quot;) {&lt;/p&gt;&lt;p&gt;SC_THREAD(main);&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;void main() {&lt;/p&gt;&lt;p&gt;int *count = new int;&lt;/p&gt;&lt;p&gt;open_out_log(&amp;quot;my_log&amp;quot;);&lt;/p&gt;&lt;p&gt;for (*count=0; *count &amp;lt; 10000; (*count)++) {&lt;/p&gt;&lt;p&gt;fprintf(out_log, &amp;quot;*count = %d\n&amp;quot;, *count);&lt;/p&gt;&lt;p&gt;wait(10, SC_NS);&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;void start_of_save() {&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;void end_of_save() {&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;void start_of_restore() {&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;void end_of_restore() {&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;void open_out_log(const char *name){&lt;/p&gt;&lt;p&gt;out_log = fopen(name);&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;private:&lt;/p&gt;&lt;p&gt;FILE *out_log;&lt;/p&gt;&lt;p&gt;};&lt;/p&gt;&lt;p&gt;In case you&amp;rsquo;re wondering why we don&amp;rsquo;t close the file in start_of_restore, the file descriptor associated with out_log before save is gone after the snapshot is restored. The core save / restore code actually does the close. &lt;/p&gt;&lt;p&gt;SystemC save / restore does not work for designs that contain AMS or simulation sessions that are instrumented with IBM PurifyPlus products. However you can use electric fence for debugging memory violations (ncsc_run &amp;ndash;efence).&lt;/p&gt;&lt;p&gt;Finally, while using restart with a saved snapshot, ncsim overwrites any SHM databases that were active before restart. With HDL save / restore, a new trn sequence file is generated for each save and restore operation. Thus if you have probes in your design and do a save followed by 2 restarts:&lt;/p&gt;&lt;p&gt;ncsim&amp;gt; probe -create sctop.es.run -database waves -waveform&lt;/p&gt;&lt;p&gt;ncsim&amp;gt; run 20 ns&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;save &amp;ndash;over x&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;run 10 ns&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;restart x&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;run 1000 ns&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;restart x&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;run 10 ns&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;You&amp;rsquo;ll get an shm directory that contains the following files:&lt;/p&gt;&lt;p&gt;georgef%ls -1 ncsim.shm&lt;/p&gt;&lt;p&gt;ncsim.dsn &lt;/p&gt;&lt;p&gt;ncsim.trn &lt;/p&gt;&lt;p&gt;ncsim.trn-1 &lt;/p&gt;&lt;p&gt;ncsim.trn-2 &lt;/p&gt;&lt;p&gt;ncsim.trn-3&lt;/p&gt;&lt;p&gt;ncsim.trn contains the probe activity from time 0 to save, ncsim.trn-1 contains the probe activity from after save to the first restart, ncsim.trn-2 contains the probe activity from after the first restart to the second restart, and ncsim.trn-3 contains the probe activity after the second restart.&lt;/p&gt;&lt;p&gt;Because of the SST2 format, we can&amp;rsquo;t support this kind of data continuity between restarts with the SystemC approach. After the first restore, the entire database (ncsim.shm and ncsim.trn) will be overwritten. &lt;/p&gt;&lt;p&gt;We have an option for restart, however, that allows you to save data between restores in entirely separate databases. Use the &amp;ndash;savedb option to keep a complete history of probe activity in a session with multiple restarts:&lt;/p&gt;&lt;p&gt;ncsim&amp;gt; probe -create sctop.es.run -database waves -waveform&lt;/p&gt;&lt;p&gt;ncsim&amp;gt; run 20 ns&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;save &amp;ndash;over x&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;run 10 ns&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;restart &amp;ndash;savedb x&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;run 1000 ns&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;restart &amp;ndash;savedb x&lt;/p&gt;&lt;p&gt;ncsim&amp;gt;run 10 ns&lt;/p&gt;&lt;p&gt;Now instead of a single ncsim.shm directory you will also have ncsim-1.shm and ncsim-2.shm. Each directory contains data written after restart. Note that no separate directory is created after save (as in HDL save / restore). &lt;/p&gt;&lt;p&gt;If you&amp;rsquo;re using Incisive SystemC, I hope you&amp;rsquo;ll give save and restore a try. Let us know what you think if you do.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;font size="2" face="Arial"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://feeds.feedburner.com/~r/cadence/community/blogs/45941/~4/ZMnK0uIStwk" height="1" width="1"/&gt;</description><feedburner:origLink>http://www.cadence.com/Community/blogs/sd/archive/2009/03/09/systemc-save-and-restore-part-2-advanced-usage.aspx</feedburner:origLink></item><item><title>How to Save OS Boot Time In Your SystemC Virtual Platform With Save and Restore</title><link>http://feedproxy.google.com/~r/cadence/community/blogs/45941/~3/wpPiTOq72JU/how-to-save-os-boot-time-in-your-systemc-virtual-platform-with-save-and-restore.aspx</link><pubDate>Wed, 18 Feb 2009 15:00:00 GMT</pubDate><guid isPermaLink="false">75bcbcf9-38a3-4e2e-b84b-26c8c46a9500:14893</guid><dc:creator>georgef</dc:creator><description>One advantage of using a virtual platform or virtual prototype over real hardware for embedded software development and testing is the ability of some simulators to save snapshots of their state. If your processor model is detailed enough, it might take several minutes (or even hours) to simulate booting the OS. If you save a snapshot of your simulation just after you&amp;rsquo;ve finished booting, each time you want to run your embedded software you can simply restore the snapshot and go. Restarting a snapshot typically takes a few seconds. This can translate into a major productivity gain, especially if you&amp;rsquo;re running a thousand short software tests on the processor. &lt;p&gt;Save and restore (or restart) has existed in HDL simulators for years, but things are trickier if SystemC is involved. For one thing, SystemC simulators use external tools for compilation and linking: i.e. gcc. They have more or less a &amp;ldquo;black box&amp;rdquo; understanding of global variables, local variables, file descriptors and heap values that make up the simulation state at any point in time. When you throw in multiple threads implemented with application-level threading packages and the fact that C++ heap objects are impractical to save programmatically, it&amp;rsquo;s easy to see why save and restore tools for HDL simulators can&amp;rsquo;t be easily extended for SystemC. &lt;/p&gt;&lt;p&gt;Beginning with version 6.2 of the Cadence Incisive Simulator (released in mid-2007), Incisive SystemC has supported the ability to save and restart simulation sessions for designs that include not only SystemC, but any combination of SystemC, VHDL, Verilog, and System Verilog. Currently the capability exists on Linux platforms. &lt;/p&gt;&lt;p&gt;Incisive implements &lt;span style="font-size:12pt;color:black;font-family:&amp;#39;Courier New&amp;#39;;"&gt;save&lt;/span&gt; by storing a snapshot of the simulation state to a file. The state is restored when the saved snapshot file is used to start a new process. To save a snapshot from the command line, use the Tcl &lt;span style="font-size:12pt;color:black;font-family:&amp;#39;Courier New&amp;#39;;"&gt;save&lt;/span&gt; command:ncsim&amp;gt; save saved_snap.&lt;/p&gt;&lt;p&gt;To save a snapshot from Simvision, choose &amp;quot;Save Checkpoint&amp;quot; from the simulation menu: &lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;br /&gt;&lt;img src="http://i593.photobucket.com/albums/tt11/georgefrazier/save.gif" alt="Saving a new snapshot" width="575" border="0" height="430" /&gt;&lt;/b&gt; &lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;To restore, you can launch Incisive from the command line with the name of saved snapshot.&amp;nbsp; For example: &lt;/p&gt;&lt;p&gt;georgef% ncsim -input sim.tcl saved_snap &lt;/p&gt;&lt;p&gt;You can also use the Tcl &lt;span style="font-size:12pt;color:black;font-family:&amp;#39;Courier New&amp;#39;;"&gt;restart&lt;/span&gt; command to restore a snapshot if you are using the command line interface (&lt;span style="font-size:12pt;color:black;font-family:&amp;#39;Courier New&amp;#39;;"&gt;restart&lt;/span&gt;&lt;span&gt; is not supported in Simvision, you should use reinvoke instead): &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;ncsim&amp;gt; restart saved_snap&lt;/i&gt; &lt;/p&gt;&lt;p&gt;This saved state is separate from the state of the simulation environment, so you can launch a new session with the saved snapshot and vary simulation parameters by passing different arguments to ncsim. This is a great way to test different scenarios from a known &amp;ldquo;safe&amp;rdquo; point before a problem occurs. &lt;/p&gt;&lt;p&gt;There are a few things to keep in mind with SystemC save / restart.&amp;nbsp; During restart, all internal variables inherit the same values from the process as it existed at the time of save (for example, C variables declared static). While this behavior helps assure that SystemC state information is properly saved and restored, it can also leave variables that reference the process environment (like file descriptor and sockets to other processes) in limbo.&amp;nbsp; In my next post I&amp;#39;ll show you how to handle these kinds of issues and point out some other things you should be aware of when using SystemC save / restart.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/cadence/community/blogs/45941/~4/wpPiTOq72JU" height="1" width="1"/&gt;</description><feedburner:origLink>http://www.cadence.com/Community/blogs/sd/archive/2009/02/18/how-to-save-os-boot-time-in-your-systemc-virtual-platform-with-save-and-restore.aspx</feedburner:origLink></item><media:rating>nonadult</media:rating></channel></rss>

