Abstract
本文介紹如何使用Debussy與ModelSim做Co-Simulation,並使用Verilog、VHDL以及Verilog搭配VHDL交叉一起simulation。

Introduction
使用環境:Debussy 5.4 v9 + ModelSim SE 6.3e

我之前一直使用Debussy + NC-Verilog做simulation,Debussy (Verdi)可以說是HDL的Source Insight,是trace與debug的神兵利器,NC-Verilog也是Verilog simulator中速度最快的,可是最近因工作需要,拿到的一包code卻是用Verilog寫RTL,用VHDL寫testbench,所以必須2種語言一起做simulation,我在NC-Verilog一直無法成功讓兩種語言一起simulation。ModelSim雖然支援Verilog + VHDL co-simulation,但用慣Debussy的我還是無法忘懷其方便的trace code方式,所以若能讓ModelSim也能dump出Debussy所需要的fsdb檔案,這樣就太完美了。

接下來會分4個方式討論

1.RTL與testbench皆使用Verilog

2.RTL與testbench皆使用VHDL

3.RTL使用VHDL,testbench使用Verilog

4.RTL使用Verilog,testbench使用VHDL

1.RTL與testbench皆使用Verilog

Step 1:

設定ModeSim使用Verilog PLI (因為testbench使用Verilog)

將C:\Novas\Debussy\share\PLI\modelsim_pli\WINNT\novas.dll複製到C:\Modeltech_6.3e\win32\下
修改C:\Modeltech_6.3e\modelsim.ini,將Veriuser部分修改成如下所示:

; List of dynamically loaded objects for Verilog PLI applications
; Veriuser = veriuser.sl
; use by verilog
Veriuser = novas.dll
; use by vhdl
; Veriuser = novas_fli.dll

modelsim.ini是個read only檔,要修改前記得修改其屬性才能存檔。

Step 2:

RTL部分 (以4 bit counter為例)

counter.v / Verilog

1 /*
2 (C) OOMusou 2011 http://oomusou.cnblogs.com
3
4 Filename : counter.v
5 Simulator : ModelSim 6.3e, Debussy 5.4 v9
6 Description : ModelSim with debussy
7 Release : 01/31/2010 1.0
8   */
9
10   module counter (
11 clk,
12 rst_n,
13 cnt
14 );
15
16   input clk;
17   input rst_n;
18   output [ 3 : 0 ] cnt;
19
20   reg [ 3 : 0 ] cnt;
21
22   always @( posedge clk, negedge rst_n) begin
23 if ( ~ rst_n)
24 cnt <= 4 ' h0;
25   else
26 cnt <= cnt + 1 ' b1;
27   end
28
29   endmodule

Step 3:

Testbench部分

counter_tb.v / Verilog

1 /*
2 (C) OOMusou 2011 http://oomusou.cnblogs.com
3
4 Filename : counter_tb.v
5 Compiler : ModelSim 6.3e, Debussy 5.4 v9
6 Description : ModelSim with debussy
7 Release : 01/31/2010 1.0
8   */
9
10   module counter_tb;
11
12   reg clk;
13   reg rst_n;
14   wire [ 3 : 0 ] cnt;
15
16   // 50MHz
17   always #( 10 ) clk = ~ clk;
18
19   initial begin
20 # 0 ;
21 clk = 1 ' b0;
22   rst_n = 1 ' b0;
23  
24 # 5 ;
25 rst_n = 1 ' b1;
26   # 195 ;
27 $finish;
28   end
29
30   initial begin
31 $fsdbDumpfile( " counter.fsdb " );
32 $fsdbDumpvars( 0 , counter_tb);
33   end
34
35 counter u_counter (
36 .clk(clk),
37 .rst_n(rst_n),
38 .cnt(cnt)
39 );
40
41   endmodule

19行

initial begin
# 0 ;
clk = 1 ' b0;
rst_n = 1 ' b0;

# 5 ;
rst_n = 1 ' b1;

# 195 ;
$finish;
end

一搬來說,若在NC-Verilog做simulation,我們會在testbench內指定結束simulation的時間,不過在ModelSim裡,simulation時間是由ModelSim script控制,在testbench內寫$finish並沒有用,所以會省略$finish時間入下。

initial begin
# 0 ;
clk = 1 ' b0;
rst_n = 1 ' b0;

# 5 ;
rst_n = 1 ' b1;
end

Step 4:

ModelSim script部分

vsim.do

vlib work
vlog counter . v
vlog counter_tb . v
vsim counter_tb
run 200ns
q

其中

vlib work

建立work library。

vlog counter . v
vlog counter_tb . v

編譯RTL:counter.v 與 testbench:counter_tb.v,vlog為modelsim的Verilog compiler。

vsim counter_tb

以counter_tb為top module進行simulation。

