The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Design Languages >> Verilog-AMS >> Can VerilogA code co-simulate with C or script languages? https://designers-guide.org/forum/YaBB.pl?num=1258832226 Message started by couragebo on Nov 21st, 2009, 11:37am |
Title: Can VerilogA code co-simulate with C or script languages? Post by couragebo on Nov 21st, 2009, 11:37am Hi, everyone, As you know, VerilogA is a very practical language for the circuit modeling. But in some cases it's not powerful enough, and it needs to "cooperate" with other tools, that's why I ask this question. In fact, I'd like to create a VerilogA model in Spectre, in this model I need to do some complicated math calculation (like inverse of matrix, or multiplication of the complex number). This kind of job, since it's can be easily done by the existed code, I want it to be done outside the VerilogA module by some script language (Python...), and send back the results to the VerilogA module. My question is: Is it possible that VerilogA code (in Spectre) calls some script functions? or are there some other methods can make this job done? To my knowledge, there is a bridge between VerilogHDL and C, which is VPI, but can it be applied to VerilogA too? and Can Spectre support it now? Thanks for your help. Best regards Bo |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by rajdeep on Nov 23rd, 2009, 1:23am Hi, You can do it with Verilog AMS. You can interface it with C, not sure of any scripting language. You can download the Verilog AMS LRM and most probably chapter 10 talks abt it. I have some exp of using it. But long time back and I remember that I used to run the design using ncvlog -ams option from command line. I guess it calls up sepectre (who else) to simulate the analog part, and a C function was used to write data (signal values) into a file (a named pipe to be precise). Im not sure what will happen if you use Spectre from Analog Environment!! But it certainly works with Verilog AMS. You might have to move from Spectre....to AMS. cheers! Rajdeep |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by couragebo on Nov 23rd, 2009, 8:53am Thank you, Rajdeep, for the quick reply and the in-depth explanation! You are right, I probablely have move to AMS designer. I read the latest LRM, but there is not an example in the manual. I guess that the C code should be compiled and put into the Verilog ams shared object directory, but i am not sure if it's correct or if there is any automatical method. There are some handles that i can use to get the Verilog ams values, but I can not see how to link them to the C code, to be exact, how to create a simulator task and call the C code. Rajdeep, can you remember some details about that? Thanks again. Best regards Bo |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by rajdeep on Nov 24th, 2009, 1:23am Hi Bo! Are you using cadence ICFB? Then you must be having the usual cadence directory distribution where it is installed. Now, I remember of using some of the makefiles from there!!! Yes!! and modified them to include my design library path etc. to make it run!! I will try to dig it out from my old databse because it must be somewhere!! I should be able to share some of those files!! Meanwhile you can look into the cadence installation path to look for those makefiles!! :-D cheers! Rajdeep |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by Frank Wiedmann on Nov 24th, 2009, 1:26am It is also possible to do a cosimulation with Spectre RF or AMS Designer and Matlab/Simulink. See http://www.mathworks.com/products/connections/product_detail/product_35807.html and http://www.cadence.com/rl/Resources/conference_papers/ctp_cdnliveemea2006_didier_cosimulation.pdf, the chapter "Cosimulation with MATLAB and Simulink" of the Spectre RF User Guide and the chapter "Cosimulation with Simulink and AMS Designer" of the AMS Designer User Guide. |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by couragebo on Nov 24th, 2009, 6:39am hi, Rajdeep, Thanks for your update. I look into the cadence intallation path, and find many makefile, they are in different path such as: ".../ic5141/tools/systemc/...", "../ic5141/tools/itkDB", ".../ic5141/tools.lnx86/systemc/....". After looking at my compile log file, i think it's the makefile in ".../ic5141/tools.lnx86/systemc/....". In fact, I find also a GNUmakefile in the directory of the verilog module. |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by couragebo on Nov 24th, 2009, 6:53am Thanks Frank for the sharing, it confirms that there exists a standard interface between AMS designer and the other simulators. Also I did some search myself , and found an interesting book discussing the Verilog VPI or PLI interface: "The Verilog PLI Handbook: A User's Guide and Comprehensive Reference on the Verilog Programming Language Interface " http://www.amazon.com/Verilog-PLI-Handbook-Comprehensive-Programming/dp/079238489X And there is also a paper about the Verilog / C co-simulation: http://www.hindawi.com/journals/es/2008/171358.html |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by couragebo on Nov 24th, 2009, 8:42am The following is makefile in the VerilogA directory: Code:
|
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by rajdeep on Nov 24th, 2009, 2:06pm Hi! I have found the stuff!! There is a particular directory structure we used to follow, and there were altogether 3 makefiles placed in diffent hierarchry :-/ We used ncsim. I know it doesnt help much... Anyway, coming back to VPI calls. We wrote a task called mytestprog, and used to call it from the top level VerilogAMS module. Code:
Pretty simple! Just like a system task! Now the next thing (rather the first thing) wud be to define this task somewhere and let ur simulator know there exists a task like that. This step is called registering your function. The directory that I was talking abt, there we found already such a function (c code) provided. This one was called vpiregn.c. (Im bit doubtful whether it was there already or we just edited it). But I think we just had to edit it!! Just here and there... It looks like this .. Code:
Now the next thing is to define the task which is the funtion vpitest(). So we wrote another C code to define vpitest(), where we used different VPI handles and functions. In the manual you will get defintion of all these functions. Use them to write that all important C function of yours. Hope this helps to give you a start... Rajdeep |
Title: Re: Can VerilogA code co-simulate with C or script languages? Post by couragebo on Nov 25th, 2009, 1:56am hi, Rajdeep, Thanks a lot for the help and the typing... :) The explanation is very clear and i know what i am going to do next. First I will create a very simple example and make it run... Thanks again Bo |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |