VHDL FLI. FLI Definition FLI routines are C programming language functions that provide procedural access to information within the HDL simulator.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

C Language.
COE 405 VHDL Basics Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum & Minerals Dr. Aiman H. El-Maleh Computer Engineering.
1 Introduction to VHDL (Continued) EE19D. 2 Basic elements of a VHDL Model Package Declaration ENTITY (interface description) ARCHITECTURE (functionality)
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
Programming Languages and Paradigms
Programming Languages and Paradigms The C Programming Language.
CS7100 (Prasad)L16-7AG1 Attribute Grammars Attribute Grammar is a Framework for specifying semantics and enables Modular specification.
Chapter 7 Process Environment Chien-Chung Shen CIS, UD
Written by: Dr. JJ Shepherd
Chapter 3: Beginning Problem Solving Concepts for the Computer Programming Computer Programming Skills /1436 Department of Computer Science.
CS 330 Programming Languages 10 / 16 / 2008 Instructor: Michael Eckmann.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
SubprogramsSubprograms. SubprogramsSubprograms ä Similar to subprograms found in other languages ä Allow repeatedly used code to be referenced multiple.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Topics of Lecture Structural Model Procedures Functions Overloading.
1) More on parameter passing: a) Parameter association b) Default parameters c) Procedures as parameters 2) Modules: Ada packages, C modules, C header.
Managing design complexity Partition of designs Typical design process using VHDL Test Bed A VHDL example.
(1) Programming Mechanics © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
IAY 0600 Digitaalsüsteemide disain Event-Driven Simulation Alexander Sudnitson Tallinn University of Technology.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Chapter Nine: Subprograms Lesson 09. What are they  Modularized code  Might return a value  Functions  Or not  Procedures  Subroutines  In object.
MIPS coding. SPIM Some links can be found such as:
Introduction to VHDL Arab Academy for Science, Technology & Maritime Transport Computer Engineering Department Magdy Saeb, Ph.D.
Porting Implementation of Packet Utilization Standard from ADA to JAVA Annelie Hultman (TEC-EME) Donata Pedrazzani (TEC-EMS) ESA/ESTEC 2004 JPUS de-briefing.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
10/17/2015DSD, USIT, GGSIPU1 Data Types Each data object has a type associated with it. The type defines the set of values that the object can have and.
Active-HDL Interfaces Building VHPI Applications C Compilation Course 9.
Manifold Lab 2 Introduction Basic Concepts First Examples.
Language Concepts Ver 1.1, Copyright 1997 TS, Inc. VHDL L a n g u a g e C o n c e p t s Page 1.
2-Jun-16EE5141 Chapter 3 ä The concept of the signal ä Process concurrency ä Delta time ä Concurrent and sequential statements ä Process activation by.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
VHDL Very High Speed Integrated Circuit Hardware Description Language Shiraz University of shiraz spring 2011.
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
CPS4200 Unix Systems Programming Chapter 2. Programs, Processes and Threads A program is a prepared sequence of instructions to accomplish a defined task.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
Chapter 7 Templates. Objectives Introduction Function Templates Class Templates Standard Template Library.
Topics AliasesSubprograms Generics & Configurations.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
VHDL Basics. VHDL BASICS 2 OUTLINE –Component model –Code model –Entity –Architecture –Identifiers and objects –Operations for relations VHDL ET062G &
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
1 Introduction to VHDL Part 2 Fall We will use Std_logic And, Or have same precedence See slide 8 of part 1.
16/11/2006DSD,USIT,GGSIPU1 Packages The primary purpose of a package is to encapsulate elements that can be shared (globally) among two or more design.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
Chapter 4 Generic Vector Class. Agenda A systemic problem with Vector of Object – Several approaches at a solution – Generic structures Converting classes.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
IAY 0600 Digital Systems Design Event-Driven Simulation VHDL Discussion Alexander Sudnitson Tallinn University of Technology.
Verification Presentation to SystemVerilog Basic Committee Peter Flake Nov 15, 2002.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
Pointers A pointer type variable holds the address of a data object or a function. A pointer can refer to an object of any one data type; it cannot refer.
Names, Scope, and Bindings Programming Languages and Paradigms.
EGRE 6311 LHO 04 - Subprograms, Packages, and Libraries EGRE 631 1/26/09.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
Procedures Procedures are very important for writing reusable and maintainable code in assembly and high-level languages. How are they implemented? Application.
Functions Students should understand the concept and basic mechanics of the function call/return pattern from CS 1114/2114, but some will not. A function.
Introduction To VHDL 홍 원 의.
A bit of C programming Lecture 3 Uli Raich.
Functions, Part 2 of 2 Topics Functions That Return a Value
Chapter 3: Using Methods, Classes, and Objects
CSC 253 Lecture 8.
CSC 253 Lecture 8.
Functions, Part 2 of 3 Topics Functions That Return a Value
VHDL Discussion Subprograms
VHDL Discussion Subprograms
Programming Languages and Paradigms
The Three Attributes of an Identifier
Functions, Part 2 of 3 Topics Functions That Return a Value
Presentation transcript:

