<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Màrius on TLM</title>
	<atom:link href="http://blogtlm.mariusmonton.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogtlm.mariusmonton.com</link>
	<description>Blog sobre SystemC-TLM-2</description>
	<lastBuildDate>Mon, 06 Feb 2012 13:46:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A very interesing final degree project</title>
		<link>http://blogtlm.mariusmonton.com/en/2011/12/un-proyecto-final-de-carrera-interesante/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2011/12/un-proyecto-final-de-carrera-interesante/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:31:27 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[SoC]]></category>
		<category><![CDATA[SystemC]]></category>
		<category><![CDATA[TLM]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=356</guid>
		<description><![CDATA[Iván Albarrán me ha hecho llegar su Trabajo Final de Carrera titulado &#8220;Análisis de arquitecturas SoCs mediante modelos SystemC&#8221;. En este proyecto Iván crea un modelo de simulación genérico para un SoC (System on Chip) que permita realizar un análisis de prestaciones de distintas arquitecturas. Para esto usa, cómo no, TLM como se puede ver en [...]]]></description>
			<content:encoded><![CDATA[<p>Iván Albarrán me ha hecho llegar su Trabajo Final de Carrera titulado &#8220;<strong>Análisis de arquitecturas SoCs mediante modelos SystemC&#8221;</strong>.</p>
<p>En este proyecto Iván crea un modelo de simulación genérico para un SoC (System on Chip) que permita realizar un análisis de prestaciones de distintas arquitecturas. Para esto usa, cómo no, TLM como se puede ver en la figura</p>
<div>
<dl id="attachment_357">
<dt><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2011/12/bloquesTLM.png"><img title="Diagrama de bloques del sistema (en TLM)" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2011/12/bloquesTLM-300x192.png" alt="" width="300" height="192" /></a></dt>
<dd>Diagrama de bloques del sistema (en TLM)</dd>
</dl>
</div>
<div>El trabajo que ha hecho me parece excelente,  las explicaciones de cada uno de los conceptos detrás de TLM-2.0 están, a mi entender, muy bien explicados. Y los resultados en cuanto a tiempos de simulación respecto a la cantidad de Initiators y cantidad de transacciones muy ilustrativas de la potencia de TLM para simular sistemas grandes y complejos.</div>
<div></div>
<div>Si queréis leer la memoria del proyecto, la podéis descargar de <a title="aquí" href="http://blogtlm.mariusmonton.com/wp-content/uploads/2011/12/PFC_ivan_albarran.pdf">aqu</a>í (PDF).</div>
<div></div>
<div>En breve colgaremos el código completo para poder usarlo en ejemplos posteriores.</div>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2011/12/un-proyecto-final-de-carrera-interesante/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Open Hardware Licenses</title>
		<link>http://blogtlm.mariusmonton.com/en/2011/07/licencias-open-hardware/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2011/07/licencias-open-hardware/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 15:59:59 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[BSD]]></category>
		<category><![CDATA[CERN]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[LGPL]]></category>
		<category><![CDATA[licencia]]></category>
		<category><![CDATA[licencias]]></category>
		<category><![CDATA[OHL]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=335</guid>
		<description><![CDATA[Sorry, this entry is only available in Español.]]></description>
			<content:encoded><![CDATA[<p>Sorry, this entry is only available in <a href="http://blogtlm.mariusmonton.com/feed/">Español</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2011/07/licencias-open-hardware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Class to log them all</title>
		<link>http://blogtlm.mariusmonton.com/en/2011/01/one-class-to-log-them-all/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2011/01/one-class-to-log-them-all/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 09:21:36 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Log]]></category>
		<category><![CDATA[singleton]]></category>
		<category><![CDATA[SystemC]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=212</guid>
		<description><![CDATA[A good way to retrieve information of what is happening in our SystemC simulations is to generate a log file with the information that we need (module name, simulation time, what phase is going on, etc.). The most elegant and easy way to do that is to create a special class for that task, that [...]]]></description>
			<content:encoded><![CDATA[<p>A good way to retrieve information of what is happening in our SystemC simulations is to generate a <em>log</em> file with the information that we need (module name, simulation time, what phase is going on, etc.).</p>
<p>The most elegant and easy way to do that is to create a special class for that task, that the other modules in the simulation can use to send their information and to be stores in disk. This can be achieved designing a <a style="font-weight: bold;" title="Singleton in Wikipedia" href="http://en.wikipedia.org/wiki/Singleton_pattern" target="_blank">singleton</a> type class. This design pattern restricts the instantiation of a class to one single object. In our case, it will cause that all modules use the same object and log file.<br />
<span id="more-212"></span></p>
<p>To design a singleton class, we may take into account:</p>
<ul>
<li>The class itself creates the unique instantiation</li>
<li>Declare the constructor as private so the class cannot be directly instantiated</li>
<li>Allow to access to the object only through a class method</li>
</ul>
<p>This can be done creating a class with a private constructor and a method that creates the object if it is not created yet and returns the reference to the object:</p>
<p><code lang="cpp"><br />
Log.h file</code></p>
<p><code lang="cpp">class Log<br />
{</p>
<p>public:</p>
<p>static Log*  Instance();</p>
<p></code></p>
<p><code lang="cpp">private:<br />
Log(const char*);<br />
static Log* m_pInstance;<br />
std::ofstream m_stream;<br />
...<br />
}<br />
</code></p>
<p><code lang="cpp"><br />
Log.cpp file</code></p>
<p><code lang="cpp">Log* Log::m_pInstance = NULL;</p>
<p>Log*<br />
Log::Instance()<br />
{<br />
if (!m_pInstance)<br />
m_pInstance = new Log("Log.txt");<br />
return m_pInstance;</p>
<p>}</p>
<p>Log::Log(const char* filename)<br />
{<br />
m_stream.open(filename);<br />
}</p>
<p></code></p>
<p>&nbsp;</p>
<p>Every module willing to use this class, may call it in the following way:</p>
<p>&nbsp;</p>
<p><code lang="cpp">Log *my_log = Log::Instance();</p>
<p></code></p>
<p>&nbsp;</p>
<p>To finish, we add some methods to store into a file the information we want to the Log class:</p>
<p>&nbsp;</p>
<p><code lang="cpp">// Method to be called this way: my_log-&gt;SC_log("My log message");<br />
void<br />
Log::SC_log(std::ostringstream msg)<br />
{<br />
m_stream &lt;&lt; "time " &lt;&lt; sc_core::sc_time_stamp() &lt;&lt; ": "<br />
&lt;&lt; msg &lt;&lt; std::endl; } // Method to be used inside C++ streams // we can write: my_log-&gt;SC_log() &lt;&lt; name() &lt;&lt; ". My log message" &lt;&lt; std::endl;<br />
std::ofstream&amp;<br />
Log::SC_log()<br />
{<br />
m_stream &lt;&lt; "time " &lt;&lt; sc_core::sc_time_stamp() &lt;&lt; ": ";<br />
return m_stream;<br />
}</p>
<p></code></p>
<p>&nbsp;</p>
<p>In the second case, the log file is in plain text with in each line the simulation time, the module name and the desired text. We can use some other library to generate a XML file or something more structured, but that is another post <img src='http://blogtlm.mariusmonton.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>And that&#8217;s all to have a common log file for all your simulations in a easy and elegant way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2011/01/one-class-to-log-them-all/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Eclipse to develop TLM-2 projects</title>
		<link>http://blogtlm.mariusmonton.com/en/2010/08/configuring-eclipse-to-develop-tlm-2-projects/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2010/08/configuring-eclipse-to-develop-tlm-2-projects/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 18:58:59 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[SystemC]]></category>
		<category><![CDATA[TLM]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=204</guid>
		<description><![CDATA[Today I tell you how to create a project in eclipse for work with TLM-2 and SystemC, it&#8217;s very easy! First step is to download eclipse for C/C++ development from here. Let&#8217;s begin: create a new C++ project Next screen ask what type of eclipse project to use, we choose Executable and Empty Project In [...]]]></description>
			<content:encoded><![CDATA[<p>Today I tell you how to create a project in eclipse for work with TLM-2 and SystemC, it&#8217;s very easy!</p>
<p><span id="more-204"></span>First step is to download eclipse for C/C++ development from <a title="http://www.eclipse.org/downloads/" href="http://www.eclipse.org/downloads/" target="_blank">here</a>.</p>
<p>Let&#8217;s begin: create a new C++ project</p>
<div class="mceIEcenter">
<dl id="attachment_180" class="aligncenter">
<dt><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/creeate_project.jpg"><img title="creeate_project" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/creeate_project-300x298.jpg" alt="" width="300" height="298" /></a></dt>
</dl>
</div>
<p>Next screen ask what type of eclipse project to use, we choose <strong>Executable</strong> and <strong>Empty Project</strong></p>
<p><strong> </strong></p>
<p style="text-align: center;"><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/C++_Project.jpg"><img class="aligncenter" title="C++_Project" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/C++_Project-274x300.jpg" alt="C++ Project" width="274" height="300" /></a></p>
<p>In the next screen, click on <strong>Advanced Settings</strong>, where we can add PATHs to SystemC library and header and TLM-2 header</p>
<p>Choose <strong>GCC C++ Compiler</strong>-&gt; <strong>Preprocessor </strong>and we add SC_INCLUDE_DYNAMIC_PROCESSES in <strong>Defined symbols.<br />
</strong></p>
<p><strong> </strong></p>
<p style="text-align: center;"><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/settings_1.jpg"><img class="aligncenter" title="settings_1" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/settings_1-300x234.jpg" alt="" width="300" height="234" /></a></p>
<p style="text-align: left;">Then we choose <strong>Directories </strong>from  the same menu and we add the PATHs to the SystemC directory and TLM-2 directory (note the ending of each PATH)</p>
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/settings_1b.jpg"><img class="aligncenter" title="settings_1b" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/settings_1b-300x234.jpg" alt="" width="300" height="234" /></a></p>
<p>Lastly, in <strong>GCC C++ Linker</strong>-&gt; <strong>Libraries</strong> we add the PATH to the SystemC library (note that this path ends with /lib-linux/)</p>
<p style="text-align: center;"><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/settings_2.jpg"><img class="aligncenter" title="settings_2" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/settings_2-300x234.jpg" alt="" width="300" height="234" /></a></p>
<p>If all were fine, we will have the project created and ready to be used in the eclipse main screen:</p>
<p style="text-align: center;"><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/project_created_1.jpg"><img class="aligncenter" title="project_created_1" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/project_created_1-236x300.jpg" alt="" width="236" height="300" /></a></p>
<p>Now, we can add new files to the project, just right click on the project name and pick new-&gt;source file o  new-&gt; header file</p>
<p style="text-align: center;"><a href="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/new_source.jpg"><img class="aligncenter" title="new_source" src="http://blogtlm.mariusmonton.com/wp-content/uploads/2010/04/new_source-300x294.jpg" alt="" width="300" height="294" /></a></p>
<p>Fill the name of the new file (with extension), and we can start typing our code!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2010/08/configuring-eclipse-to-develop-tlm-2-projects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loosely-timed example</title>
		<link>http://blogtlm.mariusmonton.com/en/2009/03/ejemplo-loosely-timed/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2009/03/ejemplo-loosely-timed/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 19:14:59 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[loosely-timed]]></category>
		<category><![CDATA[simple_initiator_socket]]></category>
		<category><![CDATA[simple_target_socket]]></category>
		<category><![CDATA[Socket]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=119</guid>
		<description><![CDATA[First of all, I should remember you what means loosely-timed: we use the blocking function b_transport and therefore we have two synchronization points per transaction, that corresponds to the beginning and the end of the transaction. These two points  can be in the same simulation time or in different simulation time. In case we have the two [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, I should remember you what means<em> loosely-timed</em>: we use the blocking function <strong>b_transport</strong> and therefore we have two synchronization points per transaction, that corresponds to the beginning and the end of the transaction. These two points  can be in the same simulation time or in different simulation time. In case we have the two synchronization points in the same simulation time, we are using <em>untimed</em>).</p>
<p><span id="more-119"></span></p>
<p>Thus, the only thing that varies in this way about the untimed mode is that in this case the function <strong>b_transport </strong>calls <strong> wait ()</strong>, and thus allow the simulation time increases. This wait will be called by the target (inside the function <strong>b_transport</strong>) and models the time the device takes to respond to the transaction, for example the access time to a memory, or the time an I2C controller spent getting a data from a  external FLASH &#8230;</p>
<p>Retrieve the <a title="Ejemplo untimed" href="http://blogtlm.mariusmonton.com/?p=43">untimed</a> example that we have nearly all we need.</p>
<p>Notice that the second parameter of the <strong> b_transport</strong> function (type sc_time) remains zero. This parameter will help us if we use temporal decoupling, and that is where we indicate the time ahead of the simulation that takes the current transaction. That&#8217;s discussed in the next example of the series.</p>
<p>Note that this mode is mainly used because it is simple to use because we use the blocking method, and allows us to write down times, and therefore have a simulation that will give us information of how long it takes to run a process, how long implementation is needed even complete a task, etc..</p>
<p>And so far this &#8220;example&#8221;, you see there&#8217;s not much difference in code with  <em>untimed</em>, although there is in difference in concept and results to be obtained. The code you have it available <a title="Ejemplo loosely-timed" href="http://www.mariusmonton.com/TLMexamples/loosely_timed_simple.tar.gz">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2009/03/ejemplo-loosely-timed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DMI example</title>
		<link>http://blogtlm.mariusmonton.com/en/2009/03/ejemplo-dmi/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2009/03/ejemplo-dmi/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 16:52:23 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Direct Memory Interface]]></category>
		<category><![CDATA[DMI]]></category>
		<category><![CDATA[example]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=105</guid>
		<description><![CDATA[Let&#8217;s go with the Direct Memory Inteface (DMI) defined in TLM-2.0. DMI mechanism in roughly speaking is to pass over transactions, protocols and so on. In short, the Target sends a pointer to its memory region (o part of it) to the Initiator to allow him to that memory region directly, without using transaction. This [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s go with the Direct Memory Inteface (DMI) defined in TLM-2.0. DMI mechanism in roughly speaking is to pass over transactions, protocols and so on. In short, the <em>Target </em>sends a pointer to its memory region (o part of it) to the <em>Initiator</em> to allow him to that memory region directly, without using transaction. This way, we speed up the simulation, because everything is more easy.  DMI is focsed on memory type devices connected to modules that are accessing very frequently to that memory devices, like CPUs or DMAs. But the mechanism is there, and we can use it in any of our modules.<br />
<span id="more-105"></span><br />
And what we should do?</p>
<h2>Target</h2>
<p>In the <em>target</em> side we need to do two things: to register the function that publishes the pointer and fill the structure to publish the pointer.<br />
To register the function:<br />
<code lang="cpp"><br />
target_socket.register_get_direct_mem_ptr(this, &amp;Target::my_get_direct_mem_ptr);<br />
</code><br />
and then write the function:<br />
<code lang="cpp"><br />
bool Target::my_get_direct_mem_ptr(tlm::tlm_generic_payload&amp;, tlm::tlm_dmi&amp; dmi_data)<br />
{<br />
dmi_data.allow_read_write();<br />
dmi_data.set_start_address( 0 );<br />
dmi_data.set_end_address( 10 );<br />
dmi_data.set_read_latency( sc_time(10, SC_NS) );<br />
dmi_data.set_write_latency( sc_time(10, SC_NS) );</code><br />
<code lang="cpp"> </code><br />
<code lang="cpp"> dmi_data.set_dmi_ptr( reinterpret_cast ( &amp;data[0]) );<br />
return true;<br />
}<br />
</code><br />
Note that in this function we only fill the dmi_data structure, in this case telling that the memory region to use can be used to write and to read, what is its start and end address, and what read and write latency has. Those times can be used by the <em>Initiator</em> to simulate the access time if it like to. Lastly, we put the pointer to our memory region (in the example our data array), doing a C++ <em>cast </em> to unsiged char, that is the standard data type for all TLM-2.0</p>
<p>Later, to tell to <em>Initiator</em> that our module is DMI capable, we may mark a field in the transaction:<br />
<code lang="cpp"><br />
void Target::b_transport( tlm::tlm_generic_payload&amp; transaction, sc_time&amp; delay )<br />
...<br />
transaction.set_dmi_allowed( true );<br />
...<br />
</code></p>
<p>This way, when a <em>Initiator</em> talks to our <em>Target </em>using a normal transaction (blocking or no-blocking) it can check that this <em>Target </em> is DMI capable.<br />
<strong> </strong></p>
<p><strong>Initiator</strong></p>
<p>First step to use DMI in our <em>Initiator</em> is to write the function that the <em>Target </em>can use to tell to <em>Initiator</em> that the DMI pointer is not longer valid (for any reason)</p>
<p>So we add a new method to our <em>Initiator</em> class:</p>
<p><code lang="cpp"><br />
void Initiator::invalidate_direct_mem_ptr(sc_dt::uint64 start, sc_dt::uint64 end)<br />
{<br />
dmi_ptr_valid = false;<br />
}<br />
</code></p>
<p>And we register it in the socket:<br />
<code lang="cpp"><br />
Initiator::Initiator(sc_module_name name_):<br />
...<br />
initiator_socket.register_invalidate_direct_mem_ptr(this, &amp;Initiator::invalidate_direct_mem_ptr);<br />
dmi_ptr_valid = false;<br />
...<br />
}<br />
</code></p>
<p>Later, the <em>Initiator </em> should first find if the <em>Target</em> device allows DMI (remember, it&#8217;s always optional). For that, <em>Initiator</em> may check a field of a transaction already responded by the <em>Target</em>. If <em>Target</em> allows DMI, would set to true that field.<br />
<code lang="cpp"><br />
...<br />
if (transaction.is_dmi_allowed() ) {<br />
dmi_ptr_valid = initiator_socket-&gt;get_direct_mem_ptr( transaction, dmi_data);<br />
}<br />
...<br />
</code></p>
<p>Note that in the previous two lines I made two different things: ask to the previous transactoin if <em>Target </em>allows DMI using <strong>is_dmi_allowed()</strong> method from transaction. Then, if <em>Target allows it</em>, we ask for the pointer, passing to <em>Target</em> the transaction with the address we want to access, and getting a <em>true</em> or <em>false </em>depending if DMI pointer is valid or not.</p>
<p>Following the example, if the <em>Target </em>allows DMI:<br />
<code lang="cpp"><br />
...<br />
// El target acepta DMI, usamos el puntero directamente<br />
unsigned char* dmi_ptr = dmi_data.get_dmi_ptr();<br />
memcpy(dmi_ptr + (i*sizeof(data)), &amp;data, sizeof(data) );<br />
std::cout &lt;&lt; "Initiator: " &lt;&lt; sc_time_stamp() &lt;&lt; "Escribiendo " &lt;&lt; data &lt;&lt; ". DMI OK" &lt;&lt; std::endl;<br />
...</code></p>
<p><code lang="cpp"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">It's time to get the pointer to the <em>Target </em>data using the method<strong> dmi_data.get_dmi_ptr()</strong> and later we can use that pointer usually.</span></code></p>
<p>Although I&#8217;ve left as is, it is not necessary to get the DMI pointer each time we are going to use it. We may ask for it once, and only check that it is still valid (in the example using the global variable<em> dmi_ptr_valid</em>) before we use it.</p>
<p>And that&#8217;s all for that example. It lacks the option to invalidate the pointer time to time in the <em>Target</em>. But it&#8217;s your homework <img src='http://blogtlm.mariusmonton.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . (If <em>target</em> wants to invalidate the DMI pointer, it only may call<strong> invalidate_direct_mem_ptr </strong>method of its <em>socket).</em></p>
<p>Full example is <a href="http://www.mariusmonton.com/TLMexamples/DMI_example.tar.gz">in this link</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2009/03/ejemplo-dmi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loosely time and temporal decoupling</title>
		<link>http://blogtlm.mariusmonton.com/en/2009/02/loosely-time-y-temporal-decoupling/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2009/02/loosely-time-y-temporal-decoupling/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 10:55:27 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[loosely-timed]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=92</guid>
		<description><![CDATA[This coding style works with 2 timing points in each transaction, one in the function call and the other in the return for the b_transport function (using the base protocol these points corresponds to the start of the petition and the start of the response). We can put these two points in the same time to mark [...]]]></description>
			<content:encoded><![CDATA[<p>This coding style works with 2 timing points in each transaction, one in the function call and the other in the return for the <strong>b_transport</strong> function (using the base protocol these points corresponds to the start of the petition and the start of the response). We can put these two points in the same time to mark that the transaction is not using time.</p>
<p><span id="more-92"></span></p>
<p>Time passed as parameter to the <strong>b_transport</strong> function marks start time of the transaction from the actual simulation time. In normal use, that time will be always 0 (unless we are using temporal decoupling). The target can use <em>wait()</em> inside the <strong>b_transport</strong> function to spend simulation time or can return<br />
immediately and modify the time parameter to mark what time he spent. Later, the Initiator may call <em>wait()</em> for that time to increase simulation time.</p>
<p>That system allows the use of temporal decoupling. This mechanism allows parts of our design to run ahead the global simulation time until it needs to communicate with others system models, when it synchronizes again with the global simulation time.</p>
<p>When a temporal decoupled module in advanced time needs to communicate with other module we have two options:</p>
<ul>
<li>Assume a value for that communication</li>
<li>Synchronize with whole system: wait for global simulation time arrives to its simulation time.</li>
</ul>
<p lang="es-ES">In this technique we use <strong>b_transport,</strong> filling the time parameter in the function call. In this parameter we annotate the time that our modules are ahead the simulation time, so the Target returns in the time parameter the offset time about simulation time. This means that adding that parameter time to actual simulation time give us the advanced simulation time for that Target.</p>
<p lang="es-ES">And why is that for? Because with this technique we boost simulation speed, because SystemC simulator had less context switching and less overhead of guessing what module is next to simulate.</p>
<p lang="es-ES">If we allow one module to run ahead with no limit, others parts of the simulation would never be simulated. To avoid that, TLM-2.0 introduces <em>global quantum,</em> that&#8217;s the maximum time that a module can be ahead global simulation time. That <em>quantum </em>can be modified in the simulation, and is a trade off between simulation speed and simulation accuracy. If this <em>quantum</em> is small, our simulation will have lot of synchronization (and lost of performance), but if we chose a big value for this <em>quantum</em>, simulation can be wrong.</p>
<p lang="es-ES">The typical example of using temporal decoupling is the simulation of a system with a CPU, memory, one timer and some slow peripheral (a UART). Software running on the simulated CPU basically fetches instructions from memory and executes them in the CPU, and only interact with the rest of the system when timer triggers and interrupt (i.e. every 1 millisecond). In this case, the CPU module can run ahead global simulation until 1 millisecond, accessing directly to memory (using DMI). In this way, it&#8217;s possible to have a very detailed model of the timer without slowing simulation performance.</p>
<p lang="es-ES">This mechanism can be started and stopped dynamically in the simulation. Can be useful to have a first part of the simulation very fast and unaccurate, and then disable temporal decoupling to have better accuracy losing some simulation performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2009/02/loosely-time-y-temporal-decoupling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Untimed example</title>
		<link>http://blogtlm.mariusmonton.com/en/2009/01/ejemplo-de-untimed/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2009/01/ejemplo-de-untimed/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 00:13:43 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[simple_initiator_socket]]></category>
		<category><![CDATA[simple_target_socket]]></category>
		<category><![CDATA[Socket]]></category>
		<category><![CDATA[untimed]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=43</guid>
		<description><![CDATA[Let&#8217;s start with the first example&#8230; Initiator We shall start with the include&#8217;s #include using namespace sc_core; #include "tlm.h" #include "tlm_utils/simple_initiator_socket.h" Firstly we include systemc and then tlm.h Then we include the easiest socket for that example. Now it&#8217;s time to declare the Initiator class class Initiator: sc_module { public: tlm_utils::simple_initiator_socket initiator_socket; SC_HAS_PROCESS(Initiator); Initiator(sc_module_name name_); [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s start with the first example&#8230;</p>
<h2>Initiator</h2>
<p>We shall start with the include&#8217;s</p>
<p><code lang="cpp"><br />
#include <systemc.h></p>
<p>using namespace sc_core;</p>
<p>#include "tlm.h"<br />
#include "tlm_utils/simple_initiator_socket.h"<br />
</code></p>
<p>Firstly we include systemc and then tlm.h<br />
Then we include the easiest socket for that example.<br />
Now it&#8217;s time to declare the <em>Initiator</em> class</p>
<p><code lang="cpp"><br />
class Initiator: sc_module<br />
{<br />
public:<br />
  tlm_utils::simple_initiator_socket initiator_socket<Initiator>;<br />
  SC_HAS_PROCESS(Initiator);<br />
  Initiator(sc_module_name name_);</p>
<p>private:<br />
  void initiator_thread();<br />
};<br />
</code></p>
<p><span id="more-43"></span><br />
Lot of interesting things there: Firstly we define the Initiator class as dereived from sc_module. Following we declare a simple_initiator <em>socket</em>, we name it initiator_socket (very original&#8230;). To this <em>template</em> (we use a lot of them), we pass as parameter the class that contains it.</p>
<p>Later we declare the constructor with the macro SC_HAS_PROCESS().<br />
Finally we declare a method to be SC_THREAD called initiator_thread (another original name).</p>
<p><code lang="cpp"><br />
...<br />
double data;<br />
tlm::tlm_generic_payload transaction;</p>
<p>sc_time delay = SC_ZERO_TIME;<br />
...<br />
</code></p>
<p>In the SC_THREAD we declare a transaction variable and a sc_time variable to annotate times (it will be 0, but we must declare it). We also declare the variable data of type double that it will be data to send between modules.</p>
<p><code lang="cpp"><br />
transaction.set_data_length( sizeof(data) );<br />
transaction.set_streaming_width( sizeof(data) );<br />
transaction.set_byte_enable_ptr(0);<br />
transaction.set_dmi_allowed(false);<br />
transaction.set_response_status( tlm::TLM_INCOMPLETE_RESPONSE );<br />
transaction.set_data_ptr( reinterpret_cast<unsigned char*>(&#038;data) );<br />
</code></p>
<p>We fill the transaction fields, names are self-explanatory. I comment last lines.<br />
We declare the transaction as TLM_INCOMPLETE_RESPONSE (standard says that).<br />
Then we prepare data, for that, we put the transaction pointer to point to our data and do a C++ cast.<br />
Note that the transaction only moves the pointer to data, not the data.</p>
<p><code lang="cpp"><br />
transaction.set_command( tlm::TLM_WRITE_COMMAND );<br />
transaction.set_address( i );<br />
initiator_socket-&#038;>b_transport( transaction, delay);<br />
</code></p>
<p>These three lines fill the transaction fields to be a write, the address to write to, and the transaction is done using <strong>b_transport</strong> function call. To that function we pass the transaction and the time for that transaction (will be 0 for this example).</p>
<p><code lang="cpp"><br />
if (transaction.get_response_status() == tlm::TLM_OK_RESPONSE)<br />
</code></p>
<p>Next we check if Target answers with a TLM_OK_RESPONSE saying that transaction is done.<br />
Example follows performing reads instead of writes (changing TLM_READ in the proper field, of course).</p>
<h2>Target</h2>
<p>Let&#8217;s see the Target code:</p>
<p><code lang="cpp"><br />
#include "tlm_utils/simple_target_socket.h"<br />
...<br />
tlm_utils::simple_target_socket target_socket<Target>;<br />
</code></p>
<p>We include the <em>header</em> for the Target socket and we declare a variable with the socket (with the class itself as template  parameter).</p>
<p>Constructor code:</p>
<p><code lang="cpp"><br />
Target::Target(sc_module_name name_):<br />
  sc_module(name_),<br />
  target_socket("target_socket")<br />
{<br />
  target_socket.register_b_transport(this, &#038;Target::b_transport);<br />
}<br />
</code></p>
<p>All seems normal, but the last line is a little tricky: here we register what function implements the method <strong>b_transport</strong></p>
<p>Following, the function:</p>
<p><code lang="cpp"><br />
void Target::b_transport( tlm::tlm_generic_payload&#038; transaction, sc_time&#038; delay )<br />
{<br />
  tlm::tlm_command command = transaction.get_command();<br />
  sc_dt::uint64    address = transaction.get_address();<br />
  unsigned char*   data_ptr = transaction.get_data_ptr();<br />
  unsigned int     length = transaction.get_data_length();<br />
  unsigned char*   byte_enable_ptr = transaction.get_byte_enable_ptr();<br />
  unsigned int     width = transaction.get_streaming_width();<br />
  double *my_data_ptr;<br />
  if (command == tlm::TLM_WRITE_COMMAND) {<br />
    data[address] = *(reinterpret_cast<float*>( data_ptr ) );<br />
    std::cout << "Target Write: " << sc_time_stamp() << ". Data: " << data[address] << std::endl;<br />
  } else {<br />
    my_data_ptr = reinterpret_cast<double*>(data_ptr);<br />
    *my_data_ptr = data[address];<br />
    std::cout << "Target Read: " << sc_time_stamp() << ". Data " << data[address] << std::endl;<br />
  }</p>
<p>  transaction.set_response_status(tlm::TLM_OK_RESPONSE );<br />
  return;<br />
}<br />
</code></p>
<p>First we collect all transaction parameters, and then if the transaction is read or write, we do the right copy between data.<br />
Look again: transaction only contains the pointer to data, no the data, so we need to access to data using that pointer casted.<br />
Finally, we put the status of the transaction to an <strong>OK</strong> (TLM_OK_RESPONSE) and return from the function.</p>
<p>Here ends the <strong>untimed </strong>example, easy! <img src='http://blogtlm.mariusmonton.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Download full code example from <a href="http://www.mariusmonton.com/TLMexamples/untimed_simple.tar.gz">en este enlace</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2009/01/ejemplo-de-untimed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Interfaces, sockets, DMI y demás</title>
		<link>http://blogtlm.mariusmonton.com/en/2009/01/interfaces-sockets-dmi-y-demas/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2009/01/interfaces-sockets-dmi-y-demas/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 00:11:02 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[DMI]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Socket]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=72</guid>
		<description><![CDATA[Interfaces Cuando usamos el canal normal para comunicar un Initiator con un Target usamos los interfaces que se definen en TLM2.0. De hecho, un Initiator crea una transacción y la pasa como argumento al método del interface (ya sea bloqueante o no). Este método lo implementa el Target que recibe la transacción y hace con [...]]]></description>
			<content:encoded><![CDATA[<h2>Interfaces</h2>
<p>Cuando usamos el canal normal para comunicar un <em>Initiator</em> con un <em>Target</em> usamos los interfaces que se definen en TLM2.0. De hecho, un <em>Initiator</em> crea una transacción y la pasa como argumento al método del interface (ya sea bloqueante o no). Este método lo implementa el <em>Target</em> que recibe la transacción y hace con ella lo que deba (la ejecuta). Este camino se conoce como <strong>forward path</strong>. Una vez el <em>Target</em> ha ejecutado la transacción, debe retornar al <em>Initiator</em>, y puede hacerse de dos formas distintas: a través de llamadas a métodos desde el <em>Target</em> al <em>Initiator</em> (a este camino se le llama el <strong>backward path</strong>; o usando el retorno del método del interface (se conoce como <strong>return path</strong>).</p>
<h2><span id="more-72"></span>DMI</h2>
<p>Existe un interface especial, llamado <strong>Direct Memory Interface</strong> que proporciona acceso directo a áreas de memoria dentro de un <em>Target</em> permitiendo acceder directamente, sin tener que pasar por todos los posibles componentes del sistema (bridges, árbitros, etc) usando un puntero a esa zona de memoria en lugar de acceder mediante llamadas a <strong>b_transport</strong> o <strong>nb_transport</strong>. Este interface especial esta pensado para acelerar las simulaciones donde se use masivamente accesos a memoria.</p>
<h2>Debug Interface</h2>
<p>Este intterface proporciona acceso inmediato y no intrusivo a un <em>Target</em>, de manera que cualquier lectura o escritura a través del Debug interface usará la misma estructura que el <strong>forward path</strong>, pero sin ningún tipo de delay o wait o notificación de evento, etc. Digamos que el resto del Target &#8220;no se entera&#8221; de que ha sido accedido.</p>
<h2>Sockets</h2>
<p>Para simplificar la interconexión entre módulos, TLM-2.0 nos ofrece <strong>sockets</strong>, que agrupa y &#8220;gestiona&#8221; tanto el <em>forward</em> como el <em>backward path</em> (y DMI y Debug Interface), habiendo <strong>sockets</strong> para <em>Initiator</em> (Initiator socket) y sockets para <em>Target</em> (Target socket). Desde TLM-2.0 se recomienda el uso de sockets en lugar de los interfaces por facilidad de uso y portabilidad.</p>
<p>TLM-2.0 define una serie de distintos <strong>sockets</strong> (<strong>convenience sockets</strong>) que implementen distintas características. Aquí va una tabla resumen:</p>
<table style="text-align: center;" border="0">
<tbody>
<tr>
<th>Socket</th>
<th>Registra Callbacks</th>
<th>Multiports</th>
<th>Conversión b/nb</th>
<th>Tagged</th>
<th>Binding</th>
</tr>
<tr>
<td style="text-align: left;">tlm_*_socket</td>
<td>No</td>
<td>Si</td>
<td>No</td>
<td>No</td>
<td>Si</td>
</tr>
<tr>
<td style="text-align: left;">simple_*_socket</td>
<td>Si</td>
<td>No</td>
<td>Si</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td style="text-align: left;">simple_*_socket_tagged</td>
<td>Si</td>
<td>No</td>
<td>Si</td>
<td>Si</td>
<td>No</td>
</tr>
<tr>
<td style="text-align: left;">passthrough_target_socket</td>
<td>Si</td>
<td>No</td>
<td>No</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td style="text-align: left;">passthrough_target_socket_tagged</td>
<td>Si</td>
<td>No</td>
<td>No</td>
<td>Si</td>
<td>No</td>
</tr>
<tr>
<td style="text-align: left;">multi_passthrough_*_socket</td>
<td>Si</td>
<td>Si</td>
<td>No</td>
<td>Si</td>
<td>Si</td>
</tr>
</tbody>
</table>
<p><strong>Socket</strong>: Nombre de la clase y del socket</p>
<p><strong>Registra Callbacks</strong>:Indica si el socket proporciona una función para registrar una función cualquiera como función <strong>transport</strong>.</p>
<p><strong>Multiport</strong>: Si el socket permite conectar múltiples <em>Initiators</em> a un <em>Target</em> o al revés.</p>
<p><strong>Conversión b/nb</strong>: el <em>Target </em>socket convierte las llamadas a <strong>b_transport</strong> a <strong>nb_transport</strong> (pasa una llamada bloqueante a no-bloqueante)</p>
<p><strong>Tagged</strong>: Cada interface son etiquetados (<em>tagged</em>) para saber por qué socket han llegado</p>
<p><strong>Binding:</strong> Si el socket permite conexión jerárquica, de manera que un Modulo puede tener &#8220;dentro&#8221; un <em>Initiator</em> y su socket conectado a éste.</p>
<p>En otra entrada del blog explicaremos cada uno de los <strong>sockets</strong> disponibles en el estandard.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2009/01/interfaces-sockets-dmi-y-demas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coding Styles</title>
		<link>http://blogtlm.mariusmonton.com/en/2008/12/estilos-de-codificacion-coding-styles/</link>
		<comments>http://blogtlm.mariusmonton.com/en/2008/12/estilos-de-codificacion-coding-styles/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 21:16:23 +0000</pubDate>
		<dc:creator>marius</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[approximately-timed]]></category>
		<category><![CDATA[loosely-timed]]></category>
		<category><![CDATA[SystemC]]></category>
		<category><![CDATA[TLM]]></category>
		<category><![CDATA[untimed]]></category>

		<guid isPermaLink="false">http://blogtlm.mariusmonton.com/?p=13</guid>
		<description><![CDATA[TLM-2 lists modeling 3 different modes (called Coding Styles in official documents): untimed, Loosely-timed and Approximately-timed. Each serves a specific purpose, and to model different types of systems. We must also take into account the cost of each simulation mode (untimed less expensive, Approximatelly-timed more expensive). Untimed This mode uses only the blocking interface. This [...]]]></description>
			<content:encoded><![CDATA[<p><strong>TLM-2</strong> lists modeling 3 different modes (called Coding Styles in official documents): <em>untimed</em>, <em>Loosely-timed</em> and <em>Approximately-timed</em>. Each serves a specific purpose, and to model different types of systems. We must also take into account the cost of each simulation mode (<em>untimed</em> less expensive, <em>Approximatelly-timed</em> more expensive).</p>
<h2><span id="more-13"></span><br />
<em> Untimed</em></h2>
<p>This mode uses only the <strong>blocking</strong> interface. This interface carries no information on response times, simply <em>initiator</em> uses the <strong>b_transport</strong> function to send data to <em>target</em>.</p>
<p>Is the most simple basis to use and simulate, and we can use to verify that the system is well designed and partitioned.</p>
<h2><em>Loosely-timed</em></h2>
<p>This mode also uses the <strong>blocking</strong> interface. Thus we have two points of time: <strong>b_transport</strong> function call and return (when it begins and when ends the transaction).</p>
<p>This mode allows use <em>temporary decoupling</em>. We can talk about this in another post, but the idea is that we have parts of our model and run &#8220;in his own time&#8221; until they need to synchronize with the rest of the model.</p>
<h2><em>Approximately timed</em></h2>
<p>This mode uses <strong>non-blocking</strong> interface, so you can record times in all phases of a transaction (typically a protocol is 3 or 4 phases).</p>
<p>This mode is the most detailed and therefore also be the slowest simulated.</p>
<p>These are the 3 ways that provide for the TLM-2.0 Standard (anyone needs something more?) And we talk in detail about each in future posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogtlm.mariusmonton.com/en/2008/12/estilos-de-codificacion-coding-styles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