run 200ns

命令ModelSim執行200 ns的simulation。

q

離開ModelSim

Step 5:

執行ModelSim的批次檔

mod.bat

vsim -c - do sim . do

-c 表示ModelSim將以console mode執行,因為在Debussy + ModelSim時,只把ModelSim當成NC-Verilog使用,並沒有用到ModelSim的GUI模式。

-do 表示執行ModelSim script。

執行結果


D: \ 0Clare \ VerilogLab \ ModelSim \ counter_verilog > vsim -c - do sim . do
Reading C: / Modeltech_6 . 3e / tcl / vsim / pref . tcl

# 6 . 3e

# do sim . do
# ** Warning: ( vlib- 34 ) Library already exists at " work " .
# Model Technology ModelSim SE vlog 6 . 3e Compiler 2008.02 Feb 2 2008
# -- Compiling module counter
#
# Top level modules:
# counter
# Model Technology ModelSim SE vlog 6 . 3e Compiler 2008.02 Feb 2 2008
# -- Compiling module counter_tb
#
# Top level modules:
# counter_tb
# vsim counter_tb
# ** Note: ( vsim- 3813 ) Design is being optimized due to module recompilation ...
# ** Note: ( vsim- 3865 ) Due to PLI being present , full design access is being specified .
# Loading C: \ Modeltech_6 . 3e \ win32 / novas . dll
# // ModelSim SE 6 . 3e Feb 2 2008
# //
# // Copyright 1991 - 2008 Mentor Graphics Corporation
# // All Rights Reserved .
# //
# // THIS WORK CONTAINS TRADE SECRET AND
# // PROPRIETARY INFORMATION WHICH IS THE PROPERTY
# // OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS
# // AND IS SUBJECT TO LICENSE TERMS .
# //
# Loading work . counter_tb ( fast )
# Loading work . counter ( fast )
# Novas FSDB Dumper for ModelSim , Release 5 . 4v9 ( Win95 / NT ) 05 / 04 / 2005
# Copyright ( C ) 1996 - 2004 by Novas Software , Inc .
# *Novas* Create FSDB file 'counter . fsdb'
# *Novas* Start dumping the scope ( counter_tb ), layer ( 0 ).
# *Novas* End of dumping .
# ** Note: $ finish : counter_tb . v ( 27 )
# Time : 200 ns Iteration: 0 Instance: / counter_tb

Step 6:

執行Debussy批次檔部份

deb.bat

debussy - 2001 counter_tb . v counter.v -ssf counter . fsdb -sswr counter . rc

-2001表示支援Verilog 2001語法

-ssf 載入Debussy dump file

-sswr 載入Debussy signal file

執行結果

2.RTL與testbench皆使用VHDL

Step 1:

設定ModelSim使用VHDL FLI (因為testbench使用VHDL)

將C:\Novas\Debussy\share\PLI\modelsim_fli54\WINNT\novas_fli.dll複製到C:\Modeltech_6.3e\win32\下
修改C:\Modeltech_6.3e\modelsim.ini,將Veriuser部分修改成如下所示:

; List of dynamically loaded objects for Verilog PLI applications
; Veriuser = veriuser.sl
; use by verilog
; Veriuser = novas.dll
; use by vhdl
Veriuser = novas_fli.dll

modelsim.ini是個read only檔,要修改前記得修改其屬性才能存檔。

複製C:\Novas\Debussy\share\PLI\modelsim_fli54\WINNT\novas.vhd到自己的project底下

(為什麼Verilog不需要這個檔,而VHDL需要這個檔,稍後會解釋)

Step 2:

RTL部分 (以4 bit counter為例)

counter.vhd / VHDL

1 -- (C) OOMusou 2011 http: // oomusou.cnblogs.com
2  
3   -- Filename : counter.vhd
4   -- Simulator : ModelSim 6 .3e, Debussy 5.4 v9
5   -- Description : ModelSim with debussy
6   -- Release : 02 / 05 / 2011 1.0
7
8   library IEEE;
9   use IEEE.std_logic_1164. all ;
10   use IEEE.std_logic_unsigned. all ;
11
12   entity counter is
13 port ( clk : in std_logic ;
14 rst_n : in std_logic ;
15 cnt : out std_logic_vector ( 3 downto 0 ));
16   end entity counter;
17
18   architecture arc of counter is
19 signal cnt_r : std_logic_vector ( 3 downto 0 );
20   begin
21 process (clk, rst_n)
22 begin
23 if (rst_n = ' 0 ' ) then
24 cnt_r <= " 0000 " ;
25 elsif rising_edge (clk) then
26 cnt_r <= cnt_r + 1 ;
27 end if ;
28 end process ;
29
30 cnt <= cnt_r;
31   end arc;

Step 3:

