Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of using SystemVerilog DPI based on QuestaSIM

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what is the use of SystemVerilog DPI based on QuestaSIM". In daily operation, I believe that many people have doubts about the use of SystemVerilog DPI based on QuestaSIM. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what is the use of SystemVerilog DPI based on QuestaSIM?" Next, please follow the editor to study!

The design and Questa SIM simulation scripts are stored in the tool installation directory:

/ examples/tutorials/systemverilog/dpi_basic

There are three things you need to do before you execute the script:

1. Create a folder and copy the above files to this folder

2. Set the QUESTA_HOME environment variable (maybe you already set it when you installed it)

3. Install the gcc-4.2.1-mingw32vc9 compiler to the installation directory of Questa SIM

1 module test (); 3 typedef enum {RED, GREEN, YELLOW} traffic_signal; 5 traffic_signal light; 7 function void sv_GreenLight (); 8 begin9 light = GREEN;10 end11 endfunction 13 function void sv_YellowLight (); 14 begin15 light = YELLOW;16 end17 endfunction 19 function void sv_RedLight (); 20 begin21 light = RED;22 end23 endfunction 25 task sv_WaitForRed (); 26 begin27 # 10 th 28 end29 endtask 31 export "DPI-C" function sv_YellowLight;32 export "DPI-C" function sv_RedLight 33 export "DPI-C" task sv_WaitForRed; 35 import "DPI-C" context task c_CarWaiting (); 37 initial38 begin39 # 10 sv_GreenLight;40 # 10 centering CarWaiting 41 # 10 sv_GreenLight;42 end 44 endmodule

First take a look at the above test file test.sv

Line1 and line44 give the test platform a name test, in which it performs various simulation activities

Line3 and line5 define an enumerated variable light, which is the object for subsequent operations

Line7~line11, line13~line17 and line19~line23 define SystemVerilog function respectively, and the prefix sv_ indicates that this is function written in SystemVerilog language.

Line25~line29 defines SystemVerilog task, and the prefix sv_ indicates that this is a task written in the SystemVerilog language. This task contains latency, so it cannot be implemented in function.

Line31~line33 is the key to SystemVerilog DPI, using the keyword "export" to make the specified function or task visible to the C language, and its name must be placed in a special name space.

The line35 "import" declaration is used to import C world code into the Verilog world.

# include "dpi_types.h" int c_CarWaiting () {printf ("There's a car waiting on theother side.\ n"); printf ("Initiatechange sequence...\ n"); sv_YellowLight (); sv_WaitForRed (); sv_RedLight (); return 0;}

Here we can find that SystemVerilog DPI is centered on SystemVerilog. When you want to make function or task in SystemVerilog visible to C, you need to export them to the C world. Similarly, if you want your SystemVerilog code to see and access something in the C world, you need to import it to SystemVerilog

On the Windows platform, double-click the windows.bat file between us

Vlib workvlog test.sv-dpiheader dpi_types.h foreign.cvopt + acc test-o opt_testvsim-I opt_test-do "add wave light; view source"

And then execute

VSIM 3 > run# There's a car waiting on the other side.# Initiate change sequence...

At this point, the study on "what is the use of QuestaSIM-based SystemVerilog DPI" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report