
/*
 *  contains the type declarations for generic information
 *
 * $Header: c:\\cygwin\\cvsroot/Vert03/vertlib/generic.h,v 1.1.1.1 2003/11/04 23:34:57 mjames
 * Exp $
 *
 * $Log: generic.h,v $
 * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
 * Imported into local repositrory
 *
 * Revision 1.9  2002/09/27 22:38:07  MJAMES
 * Introduced automatic creation of partition generics
 *
 * Revision 1.8  2002/09/09 10:29:21  mjames
 * Removed set generic range and replaced it with a set generic value command
 * that takes both integers and ranges.
 *
 * Revision 1.7  2002/01/15 12:34:54  mjames
 * ALtered comments on the enumeration for generic classes
 *
 * Revision 1.6  2001/10/31 22:20:07  mjames
 * Tidying up problematical comments caused by CVS
 * 'intelligent' comment guessing
 *
 * Revision 1.5  2001/10/22 10:59:56  mjames
 * Added IS_ATTRIBUTE : a generic attribute used for controlling VERTICAL.
 * Can have either string or expression here.
 *
 * Revision 1.4  2001/06/06 12:10:21  mjames
 * Move from HPUX
 *
 * Revision 1.3  2001/04/06 22:47:02  mjames
 * Added doc2, the creator of documentation to Vertical scripts uses PERL
 * Also correcting generic behaviour and the printing of Verilog.
 *
 * Revision 1.2  2001/01/02 07:53:53  mjames
 * Made changes to allow for interface with TCL/Tk
 *
 * Revision 1.1.1.1  2000/10/19 21:58:38  mjames
 * Mike put it here
 *
 * Revision 1.25  2000/10/04  10:37:14  10:37:14  mjames (Mike James)
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
 *
 * Revision 1.25  2000/10/04  10:37:14  10:37:14  mjames (Mike James)
 * Part of Release PSAVAT01
 *
 * Revision 1.24  2000/10/02  11:04:15  11:04:15  mjames (Mike James)
 * new_vhdl
 *
 * Revision 1.23  2000/09/27  14:42:30  14:42:30  mjames (Mike James)
 * Part of Release Sep_27_ST_2000
 *
 * Revision 1.22  2000/09/21  10:15:59  10:15:59  mjames (Mike James)
 * Part of Release Sep21Alpha
 *
 * Revision 1.21  2000/08/25  09:57:23  09:57:23  mjames (Mike James)
 * Part of Release Aug25_alpha
 *
 * Revision 1.20  2000/08/16  08:57:40  08:57:40  mjames (Mike James)
 * Part of Release CD01_Aug2000
 *
 * Revision 1.19  2000/08/14  14:45:19  14:45:19  mjames (Mike James)
 * Part of Release Aug_14_2000
 *
 * Revision 1.18  2000/08/11  08:30:39  08:30:39  mjames (Mike James)
 * Part of Release Aug_11_2000
 *
 * Revision 1.17  2000/08/09  10:31:57  10:31:57  mjames (Mike James)
 * Part of Release Aug__9_2000
 *
 * Revision 1.16  2000/05/31  11:43:10  11:43:10  mjames (Mike James)
 * Part of Release May_31_2000
 *
 * Revision 1.15  2000/05/08  17:01:46  17:01:46  mjames (Mike James)
 * Part of Release May__8_2000
 *
 * Revision 1.14  2000/05/08  16:59:39  16:59:39  mjames (Mike James)
 * Part of Release May__8_2000
 *
 * Revision 1.13  2000/05/08  16:57:16  16:57:16  mjames (Mike James)
 * Part of Release May__8_2000
 *
 * Revision 1.12  2000/03/08  16:19:09  16:19:09  mjames (Mike James)
 * New version including PC
 *
 * Revision 1.9  2000/01/20  15:58:58  15:58:58  mjames (Mike James)
 * Part of Release R22
 *
 * Revision 1.8  99/12/22  11:15:38  11:15:38  mjames (Mike James)
 * Part of Release Dec_22_1999
 *
 * Revision 1.7  99/11/23  13:52:06  13:52:06  mjames (Mike James)
 * Addded syntax to support special generics for Certify support
 *
 * Revision 1.6  99/06/18  09:25:18  09:25:18  mjames (Mike James)
 * Added new VHDL printing of generic information
 *
 * Revision 1.5  99/05/04  09:51:40  09:51:40  mjames (Mike James)
 * Amended generic lookup rules
 *
 * Revision 1.3  98/08/12  14:21:28  14:21:28  mjames (Mike James)
 * Added correct header files
 *
 * Revision 1.2  98/07/14  13:24:48  13:24:48  mjames (Mike James)
 * fixed errors in lookup of generic variables -
 * now works better
 *
 * Revision 1.1  98/02/11  11:26:21  11:26:21  mjames (Mike James)
 * Initial revision
 *  */
