/* $Id: synthesize_type.h,v 1.15 2002/03/18 20:26:38 sbeyer Exp $ $Log: synthesize_type.h,v $ Revision 1.15 2002/03/18 20:26:38 sbeyer * a few optimizations Revision 1.14 2001/06/13 09:52:05 sbeyer * added width computation for register type Revision 1.13 2001/06/12 14:56:45 sbeyer * added reasonable error message for record type overflow * increased supported record size from 200 to 1000 fields Revision 1.12 2001/06/06 13:18:16 sbeyer * started making ram usage safe (no ram on conditional assignments, etc...) Revision 1.11 2001/05/31 13:46:33 dirkl - reordering of record-elements implemented Revision 1.10 2001/05/30 18:07:58 sbeyer * added array and ram support in types * BETA support for function lookup table Revision 1.9 2001/04/20 13:45:35 dirkl - added support for records in conds Revision 1.8 2001/03/14 11:15:13 sbeyer added reasonable error messages for too many/few actuals/parameters (instead of simple core dump) Revision 1.7 2001/02/05 11:14:46 sbeyer added register support Revision 1.6 2001/01/26 16:17:40 sbeyer fixed type_array::is_member - bug Revision 1.5 2001/01/22 15:09:31 sbeyer added LAMBDA support, improved record support, small bugfixes Revision 1.4 2001/01/21 17:25:29 sbeyer improved record support considerably; added 'LET x=const' simplification Revision 1.3 2001/01/18 16:09:32 sbeyer too many changes to mention; a 16-bit-carry-chain-adder can now be synthesized Revision 1.2 2001/01/16 17:55:31 sbeyer first step in record support Revision 1.1 2001/01/15 16:09:22 sbeyer split synthesize_core into synthesize_core and synthesize_type */ #ifndef synthesize_type_h #define synthesize_type_h #include "shared_lists.h" struct type_array { int num; string name[MAX_RECORD_MEMBER_COUNT]; int type[MAX_RECORD_MEMBER_COUNT]; int bitbreite[MAX_RECORD_MEMBER_COUNT]; int lower_bound[MAX_RECORD_MEMBER_COUNT]; int upper_bound[MAX_RECORD_MEMBER_COUNT]; int ram_address_width[MAX_RECORD_MEMBER_COUNT]; type_array() { num=0; } type_array(const type_array &tarray); void empty() { num=0; } bool add_member(const string &_name, int _type, int _bitbreite =1, int _lower_bound=0, int _upper_bound=0, int _ram_address_width=0); bool add_member(const string &_name, const type_array &tarray); void make_ram(const type_array &tarray, int _address_width); bool make_array(const type_array &tarray, int _lower_bound, int _upper_bound); bool contains_ram() const; bool is_member(const string &_name, int &index) const; bool is_member(const string &_name, type_array &tarray, list &strlist) const; bool is_member(const string &_name, type_array &tarray) const; bool is_member(const type_array &tarray, int &start, int &end) const; int bit_count() const; bool is_simple() const; bool operator ==(const type_array &tarray) const; bool simple_equality(const type_array &tarray) const; // comparres elements of array one by one // changes order of record-elements acording to order in tarray bool type_array::change_order(const type_array &tarray,list &ret_string); bool operator !=(const type_array &tarray) const { return !(*this==tarray); } friend ostream& operator <<(ostream& ostr, const type_array& tarray); }; struct binding { string name; int value; binding(){ } binding(const binding &_bind) { name=_bind.name; value=_bind.value; } binding(const string &_name, int _value) { name=_name; value=_value; } }; bool is_bound(const list &bindings, const string &name, int &value); // simplify_tree copies the tree 'root', applies bindings and // returns the resulting simplified tree knoten *simplify_tree(const knoten *const root, const list &bindings); void add_actual(const knoten *const root, const actuals_array &act, list &bindings, const string &name, int index); void add_parameter(const knoten *const root, const params_array ¶ms, list &bindings, list ¶meters, const string &name, bool error_if_not_bound=false); // looks up the function call in the list of defined functions // (root node is 'expr' from "expr -> expr funarg") void get_defined_function(const knoten *const root, defined_function &function); void get_type(const knoten *const root, type_array &tarray); void get_type_with_bindings(const knoten *const root, const list &bindings, type_array &tarray); // exits with an error if any actual of the function is not bound void get_function_call_bindings(const knoten *const root, const defined_function &function, list &bindings, list ¶meters); // exits with an error if any actual or parameter of the type is not bound void get_type_bindings(const knoten *const root, const defined_type &type, list &bindings); #endif // synthesize_type_h