<?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>The CoVerification Blog</title>
	<atom:link href="http://coverification.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://coverification.com</link>
	<description>Software Assisted Hardware Verification</description>
	<lastBuildDate>Mon, 30 May 2011 12:24:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>SystemVerilog Snippets for VIM users</title>
		<link>http://coverification.com/2010/01/20/systemverilog-snippets-for-vim-users/</link>
		<comments>http://coverification.com/2010/01/20/systemverilog-snippets-for-vim-users/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 22:30:39 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[OVM]]></category>
		<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[Vim]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">https://coverification.org/?p=388</guid>
		<description><![CDATA[Just in case you are an Emacs user, you can download and use the equivalent snippets for Emacs from this link. As far as possible, I am using a common codebase for VIM and Emacs SV snippets. So if you use VIM, your snippets would seem much familiar to a colleague at work who loves [...]]]></description>
				<content:encoded><![CDATA[<p>Just in case you are an Emacs user, you can download and use the equivalent snippets for Emacs from <a href="http://coverification.org/2009/12/17/systemverilog-snippets-for-emacs/">this link</a>. As far as possible, I am using a common codebase for VIM and Emacs SV snippets. So if you use VIM, your snippets would seem much familiar to a colleague at work who loves Emacs.</p>
<p>Just like Emacs, multiple packages are available for VIM that enable use of code snippets within VIM. Of these I used a package named SnipMate for the purpose of exploring VMM snippets in VIM. If you have not used SnipMate before, the following YouTube video provides a wonderful introduction to the package and its use.<span id="more-388"></span></p>
<p><a href="http://www.youtube.com/watch?v=_galFWwSDt0&#038;fmt=18">http://www.youtube.com/watch?v=_galFWwSDt0</a></p>
<h4>Prerequisites</h4>
<ol>
<li>The snipMate package requires VIM 7 or higher.</li>
<li>SystemVerilog mode for VIM from <a href="http://www.vim.org/scripts/script.php?script_id=1586">this link</a>.</li>
</ol>
<h4>Download and Install</h4>
<ol>
<li>Download the snippets from <a href="http://coverification.org/download/VIMsnippets.zip">here</a>.</li>
<li>Install the package by unzipping it inside the ~/.vim directory.</li>
</ol>
<p>To test the installation, open a systemverilog file in GVIM and and press the key sequence . This should pop-up a list of available snippets. You can also try ovm snippets by keying in <tt>ovm</tt> and following it with a TAB press. VMM snippets can be accessed similarly by keying in <tt>vmm</tt> followed by a TAB press. Most SystemVerilog constructs like <tt>while, for, if, class</tt> etc too invoke a snippet. Another interesting snippet to try out is <tt>once</tt>. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2010/01/20/systemverilog-snippets-for-vim-users/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>SystemVerilog Snippets for Emacs</title>
		<link>http://coverification.com/2009/12/17/systemverilog-snippets-for-emacs/</link>
		<comments>http://coverification.com/2009/12/17/systemverilog-snippets-for-emacs/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 15:49:18 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[OVM]]></category>
		<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">https://coverification.org/?p=368</guid>
		<description><![CDATA[SystemVerilog is a huge language and is still growing. To boot we have two separate verification methodologies (VMM and OVM). It is heartening to see some unification effort by Accellera. But I believe VMM and OVM will still be around for at least a couple of years. To ease up coding effort, VMM provides vmmgen [...]]]></description>
				<content:encoded><![CDATA[<p>SystemVerilog is a huge language and is still growing. To boot we have two separate verification methodologies (VMM and OVM). It is heartening to see some unification effort by Accellera. But I believe VMM and OVM will still be around for at least a couple of years.</p>
<p>To ease up coding effort, VMM provides <tt>vmmgen</tt> utility (which seems broken in the recently announced 1.2 release). OVM on the other hand has a couple of utilities available in the <a href="http://www.ovmworld.org/contributions.php">contrib area</a> of the OVM World.</p>
<p>Being an Emacs addict, I always craved to have these capabilities as part of Emacs.<span id="more-368"></span> Over the past year I made some effort in this direction and I think at this point the code templates have matured enough for a public release. Additionally my package (which is built over YASnippet package for Emacs) supports common SystemVerilog constructs like <tt>class, case, always</tt> etc.</p>
<h3>Prerequisites</h3>
<p><b><a href="http://emacs.org">GNU Emacs</a> (version 22 or later)</b> -- If you are still using XEmacs, I suggest that you have another look at GNU Emacs. The past decade has seen quite a few new developments with GNU Emacs. And a lot of new elisp packages are now supported only for the GNU flavor.</p>
<p><a href="http://www.veripool.org/wiki/verilog-mode"><b>Verilog Mode</b></a> -- Let me know if there is any other verilog mode for Emacs worth its name, and I will add support for that too.</p>
<h3>Installation</h3>
<p><b>Download</b> the package from the following link <a href="http://coverification.org/download/yasnippet-bundle.el.gz">yasnippet-bundle.el.gz</a></p>
<p><b>Uncompress</b> the downloaded file in a directory where you keep your other emacs packages. Make sure that the directory you kept the uncompressed file in, is in your Emacs load path.</p>
<p><b>Load</b> the downloaded package. You can do this by adding the following lines in your emacs init file.</p>
<pre class="brush: plain; title: ; notranslate">
;; Add the directory to Emacs load path
(setq load-path (cons "/path/to/directory" load-path))

;; Load the package
(require 'yasnippet-bundle)
</pre>
<p>Now when you launch Emacs, you should see a YASnippet menu in the top menu-bar. Navigating to verilog-mode on this menu-bar will make all the verilog templates visible to you. When editing a file in <tt>verilog-mode</tt>, you can also access these templates using keyboard shortcuts shown along with the menu-bar entries. All the VMM specific templates can be accessed by typing <tt>vmm</tt> and following it up with a <tt>TAB</tt>. Similarly OVM templates can be accessed by typing <tt>ovm</tt> and then a <tt>TAB</tt>. SystemVerilog snippets can be invoked by typing the respective keywords followed by a <tt>TAB</tt>. To know all the package capabilities, just watch the following video tutorial.</p>
<p><a href="http://www.youtube.com/watch?v=76Ygeg9miao&#038;fmt=18">http://www.youtube.com/watch?v=76Ygeg9miao</a></p>
<p>If you face any issues with installation, just leave a message. Bug reports and other feedbacks/suggestions are also welcome. I intend to maintain and further develop this package. Ideas and suggestions are most welcome. Future revisions will be announced on <a href="http://twitter.com/coverify">Twitter</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/12/17/systemverilog-snippets-for-emacs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A note on VMM Channel and its Parameterization</title>
		<link>http://coverification.com/2009/11/27/a-note-on-vmm-channel-and-its-parameterization/</link>
		<comments>http://coverification.com/2009/11/27/a-note-on-vmm-channel-and-its-parameterization/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 11:25:46 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">https://blog.coverification.org/?p=361</guid>
		<description><![CDATA[I just wrapped up my third parameterized VIP. This one is a parameterized GPIO VIP, and this is a classic case where using `defines would not have sufficed, since you normally have multiple GPIO interfaces on a chip each requiring different port-width. I had earlier blogged as to why `define will not work in such [...]]]></description>
				<content:encoded><![CDATA[<p>I just wrapped up my third parameterized VIP. This one is a parameterized GPIO VIP, and this is a classic case where using <tt>`define</tt>s would not have sufficed, since you normally have multiple GPIO interfaces on a chip each requiring different port-width. I had earlier <a href="http://blog.coverification.org/2009/09/27/exploring-systemverilog-parameterized-classes/">blogged</a> as to why <tt>`define</tt> will not work in such a scenario.</p>
<p>Continuing with our exposition of the parameterized classes, today we will discuss some details of the <tt>vmm_channel</tt> and how to use these channels for parameterized transactions.</p>
<p>In an earlier <a href="http://blog.coverification.org/2009/11/03/implementing-parameterized-transaction-descriptors/">blog entry</a> I had discussed parameterized transactions. Ever since VMM 1.1 release, <tt>vmm_channel</tt> supports parameterized transactions, though this support is not enabled by default. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/11/27/a-note-on-vmm-channel-and-its-parameterization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SyntaxHighlighter for SystemVerilog</title>
		<link>http://coverification.com/2009/11/24/syntaxhighlighter-for-systemverilog/</link>
		<comments>http://coverification.com/2009/11/24/syntaxhighlighter-for-systemverilog/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 03:42:02 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[Meta]]></category>
		<category><![CDATA[SystemVerilog]]></category>

		<guid isPermaLink="false">https://blog.coverification.org/?p=344</guid>
		<description><![CDATA[There seems to be a good number of people who are blogging on SystemVerilog. And a good percentage of these blogs are powered by wordpress. When I set off blogging, I kind of missed a good syntaxhighlighter for SystemVerilog. Well there are a number of wordpress plugins that do syntax highlighting job for you, but [...]]]></description>
				<content:encoded><![CDATA[<p>There seems to be a good number of people who are blogging on SystemVerilog. And a good percentage of these blogs are powered by wordpress.</p>
<p>When I set off blogging, I kind of missed a good syntaxhighlighter for SystemVerilog. Well there are a number of wordpress plugins that do syntax highlighting job for you, but none supports SystemVerilog. <span id="more-344"></span></p>
<p>Fortunately, I found that <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">SyntaxHighlighter Evolved Plugin</a> supports extensions. So I went ahead and created an extension in form of an add-on plugin.</p>
<p>So, if you are a SystemVerilog geek, and want to share your code snippets with others, go ahead and use this small plugin. Note that this plugin depends on an active installation of <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">SyntaxHighlighter Evolved Plugin</a>.</p>
<h4>Download</h4>
<p><a href="http://blog.coverification.org/download/systemverilog-syntax.zip">SyntaxHighlighter add-on for SystemVerilog</a></p>
<h4>Install</h4>
<p>Install and activate <em>SyntaxHighlighter Evolved</em> first.</p>
<p>Upload the systemverilog-syntax.zip on to the plugin interface of your wordpress installation. Activate the plugin.</p>
<h4>Usage</h4>
<p>When you have a SV code snippet to share, enclose it within
<pre class="brush: plain; light: true; title: ; notranslate">
1</pre>
<p> tags. As an example, if you wanted to share a code that looks like ....</p>
<pre class="brush: plain; light: true; title: ; notranslate">
`ifndef _FOO_SV_
`define _FOO_SV_
class foo extends bar;
   rand int frop;
   
   constraint frop_cst
     {
      // ....
       };

   // More code here
endclass: foo
`endif // _FOO_SV_
</pre>
<p>You need to just enclose it inside <em>sv</em> tags -- just as illustrated below here.</p>
<pre class="brush: plain; light: true; title: ; notranslate">
1
</pre>
<p>This should result in a beutified snippet on your weblog.</p>
<pre class="brush: sv; title: ; notranslate">
`ifndef _FOO_SV_
`define _FOO_SV_
class foo extends bar;
   rand int frop;
   
   constraint frop_cst
     {
      // ....
       };

   // More code here
endclass: foo
`endif // _FOO_SV_
</pre>
<p>Facing issues? Just leave out a comment. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/11/24/syntaxhighlighter-for-systemverilog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing Parameterized Transaction Descriptors</title>
		<link>http://coverification.com/2009/11/04/implementing-parameterized-transaction-descriptors/</link>
		<comments>http://coverification.com/2009/11/04/implementing-parameterized-transaction-descriptors/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 03:30:58 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">https://blog.coverification.com/?p=343</guid>
		<description><![CDATA[Parameters (generics in VHDL) have been popular with RTL designers as an aid to make the designs generic. Fortunately, SystemVerilog supports parameterized classes and interfaces. So how are parameters useful while implementing generic VIPs? Is it not sufficient to pass a configuration object to the VIP and maneuver the VIP configurability with that object? Well, [...]]]></description>
				<content:encoded><![CDATA[<p>Parameters (generics in VHDL) have been popular with RTL designers as an aid to make the designs generic. Fortunately, SystemVerilog supports parameterized classes and interfaces.</p>
<p>So how are parameters useful while implementing generic VIPs? Is it not sufficient to pass a configuration object to the VIP and maneuver the VIP configurability with that object? <span id="more-343"></span></p>
<p>Well, configuration objects are dynamic. While they are very useful for the purpose they serve, they can not be used to configure bus bit-widths. This is because SystemVerilog requires you to provide compile time constants for specifying the bit range of the bus. And there are only two viable methods for achieving that -- parameters and pre-processor tick-defines. While, tick-defines are not elegant, <a href="http://blog.coverification.com/2009/09/27/exploring-systemverilog-parameterized-classes/">earlier</a> we also saw why tick-defines do not provide a viable solution all the times.</p>
<p>Let us look at what it takes to implement a parameterized transaction descriptor class. As an example we take the AMBA AHB master transaction. The specification of the bus protocol says that the data-width may be 8, 16, 32, 64, 128, 256, 512, or 1024. Similarly the address bus too can have any bit-width. The following snippet shows how an AHB Master transaction descriptor class could be coded (in VMM) using parameterized classes.</p>
<pre class="brush: sv; title: ; notranslate">
class ahbm_burst_xactn #(int DW=32, int AW=32) extends ahbm_xactn;

   typedef ahbm_burst_xactn #(DW, AW) transaction_type;
   typedef vmm_channel_typed #(transaction_type) channel_type;

   // Make the parameters available to the xactn object clients
   static const int DATA_WIDTH = DW;
   static const int ADDR_WIDTH = AW;

   // ......
   // ......
endclass: ahbm_burst_xactn

function vmm_data ahbm_burst_xactn::copy(vmm_data to=null);
   transaction_type xactn;
   if (to != null) begin
      if (!$cast(xactn, to)) begin
         `vmm_fatal(log, "Not a ahbm_burst_xactn instance");
         return null;
      end
   end else xactn = new;
   super.copy_data(xactn);

   xactn.kind = this.kind;
   // ......
   // ......
endfunction: copy

</pre>
<p>Here, I am using <tt>ahbm_xactn</tt>, which itself is derived from <tt>vmm_data</tt>, as a base class. On line 3, we have a <tt>typedef</tt> that defines <tt>transaction_type</tt>. You will notice that this is nothing but a concrete instance of the parameterized class that we are defining. The idea is to provide an abstraction for use within the transaction descriptor class itself. It makes the code more readable. For example, as you can see on line 15, nested type <tt>transaction_type</tt> provides a convenient way to declare the type of the transaction while defining the descriptor class methods. And it is a good abstraction, since if you add or remove a parameter to the parameterized class, you will not have to do that at many places. Just modify the <tt>typedef</tt> definitions, and you are done.</p>
<p>Similarly, on line 4, you see a similar <tt>typedef</tt> definition for a channel. With non-parameterized transactions, we would have declared the channel type outside the descriptor class definition. And we would have perhaps used the VMM macro <tt>`vmm_channel </tt> for doing that. That does not work for parameterized transaction types. Again <tt>typedef</tt> comes to our rescue. The following snippet illustrates how to use this abstraction while coding a transactor. Those with C++ background will notice that STL provides iterator types to the user in a similar fashion.</p>
<pre class="brush: sv; title: ; notranslate">
class ahbm_burst_gen #(int DW=32, int AW=32) extends vmm_xactor;

   typedef ahbm_burst_xactn #(DW, AW) transaction_type;

   // More typedefs -- snipped

   // transaction objects and channel declarations
   transaction_type randomized_obj;
   transaction_type::channel_type exec_chan;
   transaction_type::channel_type obs_chan;

   // snipped
endclass: ahbm_burst_gen
</pre>
<p>Coming back to the descriptor claas, on line 7 and 8, you would notice definitions of <tt>static const</tt>ants <tt>DATA_WIDTH</tt> and <tt>ADDR_WIDTH</tt>. This is a convenient way to make data and address widths available to any code that uses a transaction object but is not aware of the <tt>DW</tt> and <tt>AW</tt> parameters. And since these constants are declared static, they do not consume much memory when the simulation runs.</p>
<p>In my next post, I will discuss the intricacies of writing a parameterized transactors. When we do that, we will also see Emacs and ViM snippets coming to our rescue. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/11/04/implementing-parameterized-transaction-descriptors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exploring SystemVerilog Parameterized Classes</title>
		<link>http://coverification.com/2009/09/27/exploring-systemverilog-parameterized-classes/</link>
		<comments>http://coverification.com/2009/09/27/exploring-systemverilog-parameterized-classes/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 22:48:20 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">http://blog.coverification.com/?p=290</guid>
		<description><![CDATA[Recently Adiel Khan of Synopsys wrote a weblog on the virtues of using parameterized classes for implementing reusable VMM VIP's. It seems support for parameterized classes has matured up quite a bit in the latest release of SV compilers. In his blog, Adiel concludes that `define macros should be preferred over using parameterized classes. In [...]]]></description>
				<content:encoded><![CDATA[<p>Recently Adiel Khan of Synopsys wrote a <a href="http://www.vmmcentral.org/vmartialarts/?p=119">weblog</a> on the virtues of using parameterized classes for implementing reusable VMM VIP's. It seems support for parameterized classes has matured up quite a bit in the latest release of SV compilers.</p>
<p>In his blog, Adiel concludes that <tt>`define</tt> macros should be preferred over using parameterized classes. In this blog entry, I will try to focus on some of the virtues of parameterized classes. <span id="more-290"></span></p>
<p>Take for example an AMBA AHB Master VIP, that I recently had an opportunity to work on. To make the VIP reusable, the data bus-width and the address bus-width need to be made configurable. There are two approaches ....</p>
<h4>The `define method</h4>
<p>When you code using <tt>`define</tt>, you don't hardcode the configurable parameters (eg DATAWIDTH and ADDRWIDTH). Instead you use <tt>`define</tt> constants. The following SV code snippet shows an attempt to code an AHB master transaction this way.</p>
<pre class="brush: sv; title: ; notranslate">
`define AHB_ADDRWIDTH 32
`define AHB_DATAWIDTH 32

class ahbm_xactn extends vmm_data;

   static vmm_log log = new("ahbm_xactn", "class");

   rand ahb::trans_kind_e kind;

   rand bit [`AHB_ADDRWIDTH-1:0] haddr;
   rand bit [`AHB_DATAWIDTH-1:0] hwdata;
   rand bit [`AHB_DATAWIDTH-1:0] hrdata;

   ....

endclass: ahbm_xactn
</pre>
<p>Note that the <tt>`define</tt> macro constants are scoped globally - and that is primarily the reason I have given them a longish name (in an attempt to make them really unique).</p>
<p>Also note that we are really defining a single transaction descriptor class, just that it happens to be configurable.</p>
<h4>Using parameterized classes</h4>
<p>The following SV code snippet illustrates another attempt to implement the AHB transaction descriptor class — this time using parameterized classes.</p>
<pre class="brush: sv; title: ; notranslate">
class ahbm_xactn #(int DW=32, int AW=32) extends vmm_data;

   static vmm_log log = new("ahbm_xactn", "class");

   rand ahb::trans_kind_e kind;

   rand bit [AW-1:0] haddr;
   rand bit [DW-1:0] hwdata;
   rand bit [DW-1:0] hrdata;

   ....

endclass: ahbm_xactn
</pre>
<p>Note that the parameters DW and AW are scoped locally — and therefor it is perfectly fine to give them smaller names. When using C++ templates too, it is a standard practice to use small — often single character — names to represent classes and parameterized constants.</p>
<p>Now something that really makes parameterized classes more powerful. When you code a parameterized class, you are really coding a set of classes. A class is in fact an instance of a parameterized class and you could create a multitude of such classes.</p>
<p>Why is that important? When modeling complex systems, there are places where you have multiple subsystems, each having its own AHB bus. And you need to have independent parameters for the address and data widths of these subsystems. If you used <tt>`define</tt> to implement an AHB bus transaction, you will find yourself in a fix.</p>
<p>In fact there are multiple dimensions to reusability. When you code a reusable VIP, it should be reusable across multiple projects. It is equally important to make it reusable within the same system — meaning thereby, it should be possible to instantiate the same VIP multiple times within the same system. And it should be simultaneously possible to configure each VIP instance in a different way. When you use the <tt>`define</tt> method, you can still have multiple instances of the VIP, but the <tt>`define</tt> parameters (being globally scoped) are common for all the VIP instances, and hence not independently configurable.</p>
<p>Support for parameterized classes does open up a lot of coding options. And I will try to explore some of these in my upcoming blog entries. My focus is going to be on how to code efficient VIPs that are really <em>reusable</em>. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/09/27/exploring-systemverilog-parameterized-classes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Packing and Unpacking VMM Transactions</title>
		<link>http://coverification.com/2009/07/29/packing-and-unpacking-vmm-transactions/</link>
		<comments>http://coverification.com/2009/07/29/packing-and-unpacking-vmm-transactions/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 02:43:48 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">http://blog.coverification.com/?p=228</guid>
		<description><![CDATA[VMM recommends defining byte_pack and byte_unpack methods for each transaction descriptor class. Let us first understand exactly how and why these methods are useful. The figure below depicts the various abstraction layers in a typical VMM-based verification platform. The concept of a transaction is central to VMM and a transaction transcends through all the different [...]]]></description>
				<content:encoded><![CDATA[<p>VMM recommends defining <tt>byte_pack</tt> and <tt>byte_unpack</tt> methods for each transaction descriptor class. Let us first understand exactly how and why these methods are useful.</p>
<p>The figure below depicts the various abstraction layers in a typical VMM-based verification platform. The concept of a <em>transaction</em> is central to VMM and a transaction transcends through all the different layers. <span id="more-228"></span>At the top is <em>Test Layer</em>, which abstract the control mechanism of the verification. This is the highest level of abstraction and at this level none of the transaction details are important — often only the count of transactions is important in this layer. Just below are the <em>Scenario</em> and <em>Functional Layers </em> — which present the behavioral abstraction. Since these are the layers responsible for generation of transactions, the functional fields of each transaction object are important at these levels. What is not important is the bit-level timing as well as bit-level sequencing of the fields within the transactions. Finally the <em>Command Layer</em> helps drive the transactions to the bit-level interface of the <em>design-under-test</em>. Since this is also the physical interface of the module/chip, it is often a very different abstraction than what is presented by the <em>Functional Layer</em>. At this level we are more interesting in sequencing and timing of the various transaction bits.</p>
<p>The methods byte_pack and byte_unpack help us achieve these different abstractions of a transaction. Packed transactions offer the right abstraction within the command layer and often at the input of the functional layer. On the other hand unpacked transactions are required within the scenario layer.</p>
<p><img src="http://coverification.com/wp-content/uploads/2009/07/vmm.png" alt="vmm -- the layered platform" width="620" height="350" class="alignnone size-full wp-image-229" /></p>
<p>For an ATM Cell transaction that we discussed <a href="http://blog.coverification.com/2009/07/21/the-vmm-way-of-describing-transactions/">here</a> we can write the byte_pack method as ....</p>
<pre class="brush: sv; title: ; notranslate">
// Byte Pack
function int unsigned atm_cell::byte_pack(ref logic [7:0] bytes[],
                                          input int unsigned offset,
                                          input int kind);
   // Make sure there is enough room in the array
   if(bytes.size() &lt; this.byte_size())
        bytes = new [this.byte_size()] (bytes);
   // Pack the bytes
   bytes[0] = {gfc, vpi[7:4]};
   bytes[1] = {vpi[3:0], vci[15:12]};
   bytes[2] = {vci[11:4]};
   bytes[3] = {vci[3:0], pt, clp};
   bytes[4] = {hec};
   for (int i=0; i &lt; 48; i++)
     bytes[i+5]=payload[i];
   byte_pack = 53;
endfunction

// Byte Unpack
function int unsigned atm_cell::byte_unpack(const ref logic[7:0] bytes[],
                                            input int unsigned offset,
                                            input int len,
                                            input int kind);
   {gfc, vpi, vci, pt, clp, hec} = {bytes[0], bytes[1], bytes[2],
                                     bytes[3], bytes[4]};
   for (int i = 0; i != 48; ++i)
     payload[i] = bytes[i+5];

   return 53;
endfunction

</pre>
<p>A few points are in order ....</p>
<ol>
<li> The byte_pack (and byte_unpack) function(s) are virtual functions. And therefor the function signatures need to match exactly the signatures of the base function defined in the vmm_data class in the VMM library. </li>
<li> It is useful to add some default values to the input arguments of the function, so that it becomes easier to call the function. These default values are often added in function declaration inside the descriptor class. </li>
<pre class="brush: sv; title: ; notranslate">
// method declaration, within the descriptor class definition
extern virtual function int unsigned
               atm_cell::byte_pack(ref logic[7:0] bytes[],
                                   input int unsigned offset = 0,
                                   input int kind = -1);
</pre>
<li> Input parameters <em>offset</em> and <em>kind</em> are usually ignored in the function implementation. While the usage of parameter <em>kind</em> can be user specific, the parameter <em>offset</em> can be used to make the function more generic — so that the byte packing can be done at an offset provided by the user.</li>
<pre class="brush: sv; title: ; notranslate">
function int unsigned atm_cell::byte_pack(ref logic [7:0] bytes[],
                                          input int unsigned offset,
                                          input int kind);
   // Make sure there is enough room in the array
   if(bytes.size() &lt; this.byte_size() + offset)
        bytes = new [this.byte_size() + offset] (bytes);
   // Pack the bytes
   bytes[offset+0] = {gfc, vpi[7:4]};
   bytes[offset+1] = {vpi[3:0], vci[15:12]};
   bytes[offset+2] = {vci[11:4]};
   bytes[offset+3] = {vci[3:0], pt, clp};
   bytes[offset+4] = {hec};
   for (int i=0; i &lt; 48; i++)
     bytes[offset+i+5]=payload[i];
   byte_pack = offset+53;
endfunction
</pre>
<li> Often it is useful to use byte_pack function while sending a transaction to a DPI function. Similarly byte_unpack can be used after receiving a transaction from a DPI function. It is easier to pass dynamic arrays to and from a DPI function. </li>
<li> Janick <a href="http://verificationguild.com/modules.php?name=Forums&#038;file=viewtopic&#038;t=2752">suggests</a> on-the-fly calculation of CRC and other transaction processing be done in the byte_path method.
<li> Chris Spears <a href="http://verificationguild.com/modules.php?name=Forums&#038;file=viewtopic&#038;t=2629">suggests</a> using array slices as a short-hand notation for assigning various fields to the reference variable <em>bytes</em> and vice-versa. Given the <a href="http://blog.coverification.com/?p=206#comments">fluidity</a> in the SystemVerilog LRM regarding array assignments and the fact that the transaction fields may not be byte aligned, it is much better to use the old verilog trick as shown above, on the lines 24-25 of <em>byte_unpack</em> example for atm_cell.
</ol>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/07/29/packing-and-unpacking-vmm-transactions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copying Arrays and Queues in SystemVerilog</title>
		<link>http://coverification.com/2009/07/25/copying-arrays-and-queues-in-systemverilog/</link>
		<comments>http://coverification.com/2009/07/25/copying-arrays-and-queues-in-systemverilog/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 03:33:58 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">http://blog.coverification.com/?p=206</guid>
		<description><![CDATA[Since the payload in many transactions constitutes of multiple data bytes, it is usually represented by a fixed-size or dynamic array. Often there is a requirement to replicate the array (for example in the VMM mandated copy function). SystemVerilog provides various ways of achieving this end. Often it is done by copying all the elements [...]]]></description>
				<content:encoded><![CDATA[<p>Since the payload in many transactions constitutes of multiple data bytes, it is usually represented by a fixed-size or dynamic array. Often there is a requirement to replicate the array (for example in the VMM mandated <em>copy</em> function).</p>
<p>SystemVerilog provides various ways of achieving this end. Often it is done by copying all the elements ....<span id="more-206"></span></p>
<pre class="brush: sv; title: ; notranslate">
foreach( payload[i] )
  cpy.payload[i] = this.payload[i];
</pre>
<p>Another possibility is to use the <em>for</em> block …</p>
<pre class="brush: sv; title: ; notranslate">
for( i=0; i &lt; $size( this.payload ); i++ )
  cpy.payload[i] = this.payload[i];
</pre>
<p>But the best way is to just use the array assignment. Works for both fixed-size and dynamic arrays.</p>
<pre class="brush: sv; title: ; notranslate">
cpy.payload = this.payload;
</pre>
<p>Since in C/C++, assigning an array to another variable would only make a copy of the pointer corresponding to the array, use of assignment operator for copying arrays or queues is not intuitive enough, even when we code in SystemVerilog. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/07/25/copying-arrays-and-queues-in-systemverilog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use visual-line-mode instead of longlines-mode</title>
		<link>http://coverification.com/2009/07/23/use-visual-line-mode-instead-of-longlines-mode/</link>
		<comments>http://coverification.com/2009/07/23/use-visual-line-mode-instead-of-longlines-mode/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 15:48:20 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Meta]]></category>

		<guid isPermaLink="false">http://blog.coverification.com/?p=194</guid>
		<description><![CDATA[longlines-mode has a lot of issues with weblogger. It seems that visual-line-mode is much better. I have been using it for some time now, without any issue. Here is my new weblogger setup … Also note that I am now using RSD to enable SSL connection with the server.]]></description>
				<content:encoded><![CDATA[<p><tt>longlines-mode</tt> has a lot of issues with weblogger. It seems that <tt>visual-line-mode</tt> is much better. I have been using it for some time now, without any issue.</p>
<p>Here is my new weblogger setup … <span id="more-194"></span></p>
<pre class="brush: plain; title: ; notranslate">
(require 'weblogger)

(add-hook 'weblogger-start-edit-entry-hook
          (lambda()
            (flyspell-mode 1)
            (flyspell-buffer)   ; spell check the fetched post
            (auto-fill-mode -1)
            (visual-line-mode 1)))
(add-hook 'weblogger-publish-entry-hook
          (lambda()
            (when visual-line-mode
              (visual-line-mode -1))
            ;; tabs might spoil code indentation
            (untabify (point-min) (point-max))))
(add-hook 'weblogger-publish-entry-end-hook
          (lambda()
            (visual-line-mode 1)))

(setq weblogger-config-alist
      '(("PRIVATE"
         ("user" . "puneet")
         ("pass" . "TOPSECRET")
         ("server-url" . "https://systemc.in/wordpress/xmlrpc.php?RSD")
         ("weblog" . "1"))
        ("CoVerification"
         ("user" . "puneet")
         ("pass" . "ANOTHERTOPSECRET")
         ("server-url" . "https://blog.coverification.com/xmlrpc.php?RSD")
         ("weblog" . "1"))))

(require 'tls)
;; since I am now using rsd/ssl for wordpress, I need to make sure
;; that I do not get these redundant hostmismatch errors.
(setq tls-hostmismatch nil)

</pre>
<p>Also note that I am now using RSD to enable SSL connection with the server. </p>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/07/23/use-visual-line-mode-instead-of-longlines-mode/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>The VMM way of describing transactions</title>
		<link>http://coverification.com/2009/07/22/the-vmm-way-of-describing-transactions/</link>
		<comments>http://coverification.com/2009/07/22/the-vmm-way-of-describing-transactions/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 03:43:29 +0000</pubDate>
		<dc:creator>puneet</dc:creator>
				<category><![CDATA[SystemVerilog]]></category>
		<category><![CDATA[VMM]]></category>

		<guid isPermaLink="false">http://blog.coverification.com/?p=191</guid>
		<description><![CDATA[As one starts building a Verification IP, the first task is to identify the various data transactions that the Design Under Test supports. Some of these transactions would be low-level — quite specific to the pin interfaces of the module. For example if the DUT supports I2C interface, it is imperative for the verification IP [...]]]></description>
				<content:encoded><![CDATA[<p>As one starts building a Verification IP, the first task is to identify the various data transactions that the <em>Design Under Test</em> supports. Some of these transactions would be low-level — quite specific to the pin interfaces of the module. For example if the DUT supports I2C interface, it is imperative for the verification IP to have an I2C transaction descriptor class. In addition, on top of the low-level interfaces, higher abstraction level data transactions would often ride. <span id="more-191"></span>Before starting on the task of building the verification infrastructure, a verification engineer should identify all these layers of abstraction and all the data transactions at the various levels of abstraction. After this, as he starts implementing the verification IP, his first task would be to code the transaction description classes. The nature of the SystemVerilog based verification is such that the focus of the verification would remain on these transactions.</p>
<p>The <em>Verification Methodology Manual</em> provides several rules and guidelines specific to description of transactions. To understand how these rules apply in practice, we will look at an example — which happens to be the <em>atm_cell</em> descriptor class.</p>
<pre class="brush: sv; title: ; notranslate">
class atm_xactn extends vmm_data ;
   static  vmm_log log = new("atm_xactn", "class");
   rand bit [ 3:0] gfc;
   rand bit [ 7:0] vpi;
   rand bit [15:0] vci;
   rand bit [ 2:0] pt;
   rand bit        clp;
   bit      [ 7:0] hec;
   rand bit [ 7:0] payload[48];

   extern function new();
   // Mandated VMM functions
   extern virtual function string psdisplay(string prefix );
   extern virtual function bit is_valid(bit silent, int kind);
   extern virtual function vmm_data copy(vmm_data to);
   extern virtual function vmm_data allocate();
   extern virtual function bit compare(vmm_data to,
                                       output string diff,
                                       input int kind =-1);
   // Recommended VMM functions
   extern virtual function int unsigned byte_size(int kind=-1 );
   extern virtual function int unsigned
       byte_pack(ref logic [7:0] bytes[],
                 input int unsigned offset=0, input int kind=-1);
   extern virtual function int unsigned
       byte_unpack(ref logic [7:0] bytes[],
                   input int unsigned offset=0,
                   input int len=-1, input int kind=-1);
   // Additonal Methods
   extern  virtual function bit[7:0] atm_hec();
endclass

`vmm_channel(atm_xactn)
`vmm_scenario_gen(atm_xactn, "ATM Cell")

</pre>
<p>A few things need special mention …</p>
<ol>
<li>On line number two, the <tt>vmm_log</tt> instance has been declared <em>static</em>. Since static data members are shared by all the instance objects of a class, it avoids unnecessary duplicate instantiations of vmm_log.</li>
<li>From line 3 to line 8, various fields of the 5 byte ATM Cell header are declared. While all other header fields have been declared random, the byte corresponding to the <em>hec</em> field has not been. This is because the hec byte depends on the value of the other bytes in the header — it is really not random.</li>
<li>From line 13 to line 28, there are various function declarations. Please refer to the VMM Book for a detailed description of these functions.</li>
<li>On line 30, function <tt>atm_hec</tt> has been declared. In the next blog entry, we will see how to implement this function using a C++ library.</li>
<li>Another pair of functions <tt>pre_randomize</tt> and <tt>post_randomize</tt> are available. These methods can be used as hooks that get called, before and after a transaction gets randomized. For example <tt>post_randomize</tt> function could be used to fill the hec field, calculated by the <tt>atm_hec</tt> function.
</ol>
]]></content:encoded>
			<wfw:commentRss>http://coverification.com/2009/07/22/the-vmm-way-of-describing-transactions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
