Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

HELLLP about DPI coding

Altera_Forum
Honored Contributor II
4,956 Views

Try to make a function generator by using DPI sin functions from C, however, error occurred  

this is my whole sv code 

 

package math_pkg; 

//import dpi task C Name = SV function name 

 

import "DPI-C" pure function real cos (input real rTheta); 

import "DPI-C" pure function real sin (input real rTheta); 

import "DPI-C" pure function real log (input real rVal); 

import "DPI-C" pure function real log10 (input real rVal); 

endpackage : math_pkg 

 

 

 

 

 

Error (10170): Verilog HDL syntax error at math_pkg.sv(3) near text ""DPI-C"; expecting an identifier 

what the heck is going on dude ??
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
4,100 Views

DPI is for simulation, not for synthesis.

0 Kudos
Altera_Forum
Honored Contributor II
4,100 Views

 

--- Quote Start ---  

DPI is for simulation, not for synthesis. 

--- Quote End ---  

 

 

Thank you for replying  

I wonder why this is synthesis not simulation 

Is there a way that I can use sine functions for synthesis in fpga? 

then how to create a function generator with C languages ? 

thankyou!
0 Kudos
Altera_Forum
Honored Contributor II
4,100 Views

 

--- Quote Start ---  

https://pdfs.semanticscholar.org/f523/c638e72ce7a9b068470510ba54d23bf715fb.pdf 

--- Quote End ---  

 

Thank you so much! this helps me a lot! , :) 

Can I also ask a question the input/output declaration for a module?  

for example  

module slc3( 

input logic [15:0] S, 

input logic Clk, Reset, Run, Continue, 

output logic [11:0] LED, 

output logic [6:0] HEX0, HEX1, HEX2, HEX3, 

output logic CE, UB, LB, OE, WE, 

output logic [19:0] ADDR, 

inout wire [15:0] Data //tristate buffers need to be of type wire 

); 

i see that all the input output are calculated in a binary form, 

 

 

However , the input from the article suggestests a fraction number(like 0.45) 

https://alteraforum.com/forum/attachment.php?attachmentid=13710&stc=1  

if the result from sine wave is, for example, -0.52, should i express this in binary for the module 's output? and datatype of the output be like?(logic, real....) thanks!
0 Kudos
Altera_Forum
Honored Contributor II
4,100 Views

I see you have a lot to learn about designing digital hardware. Everything in hardware binary. https://sestevenson.wordpress.com/introduction-to-fixed-point-representation/

0 Kudos
Reply