#pragma once 
#include <stdio.h>

 
#if !defined _GENERIC
#define _GENERIC

#if !defined _EXPRESSION
#error Need to include expression.h before generic.h
#endif

/* this structure is used to provide a list of all expressions that make
   reference to a particular pointer */
typedef struct expr_ref
{
        struct expr_ref *expr_ref;
        expression_t *expr;
} expr_ref_t;

typedef enum
{
        NO_VALUE = 0,
        IS_STRING,
        IS_INTEGER,
        IS_DECLARATION_DIRECTIVE,
        IS_INSTANCE_DIRECTIVE,
        IS_ENV_VAL,   /* environment value : string */
        IS_ATTRIBUTE, /* component attribute : integer */
        IS_BOOLEAN

} generic_type_t;

/* this is used to define whether a generic
   attached to an entity is
   a default or defined for that entity */
typedef enum
{
        DEFAULT = 0,
        DEFINED
} generic_define_class_t;

/* need to define actual data types as otherwise there will be problems
 * definition eg. of integer range type which is assigned a fixed value.
 * e.g. signal s : integer range (0 to 31) := 23;. This is not supported
 * yet but it needs to be there....
 * As of December 2000 there are only a few defined data types */

typedef struct generic_info
{
        struct generic_info *next; /* neighbour in generic values */
        char *name;
        char *typename;       /* this section needs expansion into a types hierarchy */
        expression_t *expr;   /* this is its current value as opposed to the type */
        expr_ref_t *expr_ref; /* this is a pointer to the list of expressions that
                                 refer to this generic */
        generic_type_t g_type;
        generic_define_class_t g_class;
        unsigned int valid : 1;
        unsigned int is_component_generic : 1; /* is this generic part of a component template
                                                */
} generic_info_t;

extern generic_info_t *global_generics;    /* a list of user set generics */
extern generic_info_t *partition_generics; /* a list of generics in the partition */

extern generic_type_t
get_generic_value (generic_info_t **list, char *name, generic_info_t *value);

extern generic_info_t *get_generic_ref (generic_info_t **list, char *name);

extern int convert_num (char *string, int *value);

/* this function makes a copy of the info passed to it */
extern generic_info_t *set_generic_value (generic_info_t **list, generic_info_t *info);

/* this function will delete a generic expression whose
   name matches that given, if found on the list */
extern int del_generic_value (generic_info_t **list, generic_info_t *info);

extern void list_generic_values (FILE *f, generic_info_t **list, int indent);

extern void list_VHDL_generic_map_values (FILE *f, generic_info_t **list);

extern void list_VHDL_generic_values (FILE *f, generic_info_t **list);

extern void list_VHDL_constants (FILE *f, generic_info_t **list);

struct socket; /* from database.h */
extern void copy_declaration_generics (struct socket *to, struct socket *from);

extern void clear_partition_generics (generic_info_t **list);

extern void elaborate_all (void);

#endif