VHDL FLI

FLI Definition FLI routines are C programming language functions that provide procedural access to information within the HDL simulator

Using the VHDL FLI A user-written application can use these functions to: – traverse the hierarchy of an HDL design – get information about and set the values of VHDL objects in the design – get information about a simulation – control (to some extent) a simulation run

Important Concepts -Elaboration When the simulator starts, it first goes through an elaboration phase during which the entire design is loaded and connected and initial values are set. During his phase all foreign shared libraries are loaded and the initialization functions of all foreign architectures are executed.

Foreign Architecture A foreign architecture is a design unit that is instantiated in a design but that does not (generally) contain any VHDL code Instead it is a link to a C model that can communicate to the rest of the design through the ports of the foreign architecture a C model creates processes and reads and drives signal values behaving in the same manner as VHDL code but with the advantage of the power of C

Foreign Subprogram A foreign subprogram is a VHDL function or procedure that is implemented in C as opposed to VHDL A foreign subprogram: – reads its in and inout parameters – performs some operation(s) – writes its inout and out parameters

Using the VHDL FLI with Foreign Architectures To use the foreign language interface with C models, you first define Attribute ATTRIBUTE foreign OF arch_name : ARCHITECTURE IS “app_init app.so[; parameter]”; app_init — The name of the initialization function for this architecture. This part is required. app.so — The path to the shared object file to load. This part is required. parameter — A string that is passed to the initialization function. This part is preceded by a semicolon and is optional

Location of Shared Object Files The simulator searches for object files in the following order – $MGC_WD/ or./ (If MGC_WD is not set, then it will use “.”) – – within $LD_LIBRARY_PATH ($SHLIB_PATH on HP only) – $MGC_HOME/lib/ – $MODEL_TECH/ – $MODEL_TECH/../

The C Initialization Function allocates memory to hold variables for the instance registers a callback function to free the memory when the simulator is restarted saves the handles to the signals in the port list creates drivers on the ports that will be driven creates one or more processes (a C function that can be called when a signal changes) sensitizes each process to a list of signals

declaration of initialization func app_init( mtiRegionIdT region, char *param, mtiInterfaceListT *generics, mtiInterfaceListT *ports ) The header file mti.h externs all of the FLI functions and types that can be used by an FLI application.

Declaring a Foreign Subprogram in VHDL To call a foreign C subprogram: – write a VHDL subprogram declaration that has the equivalent VHDL parameters and return type – use the FOREIGN attribute to specify which C function and module to load – write a subprogram body for the subprogram, but it will never be called

Declaring a Foreign Subprogram in VHDL procedure in_params( vhdl_integer : IN integer; vhdl_enum : IN severity_level; vhdl_real : IN real; vhdl_array : IN string); attribute FOREIGN of in_params : procedure is “in_params app.dll”; procedure in_params( vhdl_integer : IN integer; vhdl_enum : IN severity_level; vhdl_real : IN real; vhdl_array : IN string) is begin report “ERROR: foreign subprogram in_params not called”; end;