Testbench部分

counter.vhd / VHDL

1 -- (C) OOMusou 2011 http: // oomusou.cnblogs.com
2  
3   -- Filename : counter_tb.vhd
4   -- Simulator : ModelSim 6 .3e, Debussy 5.4 v9
5   -- Description : ModelSim with debussy
6   -- Release : 01 / 31 / 2010 1.0
7
8   library IEEE;
9   use IEEE.std_logic_1164. all ;
10   use IEEE.std_logic_unsigned. all ;
11   use work.pkg. all ;
12
13 entity counter_tb is
14 end entity counter_tb;
15
16 architecture arc of counter_tb is
17 component counter
18 port (
19 clk : in std_logic ;
20 rst_n : in std_logic ;
21 cnt : out std_logic_vector ( 3 downto 0 )
22 );
23 end component ;
24
25 signal clk : std_logic : = ' 0 ' ;
26 signal rst_n : std_logic : = ' 0 ' ;
27 signal cnt : std_logic_vector ( 3 downto 0 );
28
29 begin
30 process
31 begin -- 50MHz
32 clk_loop : loop
33 clk <= ' 0 ' ;
34 wait for 10 ns;
35 clk <= ' 1 ' ;
36 wait for 10 ns;
37 end loop clk_loop;
38 end process ;
39
40 process
41 begin
42 wait for 5 ns;
43 rst_n <= ' 1 ' ;
44 end process ;
45
46 process
47 begin
48 fsdbDumpfile( " counter.fsdb " );
49 fsdbDumpvars( 0 , " counter_tb " );
50 wait ;
51 end process ;
52
53 u_counter : counter
54 port map (
55 clk => clk,
56 rst_n => rst_n,
57 cnt => cnt
58 );
59 end arc; 

11行

use work.pkg. all ;

這是因為novas.vhd與VHDL FLI的原因,稍後會解釋。

47行

process
begin
fsdbDumpfile( " counter.fsdb " );
fsdbDumpvars( 0 , " counter_tb " );
wait ;
end process ;

一樣使用fsdbDumpfile()與fsdbDumpvars()兩個Debussy所提供的函數,不過在VHDL FLI並不需要如Verilog PLI一樣加上$。

wait也一定要加上,否則在ModelSim做simulation時會造成無窮回圈無法停止。

Step 4:

ModelSim script部分

vsim.do

vlib work
vcom novas . vhd
vcom counter . vhd
vcom counter_tb . vhd
vsim counter_tb
run 200ns
q

因為是VHDL,所以全部改用vcom編譯。

其中novas.vhd是從Debussy目錄複製過來的,為什麼需要編譯這個檔案呢?

VHDL FLI (Foreign Language Interface)與Verilog PLI (Programming Language Interface)不同的地方在於,當你自己提供由C寫的function給simulator使用時,Verilog PLI會自己到所提供的dll去找是否有此function,但VHDL FLI需要自己去提供mapping的動作,告訴simulator哪一個function對應dll內那ㄧ個function,novas.vhd就是提供這個mapping的腳色。

若直接使用Debussy所提供的novas.vhd,在執行ModelSim會有以下錯誤訊息。

# ** Warning: (vsim-FLI- 3159 ) Failed to find foreign function 'fliparseVariableInFile' in FLI object file " C:\Modeltech_6.3e\win32/./novas_fli.dll " .

意思是novas.vhd定義的fliparseVariableInFile在novas_fli.dll找不到,致於為什麼會有此錯誤,我並不清楚。

將novas.vhd修改成如下所示:

novas.vhd / VHDL

1 package pkg is
2 attribute foreign : string ;
3
4 procedure fsdbDumpfile (file_name : in string );
5 attribute foreign of fsdbDumpfile : procedure is " fliparseTraceInit ./novas_fli.dll " ;
6
7 procedure fsdbDumpvars (depth : in integer ;
8 region_name : in string );
9 attribute foreign of fsdbDumpvars : procedure is " fliparsePartial ./novas_fli.dll " ;
10 end ;
11
12 package body pkg is
13 procedure fsdbDumpfile(file_name : in string ) is
14 begin
15 assert false report " ERROR : foreign subprogram not called " severity note ;
16 end ;
17
18 procedure fsdbDumpvars(depth : in integer ;
19 region_name : in string ) is
20 begin
21 assert false report " ERROR : foreign subprogram not called " severity note ;
22 end ;
23 end ;
24
25 entity novas is end ;
26
27 architecture novas_arch of novas is
28 attribute foreign : string ;
29 attribute foreign of novas_arch : architecture is " fliparseCommand novas_fli.dll " ;
30 begin
31 end ;
32

也就是僅留下fsdbDumpfile()與fsdbDumpvars()兩個function,其他的都刪除。

