Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to pass 64 bit variables and more to PLI C model in verilog

Status
Not open for further replies.

tariq786

Advanced Member level 2
Joined
Feb 24, 2004
Messages
562
Helped
67
Reputation
134
Reaction score
53
Trophy points
1,308
Location
USA
Activity points
3,048
I have a C model of 128 bit AES (advanced encryption standard)

I want to make this C model as a reference model that is i want to pass input to this C model and the verilog model and compare the output of the two models to see if they have the same value or not.

The problem is that i dont know how to pass 128 bit values from verilog to C model.

Has anyone done some thing similar?

Please educate me and others

Thanks
 

The easiest thing is to use the SystemVerilog DPI and import your C model.

SV code
Code:
module top;
   typedef byte a128_t[16];
   import "DPI-C" function void my_c_function (input a128_t f1,
					       output a128_t f2);
   a128_t a1,a2;
   initial begin
      void'(std::randomize(a1));
      $display("%p",a1);
      my_c_function(a1,a2);
      $display("%p",a2);
   end
endmodule
C code
Code:
#include "dpi.h"
void my_c_function (
		    const char* f1,
		    char* f2) {
  int i;
  //your algorithm goes here
  for(i=0;i<16;i++) *f2++ = (*f1++)+1;
}
Command line
Code:
 qverilog  DPI.sv -dpiheader dpi.h dpi.c
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top