SC-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 1 SV to C, C to SV Function Call Proposal Joao Geada, John Stickley.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

Advanced Piloting Cruise Plot.
1
Feichter_DPG-SYKL03_Bild-01. Feichter_DPG-SYKL03_Bild-02.
© 2008 Pearson Addison Wesley. All rights reserved Chapter Seven Costs.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Copyright © 2011, Elsevier Inc. All rights reserved. Chapter 6 Author: Julia Richards and R. Scott Hawley.
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
UNITED NATIONS Shipment Details Report – January 2006.
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Properties of Real Numbers CommutativeAssociativeDistributive Identity + × Inverse + ×
Exit a Customer Chapter 8. Exit a Customer 8-2 Objectives Perform exit summary process consisting of the following steps: Review service records Close.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Year 6 mental test 5 second questions
Year 6 mental test 10 second questions
1 Discreteness and the Welfare Cost of Labour Supply Tax Distortions Keshab Bhattarai University of Hull and John Whalley Universities of Warwick and Western.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
Break Time Remaining 10:00.
PP Test Review Sections 6-1 to 6-6
ABC Technology Project
EU market situation for eggs and poultry Management Committee 20 October 2011.
EU Market Situation for Eggs and Poultry Management Committee 21 June 2012.
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
2 |SharePoint Saturday New York City
Green Eggs and Ham.
BEEF & VEAL MARKET SITUATION "Single CMO" Management Committee 18 April 2013.
VOORBLAD.
15. Oktober Oktober Oktober 2012.
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
© 2012 National Heart Foundation of Australia. Slide 2.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
SC-CC Committee 11/18/02svcc-proposal-2.ppt - johnS 1 SV to C, C to SV Function Call Proposal Joao Geada, John Stickley.
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
Januar MDMDFSSMDMDFSSS
Analyzing Genes and Genomes
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Essential Cell Biology
Clock will move after 1 minute
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Immunobiology: The Immune System in Health & Disease Sixth Edition
1 Chapter 13 Nuclear Magnetic Resonance Spectroscopy.
Energy Generation in Mitochondria and Chlorplasts
Murach’s OS/390 and z/OS JCLChapter 16, Slide 1 © 2002, Mike Murach & Associates, Inc.
User Defined Functions Lesson 1 CS1313 Fall User Defined Functions 1 Outline 1.User Defined Functions 1 Outline 2.Standard Library Not Enough #1.
Chapter 9: Using Classes and Objects. Understanding Class Concepts Types of classes – Classes that are only application programs with a Main() method.
SC-CC Committee 11/7/02svcc-proposal.ppt - johnS 1 SV to C, C to SV Function Call Proposal Joao Geada, John Stickley.
Presentation transcript:

