Home > Community > Blogs > Functional Verification > specman matlab package update
 
Login with a Cadence account.
Not a member yet?
Create a permanent login account to make interactions with Cadence more conveniennt.

Register | Membership benefits
Get email delivery of the Functional Verification blog (individual posts).
 

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

Specman-Matlab Package Update

Comments(0)Filed under: Functional Verification, Incisive Enterprise Simulator (IES), e, Specman, C, IES-XL, ESL, Matlab

[Preface: we interrupt the Specman 9.2 Preview series to notify you of an update to the popular Specman-Matlab shareware package. Long before the term "crowd sourcing" was invented, our Application Engineers created and continue to maintain the venerable Specman+Matlab package described in this article. Guest blogger and Field colleague Jangook Lee is the latest to have refreshed it for a customer in Asia to support 64 bit mode. – Team Specman]

Testbenches need to exchange data with other applications for reading stimulus from an algorithmic model, or to connect to a reference model for checking DUT responses. Specifically, many communications and storage devices require modulated stimulus to verify a signal processing hardware block whose job it is to demodulate the signal. Matlab or C models may be used to model such algorithms, and of course model whole systems.

To verify such models, Specman has a built-in, flexible C interface that is used to talk to C/C++ models or other applications that provide a C automation API. With this Specman C interface and a little bit of code, we have created a package that makes it easy for users to integrate Matlab models into a Metric Driven Verification environment written in the e language. This “sn_matlab” package has been used and improved by dozens of customers and Application Engineers since it was first written in 2001. The main capabilities of the package are:

  • Use Specman to initialize and tear down the Matlab engine in batch mode
  • Issue Matlab commands from e-code, use the Specman command prompt to load .m files, initialize variables, and other operational tasks.
  • Transfer data to and from the Matlab engine to Specman / an e language test bench
  • Compare data of previously retrieved Matlab arrays
  • Access Matlab arrays from e-code without converting them to e list data structure
  • Convert Matlab arrays into e-lists

The complete Specman-Matlab package is posted here in the Functional Verification section of the Cadence Community Forums.

How to Run the Demo

You need Matlab and Incisive Enterprise Simulator – XL or stand-alone Specman (v8.1 or later). There is a README file in the package -- make sure to review it as it gives a more detailed overview of the package, shows how to run a demo and/or validate it’s installed correctly, and it also explains the general test flow. The test file included in the package called "test_get_cmp_mdim.e" shows all the capabilities mentioned above.

Once you compile and link in this package with your testbench, you will have a handle to the Matlab engine via a global field called "matlab". (IMPORTANT: as with anything that touches C/C++, compile and linking can get a little tricky because you need to make sure that you are linking the right libraries for your platform -- pay attention to 32-bits vs. 64-bits .so files, etc. and you will be OK.) You can then call functions defined in the Matlab struct in e to operate the Matlab engine.

For example, to send a command to Matlab, you'd write:

var s2 : list of string =
      {"sin_res = sin(mx_dbl_in);";
      "asin_res = asin(sin_res);";
      "mx_dbl_res = fix(asin_res * 1000000) * 0.000001;";
      "r1 = fix(1000 * rand(20,90));";
      "t1 = mx_int_in + r1; ";
      "mx_int_res = int32( t1 - r1 );" };
var result := matlab.exec(s2);

(Note that you can also use e macro MB s2 to do the same operation.)

Other useful functions accessible via the Matlab object are:

// read a matlab variable
get_var(v : sn_matlab_var_s) : matlab_rc_t is empty;

// set a matlab variable
put_var(v : sn_matlab_var_s) : matlab_rc_t is empty;

// compare a specman variable with a matlab mx_array variable
is_equal(sn_var : sn_matlab_var_s, mb_var : matlab_mx_array_s) : bool is empty;


To learn more about the Specman Matlab interface functions and how things really work, read the document called “Matlab Specman Interface example.pdf” included the package.

Good luck using the package, and please post to back to this blog or to the Community any questions you have, or enhancements you make to it!

Jangook Lee
Lead Services Application Engineer
Cadence Korea

Comments(0)

Leave a Comment


Name
E-mail (will not be published)
Comment
 I have read and agree to the Terms of use and Community Guidelines.
Community Guidelines
The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.