根據我使用Debussy的經驗,只要留這兩個function就夠用了,其他Debussy的function我還真的沒用過。

在novas.vhd也看到了這些是定義在pkg這個package下,所以在counter_tb.vhd必須use work.pkg.all。

Step 5:

執行ModelSim的批次檔

mod.bat

vsim -c - do sim . do

執行結果


D:\0Clare\VerilogLab\ModelSim\counter_vhdl>vsim -c -do sim.do
Reading C:/Modeltech_6.3e/tcl/vsim/pref.tcl

# 6 .3e

# do sim.do
# ** Warning: (vlib- 34 ) Library already exists at " work " .
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Compiling package pkg
# -- Compiling package body pkg
# -- Loading package pkg
# -- Compiling entity novas
# -- Compiling architecture novas_arch of novas
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Loading package std_logic_arith
# -- Loading package std_logic_unsigned
# -- Compiling entity counter
# -- Compiling architecture arc of counter
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Loading package std_logic_arith
# -- Loading package std_logic_unsigned
# -- Loading package pkg
# -- Compiling entity counter_tb
# -- Compiling architecture arc of counter_tb
# vsim counter_tb
# Loading C:\Modeltech_6.3e\win32/novas.dll
# // ModelSim SE 6 .3e Feb 2 2008
# //
# // Copyright 1991 - 2008 Mentor Graphics Corporation
# // All Rights Reserved.
# //
# // THIS WORK CONTAINS TRADE SECRET AND
# // PROPRIETARY INFORMATION WHICH IS THE PROPERTY
# // OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS
# // AND IS SUBJECT TO LICENSE TERMS.
# //
# Loading std.standard
# Loading ieee.std_logic_1164(body)
# Loading ieee.std_logic_arith(body)
# Loading ieee.std_logic_unsigned(body)
# Loading work.pkg(body)
# Loading C:\Modeltech_6.3e\win32/./novas_fli.dll
# Loading work.counter_tb(arc)
# Loading work.counter(arc)
# Novas FSDB Dumper for ModelSim 5.4 (FLI) , Release 5 .4v9 (Win95/NT) 05 / 04 / 2005
# Copyright (C) 1996 - 2004 by Novas Software , Inc.
# *Novas* Create FSDB file 'counter.fsdb'

Step 6:

執行Debussy批次檔部份

deb.bat

debussy –vhdl –93 novas.vhd counter_tb . vhd counter.vhd –top counter_tb -ssf counter . fsdb -sswr counter . rc

-vhdl 表示支援VHDL語法,因為Debussy預設支援Verilog

-93 表示支援VHDL 93的語法

-top 指定top module,在Verilog可以不指定top,Debussy可以自動判斷而抓到top module,但是VHDL沒辦法,需要自己指定,若不指定,待會會有GUI要你手動挑選top module

執行結果

3.RTL使用VHDL,testbench使用Verilog

Step 1:

設定ModeSim使用Verilog PLI (因為testbench使用Verilog)

將C:\Novas\Debussy\share\PLI\modelsim_pli\WINNT\novas.dll複製到C:\Modeltech_6.3e\win32\下
修改C:\Modeltech_6.3e\modelsim.ini,將Veriuser部分修改成如下所示:

; List of dynamically loaded objects for Verilog PLI applications
; Veriuser = veriuser.sl
; use by verilog
Veriuser = novas.dll
; use by vhdl
; Veriuser = novas_fli.dll

modelsim.ini是個read only檔,要修改前記得修改其屬性才能存檔。

Step 2:

RTL部分 (以4 bit counter為例)

counter.vhd / VHDL

1 -- (C) OOMusou 2011 http: // oomusou.cnblogs.com
2  
3   -- Filename : counter.vhd
4   -- Simulator : ModelSim 6 .3e, Debussy 5.4 v9
5   -- Description : ModelSim with debussy
6   -- Release : 02 / 05 / 2011 1.0
7
8   library IEEE;
9 use IEEE.std_logic_1164. all ;
10 use IEEE.std_logic_unsigned. all ;
11
12 entity counter is
13 port ( clk : in std_logic ;
14 rst_n : in std_logic ;
15 cnt : out std_logic_vector ( 3 downto 0 ));
16 end entity counter;
17
18 architecture arc of counter is
19 signal cnt_r : std_logic_vector ( 3 downto 0 );
20 begin
21 process (clk, rst_n)
22 begin
23 if (rst_n = ' 0 ' ) then
24 cnt_r <= " 0000 " ;
25 elsif rising_edge (clk) then
26 cnt_r <= cnt_r + 1 ;
27 end if ;
28 end process ;
29
30 cnt <= cnt_r;
31 end arc;

Step 3:

Testbench部分

counter_tb.v / Verilog

