<?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>Functional Verification Blog &#187; Verilog</title>
	<atom:link href="http://blog.asicguru.com/category/verilog/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.asicguru.com</link>
	<description>A Functional Verification Blog</description>
	<lastBuildDate>Tue, 18 May 2010 16:19:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mixed verilog and vhdl compilation with VCS</title>
		<link>http://blog.asicguru.com/2009/03/mixed-verilog-and-vhdl-compilation-with-vcs/</link>
		<comments>http://blog.asicguru.com/2009/03/mixed-verilog-and-vhdl-compilation-with-vcs/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 11:40:07 +0000</pubDate>
		<dc:creator>Puneet</dc:creator>
				<category><![CDATA[Verilog]]></category>
		<category><![CDATA[Vhdl]]></category>
		<category><![CDATA[mixed compilation]]></category>
		<category><![CDATA[vcs]]></category>

		<guid isPermaLink="false">http://asicguru.com/blog/?p=5</guid>
		<description><![CDATA[Here I will explain how you can compile and simulate vhdl and verlog based design using the VCS. lets take a small example of counter. The dut will be written in vhdl and the testbench we will write in verilog. Then we will instantiate vhdl counter into our verilog testbench and then compile and simulate [...]]]></description>
			<content:encoded><![CDATA[<p>Here I will explain how you can compile and simulate vhdl and verlog based design using the VCS. lets take a small example of counter. The dut will be written in vhdl and the testbench we will write in verilog. Then we will instantiate vhdl counter into our verilog testbench and then compile and simulate it.</p>
<p>Here is the code for dut and testbench.</p>
<p>VHDL DUT :<br />
==========</p>
<pre class="wiki">library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity counter is
port(  clk:  in std_logic;
  reset:  in std_logic;
  enable:  in std_logic;
  count:  out std_logic_vector(3 downto 0)
);
end counter;

architecture behav of counter is
  signal pre_count: std_logic_vector(3 downto 0);
  begin
    process(clk, enable, reset)
    begin
      if reset = '1' then
        pre_count &lt;= "0000";
      elsif (clk='1' and clk'event) then
        if enable = '1' then
          pre_count &lt;= pre_count + "1";
        end if;
      end if;
    end process;
    count &lt;= pre_count;
end behav;</pre>
<p>Verilog Testbench<br />
=================</p>
<div class="code">
<pre>module counterTb;
    reg clk;
    reg reset;
    reg enable;
    wire [3:0] count;

    initial
    begin
        $monitor ($time, " Count = %d", count);
        clk=0;
        reset = 1;
        enable = 0;
        #5
        reset = 0;
        enable = 1;
    end

    initial
        forever
            #5 clk = ~clk;

    initial
        #1000 $finish;

   // initialize vhdl counter module
   counter (.clk(clk),.reset(reset),.enable(enable), .count(count));

endmodule</pre>
</div>
<p>Steps to compile :<br />
* Create directory for the compiled libraries (mkdir compile)</p>
<p>* Setup &#8220;synopsys_sim.setup&#8221; file and map libraries in it</p>
<ul>
<li>Create file synoosys_sim.setup</li>
<li>Add line : counter_lib : ./compile/</li>
</ul>
<p>* Compile the libraries</p>
<ul>
<li>vhdlan -work counter_lib counter.vhdl</li>
<li>vlogan +v2k +incdir+./  -work counter_lib countertb.v</li>
</ul>
<p>* Elobrate the design and generate executable</p>
<ul>
<li>vcs counter_lib.counterTb</li>
</ul>
<p>* Simulate it.</p>
<ul>
<li>./simv</li>
</ul>
<p>You can create a makefile also to design and elobrate the design. Something like</p>
<pre class="wiki">all : compile sim

counter_lib : counter.vhdl
    vhdlan -work counter_lib counter.vhdl

countertb_lib : countertb.v
    vlogan +v2k +incdir+./  -work counter_lib countertb.v

compile : countertb_lib counter_lib

sim :
    vcs counter_lib.counterTb</pre>
<p>Now you just need to say &#8220;make&#8221;. It will compile and elobrate the design.</p>
<p>synopsys_sim.setup file content<br />
===============================</p>
<pre class="wiki">counter_lib : ./compile/
WORK&gt;DEFAULT
DEFAULT: ./compile/
ASSERT_IGNORE_WARNING=TRUE
ASSERT_IGNORE_FAILURE=TRUE
ASSERT_IGNORE_ERROR=TRUE</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.asicguru.com/2009/03/mixed-verilog-and-vhdl-compilation-with-vcs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