SC-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 1 SV to C, C to SV Function Call Proposal Joao Geada, John Stickley

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 2 Contents SV-to-C Function Calls –Declaration Syntax –Simple Function Binding –Context Specific Function Binding C-to-SV Function Calls –Declaration Syntax –Context Specific Function Binding Packet Router Example –SystemC Testbench Root –SystemC EthPortWrapper Module –SystemVerilog EthPort Module

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 3 SV-to-C Declaration Syntax extern_decl ::= extern [attribute {, attribute}] return _ type fname ( [arg {,arg} ); attribute ::= pure | queueable Examples: // Declare an SV callable, pure, C function extern pure integer MyCFunc( input integer portID ); // Declare an pure SV callable, void C function extern pure void MyCFunc( input integer portID, output integer mappedID ); // Declare an SV callable, queueable, void C function extern queueable void MyCFunc( input integer portID );

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 4 SV-to-C Simple Function Binding For free functions, i.e. no contexts involved, no special binding API call required. Simply define the function on the C side … int MyCFunc( int portID ){ return map(portID); } … and call it from the SV side. my_clock ) begin if( my_reset ) begin // Blah, blah, blah; end else begin if( state == READY ) begin mappedID <= MyCFunc( portID ); // Call to C. state <= WAITING; end // Blah, blah, blah; end

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 5 SV-to-C Context Specific Function Binding For context specific functions use tf_isetworkarea(), tf_igetworkarea(), tf_getinstance(), tf_mipname() in current PLI interface to establish context to be associated with each instance specific SV call. The equivalent can probably also be done using VPI functions as well (exercise left to reader !). Define a function on the C side that calls tf_getinstance() and tf_igetworkarea() to fetch a context pointer previously established as described above: void MyCFunc(int portID, int *mappedID ){ MyCModel *me = (MyCModel *)tf_igetworkarea( tf_getinstance() ); *mappedID = me->map(portID); } During initialization, bind the model context to the SV caller instance: void MyCModel::Init( ){ tf_isetworkarea( this, tf_mipname(“top.u1”) ); }

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 6 C-to-SV Declaration Syntax export_decl ::= export [attribute {, attribute}] [scopename{::scopename}::]fname [“cname”]; scopename ::= modulename | interfacename attribute ::= pure | queueable Example: // Declare a C callable, context specific, SV function export MySvModule::MySvFunc “MySvModule_MySvFunc”; module MySvModule(... );... function MySvFunc; input integer portID; output integer mappedID; mappedID = map[portID]; endfunction... endmodule

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 7 C-to-SV Context Specific Function Binding For context specific functions use tf_mipname() to establish context to be associated with each instance specific SV callee: The equivalent can probably also be done using VPI functions as well (exercise left to reader !). During initialization, establish a context handle to the SV callee instance: void MyCModel::Init( ){ dSvContext = tf_mipname( “top.u1” ); } Now at run-time call the SV function from C passing the context handle as the first argument: void MyCModel::RunTest( int portID ){ MySvModule_MySvFunc( dSvContext, portID, &mappedID );... }

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 8 Packet Router Example

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 9 Packet Router Example: SystemC Testbench Root 1 SC_MODULE( TestBench ){ 2 private: 3 EthPortWrapper *context1; 4 EthPortWrapper *context2; 5 EthPortWrapper *context3; 6 EthPortWrapper *context4; 7 int numOutputs; 8 9 void testThread(); // Main test driver thread. 10 public: 11 SC_CTOR( System ) : numOutputs(0) { SC_THREAD( testThread ); 14 sensitive << UTick; // Construct 4 instances of reusable EthPortWrapper 17 // class for each of 4 different HDL module instances. 18 context1 = new EthPortWrapper( "c1" ); context1->Bind( "top.u1", this ); 19 context2 = new EthPortWrapper( "c2" ); context2->Bind( "top.u2", this ); 20 context3 = new EthPortWrapper( "c3" ); context3->Bind( "top.u3", this ); 21 context4 = new EthPortWrapper( "c4" ); context4->Bind( "top.u4", this ); 22 } 23 void BumpNumOutputs(){ numOutputs++; } 24 }; void TestBench::testThread(){ 27 // Now run a test that sends random packets to each input port. 28 context1->PutPacket( generateRandomPayload() ); 29 context2->PutPacket( generateRandomPayload() ); 30 context3->PutPacket( generateRandomPayload() ); 31 context4->PutPacket( generateRandomPayload() ); while( numOutputs < 4 ) // Wait until all 4 packets have been received. 34 sc_wait(); 35 }

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 10 Packet Router Example: SystemC EthPortWrapper Module 1 SC_MODULE( EthPortWrapper ){ 2 private: 3 void *dSvContext; 4 sc_module *myParent; 5 6 public: 7 SC_CTOR( EthPortWrapper ) : dSvContext(0), myParent(0) { } 8 void Bind( const char *hdlPath, sc_module *parent ); 9 void PutPacket( vec32 *packet ); friend void HandleOutputPacket( int portID, vec32 *payload ); 12 }; void EthPortWrapper::Bind( const char *hdlPath, sc_module *parent ){ 15 myParent = parent; 16 dSvContext = tf_mipname( hdlPath ); 17 tf_isetworkarea( this, tf_mipname(hdlPath) ); 18 } void EthPortWrapper::PutPacket( sv_handle *packet ){ 21 EthPort_PutPacket( dSvContext, packet ); // Call SV function. 22 } friend void HandleOutputPacket( int portID, sv_handle *payload ){ 25 EthPortWrapper *me = (EthPortWrapper *)tf_igetworkarea( tf_getinstance() ); me->myParent->BumpNumOutputs(); // Let top level know another packet received printf( "Received output on port on port %\n", portID ); 30 me->DumpPayload( payload ); 31 }

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 11 Packet Router Example: SystemVerilog EthPort Module 1 module EthPort( 2 MiiOutData, MiiInData, 3 MiiOutEnable, MiiInEnable, 4 MiiOutError, MiiInError, 5 clk, reset ); 6 7 input [7:0] MiiOutData; output [7:0] mii_data; 8 reg [7:0] mii_data; 9 input MiiOutEnable; output mii_enable; 10 reg mii_enable; 11 input MiiOutError; output mii_error; 12 reg mii_error; 13 input clk, reset; extern HandleOutputPacket( 16 input integer portID, input reg [1439:0] *payload ); export PutPacket “EthPort_PutPacket”; reg packetReceivedFlag; 21 reg [1499:0] packetData; function PutPacket; 24 input reg [1499:0] packet; packetData = packet; 27 packetReceivedFlag = 1; 28 endfunction

SV-CC Committee 11/26/02svcc-proposal-5.ppt - johnS 12 Packet Router Example: SystemVerilog EthPort Module (cont’d) 1 clk ) begin // input packet FSM 2 if( reset ) begin 3 // Blah, blah, blah... 4 end 5 else begin 6 if( instate == READY ) begin 7 if( packetReceived ) 8 state <= PROCESS_INPUT_PACKET; 9 end 10 else if( instate == PROCESS_INPUT_PACKET ) begin 11 // Start processing input packet byte by byte end 13 end 14 end clk ) begin // output packet FSM 17 if( reset ) begin 18 // Blah, blah, blah end 20 else begin 21 if( outstate == READY ) begin 22 if( MiiOutEnable ) 23 state <= PROCESS_OUTPUT_PACKET; 24 end 25 else if( outstate == PROCESS_OUTPUT_PACKET ) begin 26 // Start assembling output packet byte by byte // Make call to C side to handle it. 29 HandleOutputPacket( myPortID, outPacketVector ); 30 end 31 end 32 end 33 endmodule