1 /*
2 (C) OOMusou 2011 http://oomusou.cnblogs.com
3
4 Filename : counter_tb.v
5 Compiler : ModelSim 6.3e, Debussy 5.4 v9
6 Description : ModelSim with debussy
7 Release : 01/31/2010 1.0
8   */
9
10   module counter_tb;
11
12   reg clk;
13   reg rst_n;
14   wire [ 3 : 0 ] cnt;
15
16   // 50MHz
17   always #( 10 ) clk = ~ clk;
18
19   initial begin
20 # 0 ;
21 clk = 1 ' b0;
22   rst_n = 1 ' b0;
23  
24 # 5 ;
25 rst_n = 1 ' b1;
26   # 195 ;
27 $finish;
28   end
29
30   initial begin
31 $fsdbDumpfile( " counter.fsdb " );
32 $fsdbDumpvars( 1 , counter_tb);
33   end
34
35 counter u_counter (
36 .clk(clk),
37 .rst_n(rst_n),
38 .cnt(cnt)
39 );
40
41   endmodule

30行

initial begin
$fsdbDumpfile( " counter.fsdb " );
$fsdbDumpvars( 1 , counter_tb);
end

$fsdbDumpvars()的第一個參數是填1不是0,若填0會產生以下warning,不過並不影響最後fsdb的結果。

# ** Warning: Unknown scope type: counter_tb.u_counter 1010
# : counter_tb.v( 30 )
# Time: 0 ns Iteration: 0 Instance: /counter_tb
# ** Warning: Unknown scope type: counter_tb.u_counter 1010
# : counter_tb.v( 30 )
# Time: 0 ns Iteration: 0 Instance: /counter_tb
# *Novas* End of dumping.

Step 4:

ModelSim script部分

vsim.do

vlib work
vcom counter . vhd
vlog counter_tb . v
vsim counter_tb
run 200ns
q

VHDL使用vcom編譯,Verilog使用vlog編譯。

Step 5:

執行ModelSim的批次檔

mod.bat

vsim -c - do sim . do

執行結果


D:\0Clare\VerilogLab\ModelSim\counter_vhdl_verilog>vsim -c -do sim.do
Reading C:/Modeltech_6.3e/tcl/vsim/pref.tcl

# 6 .3e

# do sim.do
# ** Warning: (vlib- 34 ) Library already exists at " work " .
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Loading package std_logic_arith
# -- Loading package std_logic_unsigned
# -- Compiling entity counter
# -- Compiling architecture arc of counter
# Model Technology ModelSim SE vlog 6 .3e Compiler 2008.02 Feb 2 2008
# -- Compiling module counter_tb
#
# Top level modules:
# counter_tb
# vsim counter_tb
# Loading C:\Modeltech_6.3e\win32/novas.dll
# // ModelSim SE 6 .3e Feb 2 2008
# //
# // Copyright 1991 - 2008 Mentor Graphics Corporation
# // All Rights Reserved.
# //
# // THIS WORK CONTAINS TRADE SECRET AND
# // PROPRIETARY INFORMATION WHICH IS THE PROPERTY
# // OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS
# // AND IS SUBJECT TO LICENSE TERMS.
# //
# Loading work.counter_tb(fast)
# Loading std.standard
# Loading ieee.std_logic_1164(body)
# Loading ieee.std_logic_arith(body)
# Loading ieee.std_logic_unsigned(body)
# Loading work.counter(arc)
# Novas FSDB Dumper for ModelSim , Release 5 .4v9 (Win95/NT) 05 / 04 / 2005
# Copyright (C) 1996 - 2004 by Novas Software , Inc.
# *Novas* Create FSDB file 'counter.fsdb'
# *Novas* Start dumping the scope(counter_tb) , layer( 0 ).
# ** Warning: Unknown scope type: counter_tb.u_counter 1010
# : counter_tb.v( 30 )
# Time: 0 ns Iteration: 0 Instance: /counter_tb
# ** Warning: Unknown scope type: counter_tb.u_counter 1010
# : counter_tb.v( 30 )
# Time: 0 ns Iteration: 0 Instance: /counter_tb
# *Novas* End of dumping.

D:\0Clare\VerilogLab\ModelSim\counter_vhdl_verilog>vsim -c -do sim.do
Reading C:/Modeltech_6.3e/tcl/vsim/pref.tcl

# 6 .3e