Matching VHDL Parameters with C Parameters

Arrays Array and record SIGNAL parameters are passed as an mtiVariableIdT type Any array or record subelements of these composite variables are also of type mtiVariableIdT The values of all scalar subelements are of type mtiSignalIdT Arrays are not NULL-terminated. The length of an array can be determined by calling mti_TickLength() on the array’s type. To access the signal IDs, use mti_GetVarSubelements() at each composite level For each subelement that is of a scalar type, use mti_GetVarValueIndirect() to get the signal ID of the scalar

Enumeration Enumeration object values are equated to the position number of the corresponding identifier or character literal in the VHDL type declaration -- C interface values TYPE std_ulogic IS('U',-- 0 'X',-- 1 '0',-- 2 '1',-- 3 'Z',-- 4 'W',-- 5 'L',-- 6 'H',-- 7 '-' – );

Matching VHDL Return Types with C Return Types

C Example #include #include "mti.h“ char *severity[] = {"NOTE", "WARNING", "ERROR", "FAILURE"}; static char *get_string(mtiVariableIdT id); void in_params ( int vhdl_integer, /* IN integer */ int vhdl_enum, /* IN severity_level */ double *vhdl_real, /* IN real */ mtiVariableIdT vhdl_array /* IN string */ ) { printf("Integer = %d\n", vhdl_integer); printf("Enum = %s\n", severity[vhdl_enum]); printf("Real = %g\n", *vhdl_real); printf("String = %s\n", get_string(vhdl_array)); }

C Example void out_params ( int *vhdl_integer, /* OUT integer */ char *vhdl_enum, /* OUT severity_level */ double *vhdl_real, /* OUT real */ mtiVariableIdT vhdl_array /* OUT string */ ) { char *val; int i, len, first; *vhdl_integer += 1; *vhdl_enum += 1; if (*vhdl_enum > 3){ *vhdl_enum = 0; } *vhdl_real += 1.01;

C Example /* rotate the array */ val = mti_GetArrayVarValue(vhdl_array, NULL); len = mti_TickLength(mti_GetVarType(vhdl_array)); first = val[0]; for (i = 0; i < len - 1; i++){ val[i] = val[i+1]; } val[len - 1] = first; }

C Example /* Convert a VHDL String array into a NULL terminated string */ static char *get_string(mtiVariableIdT id) { static char buf[1000]; mtiTypeIdT type; int len; mti_GetArrayVarValue(id, buf); type = mti_GetVarType(id); len = mti_TickLength(type); buf[len] = 0; return buf; }

Package (pkg) Example package pkg is procedure in_params( vhdl_integer : IN integer; vhdl_enum : IN severity_level; vhdl_real : IN real; vhdl_array : IN string); attribute foreign of in_params : procedure is "in_params test.dll"; procedure out_params( vhdl_integer : OUT integer; vhdl_enum : OUT severity_level; vhdl_real : OUT real; vhdl_array : OUT string); attribute foreign of out_params : procedure is "out_params test.dll"; end;

Package (pkg) Example package body pkg is procedure in_params( vhdl_integer : IN integer; vhdl_enum : IN severity_level; vhdl_real : IN real; vhdl_array : IN string) is begin report "ERROR: foreign subprogram in_params not called"; end; procedure out_params( vhdl_integer : OUT integer; vhdl_enum : OUT severity_level; vhdl_real : OUT real; vhdl_array : OUT string) is begin report "ERROR: foreign subprogram out_params not called"; end;

Entity (test) Example entity test is end test; use work.pkg.all; architecture only of test is begin process variable int : integer := 0; variable enum : severity_level := note; variable r : real := 0.0; variable s : string(1 to 5) := "abcde"; begin for i in 1 to 10 loop in_params(int, enum, r, s); out_params(int, enum, r, s); end loop; wait; end process; end;