# do sim.do
# ** Warning: (vlib- 34 ) Library already exists at " work " .
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Loading package std_logic_arith
# -- Loading package std_logic_unsigned
# -- Compiling entity counter
# -- Compiling architecture arc of counter
# Model Technology ModelSim SE vlog 6 .3e Compiler 2008.02 Feb 2 2008
# -- Compiling module counter_tb
#
# Top level modules:
# counter_tb
# vsim counter_tb
# ** Note: (vsim- 3813 ) Design is being optimized due to module recompilation...
# ** Note: (vsim- 3865 ) Due to PLI being present , full design access is being specified.
# Loading C:\Modeltech_6.3e\win32/novas.dll
# // ModelSim SE 6 .3e Feb 2 2008
# //
# // Copyright 1991 - 2008 Mentor Graphics Corporation
# // All Rights Reserved.
# //
# // THIS WORK CONTAINS TRADE SECRET AND
# // PROPRIETARY INFORMATION WHICH IS THE PROPERTY
# // OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS
# // AND IS SUBJECT TO LICENSE TERMS.
# //
# Loading work.counter_tb(fast)
# Loading std.standard
# Loading ieee.std_logic_1164(body)
# Loading ieee.std_logic_arith(body)
# Loading ieee.std_logic_unsigned(body)
# Loading work.counter(arc)
# Novas FSDB Dumper for ModelSim , Release 5 .4v9 (Win95/NT) 05 / 04 / 2005
# Copyright (C) 1996 - 2004 by Novas Software , Inc.
# *Novas* Create FSDB file 'counter.fsdb'
# *Novas* Start dumping the scope(counter_tb) , layer( 1 ).
# *Novas* End of dumping.

Step 6:

執行Debussy批次檔部份

deb.bat

vhdlcom - 93 counter.vhd
vericom - 2001 counter_tb.v
debussy -lib work -top counter_tb -ssf counter.fsdb -sswr counter.rc

若RTL與testbench同時包含Verilog與VHDL,Debussy就無法直接開啟,必須先將Verilog與VHDL分別編譯成lib,然後才可開啟。

VHDL使用vhdlcom作編譯,-93表示支援VHDL 93的語法,Verilog使用vericom作編譯,-2001表示支援Verilog 2001語法,vhdlcom與vericom預設都會編譯在work這個lib下,所以debussy開啟時需用-lib指定使用work這個lib,並用-top指定top module,這樣才可開啟mixed-language的design。

執行結果

4.RTL使用Verilog,testbench使用VHDL

Step 1:

設定ModelSim使用VHDL FLI (因為testbench使用VHDL)

將C:\Novas\Debussy\share\PLI\modelsim_fli54\WINNT\novas_fli.dll複製到C:\Modeltech_6.3e\win32\下
修改C:\Modeltech_6.3e\modelsim.ini,將Veriuser部分修改成如下所示:

; List of dynamically loaded objects for Verilog PLI applications
; Veriuser = veriuser.sl
; use by verilog
; Veriuser = novas.dll
; use by vhdl
Veriuser = novas_fli.dll

modelsim.ini是個read only檔,要修改前記得修改其屬性才能存檔。

Step 2:

RTL部分 (以4 bit counter為例)

counter.v / Verilog

1 /*
2 (C) OOMusou 2011 http://oomusou.cnblogs.com
3
4 Filename : counter.v
5 Simulator : ModelSim 6.3e, Debussy 5.4 v9
6 Description : ModelSim with debussy
7 Release : 01/31/2010 1.0
8   */
9
10   module counter (
11 clk,
12 rst_n,
13 cnt
14 );
15
16   input clk;
17   input rst_n;
18   output [ 3 : 0 ] cnt;
19
20   reg [ 3 : 0 ] cnt;
21
22   always @( posedge clk, negedge rst_n) begin
23 if ( ~ rst_n)
24 cnt <= 4 ' h0;
25   else
26 cnt <= cnt + 1 ' b1;
27   end
28
29   endmodule

Step 3:

Testbench部分

counter.vhd / VHDL

1 -- (C) OOMusou 2011 http: // oomusou.cnblogs.com
2
3 -- Filename : counter_tb.vhd
4 -- Simulator : ModelSim 6 .3e, Debussy 5.4 v9
5 -- Description : ModelSim with debussy
6 -- Release : 01 / 31 / 2010 1.0
7
8 library IEEE;
9 use IEEE.std_logic_1164. all ;
10 use IEEE.std_logic_unsigned. all ;
11 use work.pkg. all ;
12
13 entity counter_tb is
14 end entity counter_tb;
15
16 architecture arc of counter_tb is
17 component counter
18 port (
19 clk : in std_logic ;
20 rst_n : in std_logic ;
21 cnt : out std_logic_vector ( 3 downto 0 )
22 );
23 end component ;
24
25 signal clk : std_logic : = ' 0 ' ;
26 signal rst_n : std_logic : = ' 0 ' ;
27 signal cnt : std_logic_vector ( 3 downto 0 );
28
29 begin
30 process
31 begin -- 50MHz
32 clk_loop : loop
33 clk <= ' 0 ' ;
34 wait for 10 ns;
35 clk <= ' 1 ' ;
36 wait for 10 ns;
37 end loop clk_loop;
38 end process ;
39
40 process
41 begin
42 wait for 5 ns;
43 rst_n <= ' 1 ' ;
44 end process ;
45
46 process
47 begin
48 fsdbDumpfile( " counter.fsdb " );
49 fsdbDumpvars( 0 , " counter_tb " );
50 wait ;
51 end process ;
52
53 u_counter : counter
54 port map (
55 clk => clk,
56 rst_n => rst_n,
57 cnt => cnt
58 );
59 end arc; 

Step 4:

ModelSim script部分

vsim.do

vlib work
vcom novas . vhd
vlog counter . v
vcom counter_tb . vhd
vsim counter_tb
run 200ns
q

VHDL使用vcom編譯,Verilog使用vlog編譯。

Step 5:

執行ModelSim的批次檔

mod.bat

vsim -c - do sim . do

執行結果


D:\0Clare\VerilogLab\ModelSim\counter_verilog_vhdl>vsim -c -do sim.do
Reading C:/Modeltech_6.3e/tcl/vsim/pref.tcl

# 6 .3e

# do sim.do
# ** Warning: (vlib- 34 ) Library already exists at " work " .
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Compiling package pkg
# -- Compiling package body pkg
# -- Loading package pkg
# -- Compiling entity novas
# -- Compiling architecture novas_arch of novas
# Model Technology ModelSim SE vlog 6 .3e Compiler 2008.02 Feb 2 2008
# -- Compiling module counter
#
# Top level modules:
# counter
# Model Technology ModelSim SE vcom 6 .3e Compiler 2008.02 Feb 2 2008
# -- Loading package standard
# -- Loading package std_logic_1164
# -- Loading package std_logic_arith
# -- Loading package std_logic_unsigned
# -- Loading package pkg
# -- Compiling entity counter_tb
# -- Compiling architecture arc of counter_tb
# vsim counter_tb
# Loading C:\Modeltech_6.3e\win32/novas.dll
# // ModelSim SE 6 .3e Feb 2 2008
# //
# // Copyright 1991 - 2008 Mentor Graphics Corporation
# // All Rights Reserved.
# //
# // THIS WORK CONTAINS TRADE SECRET AND
# // PROPRIETARY INFORMATION WHICH IS THE PROPERTY
# // OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS
# // AND IS SUBJECT TO LICENSE TERMS.
# //
# Loading std.standard
# Loading ieee.std_logic_1164(body)
# Loading ieee.std_logic_arith(body)
# Loading ieee.std_logic_unsigned(body)
# Loading work.pkg(body)
# Loading C:\Modeltech_6.3e\win32/./novas_fli.dll
# Loading work.counter_tb(arc)
# Loading work.counter(fast)
# Novas FSDB Dumper for ModelSim 5.4 (FLI) , Release 5 .4v9 (Win95/NT) 05 / 04 / 2005
# Copyright (C) 1996 - 2004 by Novas Software , Inc.
# *Novas* Create FSDB file 'counter.fsdb'

Step 6:

執行Debussy批次檔部份

deb.bat

vericom - 2001 counter.v
vhdlcom - 93 novas.vhd counter_tb.vhd
debussy -lib work -top counter_tb -ssf counter.fsdb -sswr counter.rc

執行結果

完整程式碼下載
counter_verilog.7z (RTL與testbench皆使用Verilog)
counter_vhdl.7z (RTL與testbench皆使用VHDL)
counter_vhdl_verilog.7z (RTL使用VHDL,testbench使用Verilog)
counter_verilog_vhdl.7z (RTL使用Verilog,testbench使用VHDL)

Conclusion
本文介紹了Debussy與ModelSim的Co-Simulation,這兩個工具的合作,可以發揮ModelSim能Verilog與VHDL一起simulation的優點,又可發揮Debussy的trace與debug的功力;並且實際示範了2種HDL語言交互simulation的方法,其中包含了一些小技巧。

在Quartus II也允許這種跨語言的方式作synthesis,或許你會問,為什麼要搞的這麼複雜?乖乖只用Verilog或只用VHDL就好了,但現實上,這兩個HDL語言佔有率幾乎一半一半,無論是工作上也好,或者看書網路上找資源,遇到Verilog或者VHDL的機會仍相當多,像我是Verilog比較熟,但有些IP是用VHDL開發(無論是買來的或者網路抓的),所以VHDL也要多少懂一點,最少要能一起Co-Simulation,雖然重要的是硬體的設計,但多懂一種語言也不是壞事。

Reference
[1] 小時不識月 Stupid & Hungry, [筆記] 怎樣使用Debussy + ModelSim快速查訪前仿真波形 
[2] 電子開發網, debussy和modelsim協同仿真 (VHDL)

全文完。

(筆記) 如何使用Debussy與ModelSim做Co-Simulation? (SOC) (Verilog) (VHDL) (Debussy) (ModelSim)相关推荐

  1. (原創) 深入探討blocking與nonblocking (SOC) (Verilog)

    Abstract Verilog雖然是個語法簡單的語言,但是blocking與nonblocking卻是大家學習Verilog時永遠的痛,即時是很資深的IC Designer,也未必完全搞清楚兩者的差 ...

  2. (筆記) 如何使用ModelSim作前仿真與後仿真? (SOC) (Quartus II) (ModelSim)

    Abstract 本文介紹使用ModelSim做前仿真,並搭配Quartus II與ModelSim作後仿真. Introduction 使用環境:Quartus II 8.1 + ModelSim- ...

  3. golang 筆記:make 與 new 的差別

    转载:https://medium.com/d-d-mag/golang-%E7%AD%86%E8%A8%98-make-%E8%88%87-new-%E7%9A%84%E5%B7%AE%E5%88% ...

  4. ARMv8 與 Linux的新手筆記

    ARMv8 與 Linux的新手筆記 by loda hlchou@gmail.com 從iPhone 5S採用ARMv8處理器架構後,對於ARMv8 64bits的相關討論很多,也受到大家關注,Go ...

  5. (筆記) 如何增加SignalTap II能觀察的reg與wire數量? (SOC) (Quartus II) (SignalTap II)

    Abstract 無法在SignalTap II觀察reg與wire,主要都是因為被Quartus II優化的關係,在Quartus II簡單的設定,就能增加SignalTap II能觀察的數量. I ...

  6. Git-rebase 小筆記

    https://blog.yorkxin.org/posts/2011/07/29/git-rebase/ 最近剛好有個機會整理很亂的 Git commit tree,終於搞懂了 rebase 的用法 ...

  7. (筆記) 如何在字串中從指定字元抓到指定字元(pointer版)?

    Abstract 這是一個實務上常用的功能,可惜在C語言的string.h並沒有提供,本文實作出一個小function達到此功能,並搭配pointer. Introduction 在(筆記) 如何在字 ...

  8. (筆記) 如何在字串中從指定字元抓到指定字元(pointer版)? (C/C++) (C)

    Abstract 這是一個實務上常用的功能,可惜在C語言的string.h並沒有提供,本文實作出一個小function達到此功能,並搭配pointer. Introduction 在(筆記) 如何在字 ...

  9. Git 初學筆記 - 指令操作教學

    Git 是分散式的版本控制系統, 從架設.簡易操作.設定, 此篇主要是整理基本操作.遠端操作等. 註: Git 的範圍太廣了, 把這篇當作是初學入門就好了. 注意事項 由 project/.git/c ...

最新文章

  1. list extend 和 append
  2. 公钥密码--Elgamal
  3. sklearn自学指南(part5)--使用手册的目录
  4. python基础之网络基础
  5. docker es持久化_Docker 搭建 ES 集群并整合 Spring Boot
  6. android 属性动画实例,Android属性动画完全解析 中 ,ValueAnimator和ObjectAnimator的高级用法...
  7. struts2中的method
  8. 年后跳槽必备的 Java 题库,全网最全!
  9. DM642 视频采集基本架构
  10. 编程常见错误——循环中进行有符号数和无符号数的比较
  11. [C++] STL标准模板库
  12. shiro(SpringBoot+SpringMVC+Mybatis+Shrio):丰富的登录模块附有GIF动图,博主可免费答疑
  13. VS code 连接Linux服务器
  14. weka,FP,priori
  15. 国内知名插画培训机构有哪些
  16. hadoop 不能加载native-hadoop library问题
  17. 使用Matlab和Minepy工具箱做变量的互信息MIC (maximal information coefficient ) 分析
  18. python测试框架untest_python自动化测试框架unittest
  19. 关于Rost ContentMining 6.0情感分析出现空白的解决方案
  20. 计算机更新80072f76,win10系统更新升级出现错误代码0x80072f76的解决方法

热门文章

  1. 【目标检测-YOLO】YOLOv5-v6.0-网络架构详解(第二篇)
  2. 《黑客与画家》读后感--为什么书呆子不受欢迎
  3. 图像区分平坦区域、边缘、角点区域
  4. 数码相机删除照片怎么恢复?
  5. Hive 窗口函数大全
  6. 教师网络计算机研修日志,网络研修日志范文(通用7篇)
  7. 电池监控芯片bq34z100-g1调试
  8. php伪造来路301,使用 fsockopen 伪造来路
  9. 计算机语言表示教师节快乐,教师节快乐的微信祝福语大全(精选80句)
  10. Java学习必备武林秘籍,大侠请收好!