2001-03-11 01:29:38 +01:00
|
|
|
#ifndef __compile_H
|
|
|
|
|
#define __compile_H
|
|
|
|
|
/*
|
2008-01-04 08:44:14 +01:00
|
|
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
2001-03-11 01:29:38 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include <stdio.h>
|
2007-07-12 06:38:56 +02:00
|
|
|
# include <fstream>
|
2008-01-01 18:45:02 +01:00
|
|
|
# include <vector>
|
2001-03-20 07:16:23 +01:00
|
|
|
# include "parse_misc.h"
|
2001-03-18 05:35:18 +01:00
|
|
|
# include "vpi_user.h"
|
2004-12-11 03:31:25 +01:00
|
|
|
# include "vvp_net.h"
|
2001-03-11 01:29:38 +01:00
|
|
|
|
2005-07-15 01:34:18 +02:00
|
|
|
using namespace std;
|
|
|
|
|
|
2008-01-01 18:45:02 +01:00
|
|
|
/*
|
|
|
|
|
* The file names are kept in this vector. Entry 0 is "N/A" and 1 is
|
|
|
|
|
* for interactive commands.
|
|
|
|
|
*/
|
|
|
|
|
extern vector<const char*> file_names;
|
|
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
/*
|
|
|
|
|
* The functions described here are the compile time support
|
|
|
|
|
* functions. Various bits of the compile process are taken care of
|
|
|
|
|
* here. What is called when is mostly controlled by the parser.
|
|
|
|
|
*
|
|
|
|
|
* Before compilation takes place, the compile_init function must be
|
|
|
|
|
* called once to set stuff up.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
extern void compile_init(void);
|
|
|
|
|
|
|
|
|
|
extern void compile_cleanup(void);
|
|
|
|
|
|
2002-07-15 02:21:42 +02:00
|
|
|
extern bool verbose_flag;
|
|
|
|
|
|
2007-07-12 06:38:56 +02:00
|
|
|
/*
|
|
|
|
|
* If this file opened, then write debug information to this
|
|
|
|
|
* file. This is used for debugging the VVP runtime itself.
|
|
|
|
|
*/
|
|
|
|
|
extern ofstream debug_file;
|
|
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
/*
|
|
|
|
|
* Connect a list of symbols to a contiguous set of ipoints.
|
|
|
|
|
* Constants C<?> are handled by setting the ival of the ipoint.
|
|
|
|
|
*/
|
2004-12-11 03:31:25 +01:00
|
|
|
extern void inputs_connect(vvp_net_t*fdx, unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void input_connect(vvp_net_t*fdx, unsigned port, char*label);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2005-04-01 08:02:45 +02:00
|
|
|
/*
|
|
|
|
|
* This function is an expansion of the inputs_connect function. It
|
|
|
|
|
* uses the inputs_connect function, but it creates vvp_wide_fun_t
|
|
|
|
|
* nodes to handle arbitrary width nodes, and connects those nodes to
|
|
|
|
|
* the vvp_wide_fun_core object passed in.
|
|
|
|
|
*/
|
|
|
|
|
extern void wide_inputs_connect(vvp_wide_fun_core*core,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
|
2005-10-12 19:23:15 +02:00
|
|
|
extern vvp_net_t* vvp_net_lookup(const char*label);
|
2008-03-20 21:07:18 +01:00
|
|
|
extern vpiHandle vvp_lookup_handle(const char*label);
|
2005-04-01 08:02:45 +02:00
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
/*
|
|
|
|
|
* Add a functor to the symbol table
|
|
|
|
|
*/
|
2004-12-11 03:31:25 +01:00
|
|
|
extern void define_functor_symbol(const char*label, vvp_net_t*ipt);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2005-10-12 19:23:15 +02:00
|
|
|
|
2001-03-22 23:38:13 +01:00
|
|
|
/*
|
|
|
|
|
* This is a count of errors encountered during compilation. If this
|
|
|
|
|
* is non-zero, then simulation is not recommended.
|
|
|
|
|
*/
|
|
|
|
|
extern unsigned compile_errors;
|
|
|
|
|
|
2001-03-23 03:40:22 +01:00
|
|
|
extern const char* module_path;
|
|
|
|
|
extern void compile_load_vpi_module(char*name);
|
|
|
|
|
|
2001-07-01 01:03:16 +02:00
|
|
|
extern void compile_vpi_time_precision(long pre);
|
|
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
/*
|
|
|
|
|
* This function is called by the parser to compile a functor
|
|
|
|
|
* statement. The strings passed in are allocated by the lexor, but
|
|
|
|
|
* this function will free them. (Or save them permanently.) This
|
|
|
|
|
* includes the argv array and the strings it references.
|
|
|
|
|
*
|
2003-02-10 00:33:26 +01:00
|
|
|
* The argc and argv are a list of char* that are the port parameters
|
2001-03-11 01:29:38 +01:00
|
|
|
* of the functor. The compile should match those port parameters up
|
|
|
|
|
* to existing functors to manage the linking.
|
|
|
|
|
*/
|
2005-06-17 05:46:52 +02:00
|
|
|
extern void compile_functor(char*label, char*type, unsigned width,
|
2006-01-02 06:32:06 +01:00
|
|
|
unsigned ostr0, unsigned ostr1,
|
2001-03-20 07:16:23 +01:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
|
2001-05-09 04:53:25 +02:00
|
|
|
/*
|
|
|
|
|
* This is called by the parser to make a resolver. This is a special
|
2004-12-30 00:45:13 +01:00
|
|
|
* kind of functor; a strength aware functor. It has up to 4 inputs
|
|
|
|
|
* that are blended to make a resolved output. The type string selects
|
|
|
|
|
* a resolution algorithm.
|
2001-05-09 04:53:25 +02:00
|
|
|
*/
|
|
|
|
|
extern void compile_resolver(char*label, char*type,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
|
2004-12-30 00:45:13 +01:00
|
|
|
extern void compile_concat(char*label, unsigned w0, unsigned w1,
|
|
|
|
|
unsigned w2, unsigned w3,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
|
2007-07-25 03:24:24 +02:00
|
|
|
/*
|
|
|
|
|
* Arrange for the system task/function call to have its compiletf
|
|
|
|
|
* function called.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_compiletf(struct __vpiSysTaskCall*);
|
|
|
|
|
|
2006-01-02 06:32:06 +01:00
|
|
|
/*
|
|
|
|
|
* Compile delay nodes of various form.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_delay(char*label, vvp_delay_t*del, struct symb_s input);
|
|
|
|
|
extern void compile_delay(char*label, unsigned argc, struct symb_s*argv);
|
|
|
|
|
|
2004-12-30 00:45:13 +01:00
|
|
|
/*
|
|
|
|
|
* This is called by the parser to create a part select node.
|
|
|
|
|
* See the PART SELECT STATEMENT section in the README.txt
|
|
|
|
|
*/
|
2004-12-11 03:31:25 +01:00
|
|
|
extern void compile_part_select(char*label, char*src,
|
|
|
|
|
unsigned base, unsigned wid);
|
2005-01-09 21:11:15 +01:00
|
|
|
extern void compile_part_select_pv(char*label, char*src,
|
|
|
|
|
unsigned base, unsigned wid,
|
|
|
|
|
unsigned vec_wid);
|
2005-05-09 01:40:14 +02:00
|
|
|
extern void compile_part_select_var(char*label, char*src,
|
|
|
|
|
char*var, unsigned wid);
|
2004-12-11 03:31:25 +01:00
|
|
|
|
2001-06-05 05:05:41 +02:00
|
|
|
/*
|
2001-06-15 06:07:57 +02:00
|
|
|
* This is called by the parser to make the various arithmetic and
|
|
|
|
|
* comparison functors.
|
2001-06-05 05:05:41 +02:00
|
|
|
*/
|
2008-02-09 02:32:57 +01:00
|
|
|
extern void compile_arith_pow(char*label, long width, bool signed_flag,
|
2008-02-06 04:09:30 +01:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2008-05-07 05:37:00 +02:00
|
|
|
extern void compile_arith_abs(char*label,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2008-06-18 02:07:19 +02:00
|
|
|
extern void compile_arith_cast_real(char*label,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2004-06-30 04:15:57 +02:00
|
|
|
extern void compile_arith_div(char*label, long width, bool signed_flag,
|
2001-10-16 04:47:37 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2002-01-03 05:19:01 +01:00
|
|
|
extern void compile_arith_mod(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-06-17 01:45:05 +02:00
|
|
|
extern void compile_arith_mult(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-06-05 05:05:41 +02:00
|
|
|
extern void compile_arith_sum(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-06-07 05:09:03 +02:00
|
|
|
extern void compile_arith_sub(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2005-01-22 02:06:20 +01:00
|
|
|
extern void compile_cmp_eeq(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2005-03-09 06:52:03 +01:00
|
|
|
extern void compile_cmp_nee(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2004-06-16 18:33:25 +02:00
|
|
|
extern void compile_cmp_eq(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void compile_cmp_ne(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2003-04-11 07:15:38 +02:00
|
|
|
extern void compile_cmp_ge(char*label, long width, bool signed_flag,
|
2001-06-15 06:07:57 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2003-04-11 07:15:38 +02:00
|
|
|
extern void compile_cmp_gt(char*label, long width, bool signed_flag,
|
2001-06-15 06:07:57 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2005-07-06 06:29:25 +02:00
|
|
|
|
2008-01-04 08:44:14 +01:00
|
|
|
extern void compile_arith_mult_r(char*label, unsigned argc,
|
|
|
|
|
struct symb_s*argv);
|
2008-01-31 02:53:06 +01:00
|
|
|
extern void compile_arith_pow_r(char*label, unsigned argc, struct symb_s*argv);
|
2005-07-06 06:29:25 +02:00
|
|
|
extern void compile_arith_div_r(char*label, unsigned argc, struct symb_s*argv);
|
2008-01-31 03:32:27 +01:00
|
|
|
extern void compile_arith_mod_r(char*label, unsigned argc, struct symb_s*argv);
|
2008-01-04 08:44:14 +01:00
|
|
|
extern void compile_arith_sum_r(char*label, unsigned argc, struct symb_s*argv);
|
2005-07-06 06:29:25 +02:00
|
|
|
extern void compile_arith_sub_r(char*label, unsigned argc, struct symb_s*argv);
|
2008-01-15 19:54:04 +01:00
|
|
|
extern void compile_cmp_eq_r(char*label, unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void compile_cmp_ne_r(char*label, unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void compile_cmp_ge_r(char*label, unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void compile_cmp_gt_r(char*label, unsigned argc, struct symb_s*argv);
|
2005-07-06 06:29:25 +02:00
|
|
|
|
2005-04-24 22:07:25 +02:00
|
|
|
extern void compile_dff(char*label,
|
|
|
|
|
struct symb_s arg_d,
|
|
|
|
|
struct symb_s arg_c,
|
|
|
|
|
struct symb_s arg_e,
|
|
|
|
|
struct symb_s arg_a);
|
2006-09-23 06:57:19 +02:00
|
|
|
|
2007-10-31 04:14:40 +01:00
|
|
|
class __vpiModPath;
|
2007-11-03 03:59:08 +01:00
|
|
|
extern __vpiModPath* compile_modpath(char*label,
|
|
|
|
|
struct symb_s drv,
|
|
|
|
|
struct symb_s dest);
|
2007-10-31 04:14:40 +01:00
|
|
|
extern void compile_modpath_src(__vpiModPath*dst,
|
2007-03-02 07:13:22 +01:00
|
|
|
char edge,
|
2006-09-23 06:57:19 +02:00
|
|
|
struct symb_s input,
|
2007-11-06 04:58:20 +01:00
|
|
|
struct numbv_s d,
|
|
|
|
|
int condit_input, /* match with '0' */
|
2008-04-29 04:00:29 +02:00
|
|
|
struct symb_s path_term_input,
|
|
|
|
|
bool ifnone);
|
2007-10-31 04:14:40 +01:00
|
|
|
extern void compile_modpath_src(__vpiModPath*dst,
|
2007-03-02 07:13:22 +01:00
|
|
|
char edge,
|
2007-03-01 07:19:38 +01:00
|
|
|
struct symb_s input,
|
|
|
|
|
struct numbv_s d,
|
2007-11-06 04:58:20 +01:00
|
|
|
struct symb_s condit_input,
|
|
|
|
|
struct symb_s path_term_input);
|
2006-09-23 06:57:19 +02:00
|
|
|
|
2005-02-03 05:55:13 +01:00
|
|
|
extern void compile_reduce_and(char*label, struct symb_s arg);
|
|
|
|
|
extern void compile_reduce_or(char*label, struct symb_s arg);
|
|
|
|
|
extern void compile_reduce_xor(char*label, struct symb_s arg);
|
|
|
|
|
extern void compile_reduce_nand(char*label, struct symb_s arg);
|
|
|
|
|
extern void compile_reduce_nor(char*label, struct symb_s arg);
|
|
|
|
|
extern void compile_reduce_xnor(char*label, struct symb_s arg);
|
|
|
|
|
|
2005-05-24 03:43:27 +02:00
|
|
|
extern void compile_extend_signed(char*label, long width, struct symb_s arg);
|
|
|
|
|
|
2006-06-18 06:15:50 +02:00
|
|
|
extern void compile_sfunc(char*label, char*name, char*format_string,
|
2008-04-30 03:58:25 +02:00
|
|
|
long file_idx, long lineno,
|
2006-06-18 06:15:50 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2005-02-07 23:42:42 +01:00
|
|
|
extern void compile_repeat(char*label, long width, long repeat,
|
|
|
|
|
struct symb_s arg);
|
|
|
|
|
|
2001-07-06 06:46:44 +02:00
|
|
|
extern void compile_shiftl(char*label, long width,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2006-07-30 04:51:35 +02:00
|
|
|
extern void compile_shiftr(char*label, long width, bool signed_flag,
|
2001-07-07 04:57:33 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-06-05 05:05:41 +02:00
|
|
|
|
2007-09-28 20:21:08 +02:00
|
|
|
extern void compile_timescale(long units, long precision);
|
2001-05-09 04:53:25 +02:00
|
|
|
|
2001-03-21 06:13:03 +01:00
|
|
|
extern void compile_vpi_symbol(const char*label, vpiHandle obj);
|
2001-07-11 06:43:57 +02:00
|
|
|
extern void compile_vpi_lookup(vpiHandle *objref, char*label);
|
2001-03-21 06:13:03 +01:00
|
|
|
|
2008-05-06 04:46:30 +02:00
|
|
|
extern void compile_param_string(char*label, char*name, char*value,
|
|
|
|
|
long file_idx, long lineno);
|
2006-03-18 23:51:10 +01:00
|
|
|
extern void compile_param_logic(char*label, char*name, char*value,
|
2008-05-06 04:46:30 +02:00
|
|
|
bool signed_flag,
|
|
|
|
|
long file_idx, long lineno);
|
|
|
|
|
extern void compile_param_real(char*label, char*name, char*value,
|
|
|
|
|
long file_idx, long lineno);
|
2003-03-11 00:37:07 +01:00
|
|
|
|
2008-05-17 04:06:12 +02:00
|
|
|
/*
|
|
|
|
|
* The resolv_list_s is the base class for a symbol resolve
|
|
|
|
|
* action. Some function creates an instance of a resolv_list_s object
|
|
|
|
|
* that contains the data pertinent to that resolution request, and
|
|
|
|
|
* executes it with the resolv_submit function. If the operation can
|
|
|
|
|
* complete, then the resolv_submit deletes the object. Otherwise, it
|
|
|
|
|
* pushes it onto the resolv_list for later processing.
|
|
|
|
|
*
|
|
|
|
|
* Derived classes implement the resolve function to perform the
|
|
|
|
|
* actual binding or resolution that the instance requires. If the
|
|
|
|
|
* function succeeds, the resolve method returns true and the object
|
|
|
|
|
* can be deleted any time.
|
|
|
|
|
*
|
|
|
|
|
* The mes parameter of the resolve method tells the resolver that
|
|
|
|
|
* this call is its last chance. If it cannot complete the operation,
|
|
|
|
|
* it must print an error message and return false.
|
|
|
|
|
*/
|
|
|
|
|
class resolv_list_s {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit resolv_list_s(char*lab) : label_(lab) { }
|
|
|
|
|
virtual ~resolv_list_s();
|
|
|
|
|
virtual bool resolve(bool mes = false) = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
const char*label() const { return label_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend void ::resolv_submit(struct resolv_list_s*cur);
|
|
|
|
|
friend void ::compile_cleanup(void);
|
|
|
|
|
|
|
|
|
|
char*label_;
|
|
|
|
|
struct resolv_list_s*next;
|
|
|
|
|
};
|
|
|
|
|
|
2002-03-18 01:19:34 +01:00
|
|
|
/*
|
|
|
|
|
* This function schedules a lookup of an indexed label. The ref
|
2005-03-18 03:56:03 +01:00
|
|
|
* points to the vvp_net_t that receives the result. The result may
|
2002-03-18 01:19:34 +01:00
|
|
|
* be assigned later, if the symbol is defined later in the source
|
|
|
|
|
* file, so the memory that ref points to must persist.
|
2005-03-18 03:56:03 +01:00
|
|
|
*
|
|
|
|
|
* The text for the label will be deleted by this function, or the
|
|
|
|
|
* cleanup that completes the binding.
|
2002-03-18 01:19:34 +01:00
|
|
|
*/
|
2005-03-18 03:56:03 +01:00
|
|
|
extern void functor_ref_lookup(vvp_net_t**ref, char*lab);
|
2002-03-18 01:19:34 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This function schedules a lookup of the labeled instruction. The
|
|
|
|
|
* code points to a code structure that points to the instruction
|
|
|
|
|
* field that receives the result, and the label is the name to
|
|
|
|
|
* lookup. The lookup will free the label text when it is done.
|
|
|
|
|
*/
|
|
|
|
|
extern void code_label_lookup(struct vvp_code_s *code, char *label);
|
|
|
|
|
|
2004-10-04 03:10:51 +02:00
|
|
|
/*
|
2001-04-25 06:35:05 +02:00
|
|
|
* The `compile_udp_def' function creates a UDP. The `table' is a
|
2004-10-04 03:10:51 +02:00
|
|
|
* NULL terminated array of char*, as assembled by `compile_udp_table'.
|
|
|
|
|
* `compile_udp_table' is called with `table'==NULL to create a new
|
2001-04-25 06:35:05 +02:00
|
|
|
* table, or with an existing table to append to.
|
|
|
|
|
*
|
2004-10-04 03:10:51 +02:00
|
|
|
* `compile_udp_functor' creates a mode-3 functor referring to the
|
|
|
|
|
* labeled UDP.
|
2001-04-24 04:23:58 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
extern void compile_udp_def(int sequ, char*label, char *name,
|
|
|
|
|
unsigned nin, unsigned init, char **table);
|
|
|
|
|
|
|
|
|
|
extern void compile_udp_functor(char*label, char*type,
|
2005-04-03 07:45:51 +02:00
|
|
|
vvp_delay_t*delay,
|
2001-04-24 04:23:58 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
|
|
|
|
|
extern char **compile_udp_table(char **table, char *row);
|
|
|
|
|
|
2001-05-01 03:09:39 +02:00
|
|
|
/*
|
|
|
|
|
* Memory Instances, Ports, and Initialization
|
|
|
|
|
*/
|
|
|
|
|
|
2007-04-10 03:26:15 +02:00
|
|
|
extern void compile_var_array(char*label, char*name,
|
|
|
|
|
int last, int first,
|
|
|
|
|
int msb, int lsb, char signed_flag);
|
|
|
|
|
extern void compile_real_array(char*label, char*name,
|
|
|
|
|
int last, int first,
|
|
|
|
|
int msb, int lsb);
|
|
|
|
|
extern void compile_net_array(char*label, char*name,
|
|
|
|
|
int last, int first);
|
2007-06-25 03:17:37 +02:00
|
|
|
extern void compile_array_alias(char*label, char*name, char*src);
|
2007-01-16 06:44:14 +01:00
|
|
|
|
2008-05-16 19:38:32 +02:00
|
|
|
/* Index is a net. */
|
2007-01-16 06:44:14 +01:00
|
|
|
extern void compile_array_port(char*label, char*name, char*addr);
|
2008-05-16 19:38:32 +02:00
|
|
|
/* Index is a constant address */
|
|
|
|
|
extern void compile_array_port(char*label, char*name, long addr);
|
2007-01-16 06:44:14 +01:00
|
|
|
|
2008-06-01 06:45:55 +02:00
|
|
|
extern void compile_array_cleanup(void);
|
|
|
|
|
|
2002-03-18 01:19:34 +01:00
|
|
|
/*
|
|
|
|
|
* Compile the .ufunc statement.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_ufunc(char*label, char*code, unsigned wid,
|
|
|
|
|
unsigned argc, struct symb_s*argv,
|
|
|
|
|
unsigned portc, struct symb_s*portv,
|
2005-03-18 03:56:03 +01:00
|
|
|
struct symb_s retv);
|
2001-05-01 03:09:39 +02:00
|
|
|
|
2001-03-26 06:00:39 +02:00
|
|
|
/*
|
|
|
|
|
* The compile_event function takes the parts of the event statement
|
|
|
|
|
* and makes the various objects needed to simulate it. This includes
|
|
|
|
|
* the functor that receives the signals and the event_t that holds
|
|
|
|
|
* the threads.
|
|
|
|
|
*/
|
|
|
|
|
extern void compile_event(char*label, char*type,
|
2006-11-22 07:10:05 +01:00
|
|
|
unsigned argc, struct symb_s*argv,
|
|
|
|
|
bool debug_flag);
|
2002-05-18 04:34:11 +02:00
|
|
|
extern void compile_named_event(char*label, char*type);
|
2001-03-26 06:00:39 +02:00
|
|
|
|
2003-01-26 00:48:05 +01:00
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
/*
|
|
|
|
|
* A code statement is a label, an opcode and up to 3 operands. There
|
|
|
|
|
* are a few lexical types that the parser recognizes of the operands,
|
|
|
|
|
* given by the ltype_e enumeration. The compile_code function takes
|
|
|
|
|
* the label, mnemonic and parsed operands and writes a properly
|
|
|
|
|
* formed instruction into the code space. The label is set into the
|
|
|
|
|
* symbol table with the address of the instruction.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define OPERAND_MAX 3
|
2001-03-20 07:16:23 +01:00
|
|
|
enum ltype_e { L_NUMB, L_SYMB };
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
struct comp_operands_s {
|
|
|
|
|
unsigned argc;
|
|
|
|
|
struct {
|
|
|
|
|
enum ltype_e ltype;
|
|
|
|
|
union {
|
|
|
|
|
unsigned long numb;
|
2001-03-20 07:16:23 +01:00
|
|
|
struct symb_s symb;
|
2001-03-11 01:29:38 +01:00
|
|
|
};
|
|
|
|
|
} argv[OPERAND_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct comp_operands_s*comp_operands_t;
|
|
|
|
|
|
|
|
|
|
extern void compile_code(char*label, char*mnem, comp_operands_t opa);
|
2001-04-18 06:21:23 +02:00
|
|
|
extern void compile_disable(char*label, struct symb_s symb);
|
2001-05-20 02:46:12 +02:00
|
|
|
|
2001-03-18 05:35:18 +01:00
|
|
|
extern void compile_vpi_call(char*label, char*name,
|
2008-04-30 03:58:25 +02:00
|
|
|
long file_idx, long lineno,
|
2001-03-18 05:35:18 +01:00
|
|
|
unsigned argc, vpiHandle*argv);
|
2001-05-20 02:46:12 +02:00
|
|
|
|
2003-01-27 01:14:37 +01:00
|
|
|
/* Compile a function call. The vbit and vwid encode the return
|
|
|
|
|
type. If the vwid >0, the return type is a vector. If the vwid is
|
|
|
|
|
<0, the return type is -vpiRealConst or some other constant subtype
|
|
|
|
|
code that represents the function type. */
|
2001-05-20 02:46:12 +02:00
|
|
|
extern void compile_vpi_func_call(char*label, char*name,
|
2003-01-27 01:14:37 +01:00
|
|
|
unsigned vbit, int vwid,
|
2008-04-30 03:58:25 +02:00
|
|
|
long file_idx, long lineno,
|
2001-05-20 02:46:12 +02:00
|
|
|
unsigned argc, vpiHandle*argv);
|
|
|
|
|
|
2001-04-18 06:21:23 +02:00
|
|
|
extern void compile_fork(char*label, struct symb_s targ_s,
|
|
|
|
|
struct symb_s scope_s);
|
2001-04-01 08:40:44 +02:00
|
|
|
extern void compile_codelabel(char*label);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
2001-03-18 01:37:55 +01:00
|
|
|
/*
|
|
|
|
|
* The parser uses these functions to compile .scope statements.
|
|
|
|
|
* The implementations of these live in the vpi_scope.cc file.
|
|
|
|
|
*/
|
2008-04-30 03:58:25 +02:00
|
|
|
extern void compile_scope_decl(char*typ, char*lab, char*nam,const char*tnam,
|
|
|
|
|
char*par, long file_idx, long lineno,
|
|
|
|
|
long def_file_idx, long def_lineno);
|
2001-03-18 01:37:55 +01:00
|
|
|
extern void compile_scope_recall(char*sym);
|
|
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
/*
|
|
|
|
|
* The parser uses this function to declare a thread. The start_sym is
|
|
|
|
|
* the start instruction, and must already be defined.
|
|
|
|
|
*/
|
2003-09-04 22:26:30 +02:00
|
|
|
extern void compile_thread(char*start_sym, char*flag);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
|
|
|
|
/*
|
2001-03-20 07:16:23 +01:00
|
|
|
* This function is called to create a var vector with the given name.
|
2001-03-11 01:29:38 +01:00
|
|
|
*/
|
2001-04-05 03:34:26 +02:00
|
|
|
extern void compile_variable(char*label, char*name,
|
2007-12-28 01:56:32 +01:00
|
|
|
int msb, int lsb, char signed_flag,
|
|
|
|
|
bool local_flag);
|
2007-01-16 06:44:14 +01:00
|
|
|
extern void compile_var_real(char*label, char*name,
|
|
|
|
|
int msb, int lsb);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
2001-04-05 03:34:26 +02:00
|
|
|
extern void compile_net(char*label, char*name,
|
|
|
|
|
int msb, int lsb, bool signed_flag,
|
2007-12-28 01:56:32 +01:00
|
|
|
bool net8_flag, bool local_flag,
|
2001-03-25 01:35:35 +01:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2005-07-06 06:29:25 +02:00
|
|
|
extern void compile_net_real(char*label, char*name,
|
2007-12-28 02:34:12 +01:00
|
|
|
int msb, int lsb, bool local_flag,
|
2005-07-06 06:29:25 +02:00
|
|
|
unsigned argc, struct symb_s*argv);
|
2001-03-25 01:35:35 +01:00
|
|
|
|
2007-01-16 06:44:14 +01:00
|
|
|
extern void compile_netw(char*label, char*array_symbol,
|
2007-04-10 03:26:15 +02:00
|
|
|
unsigned long array_addr,
|
2007-01-16 06:44:14 +01:00
|
|
|
int msb, int lsb, bool signed_flag,
|
|
|
|
|
bool net8_flag,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void compile_netw_real(char*label, char*array_symbol,
|
|
|
|
|
int msb, int lsb,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
|
2005-10-12 19:23:15 +02:00
|
|
|
extern void compile_alias(char*label, char*name,
|
|
|
|
|
int msb, int lsb, bool signed_flag,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
|
|
|
|
extern void compile_alias_real(char*label, char*name,
|
|
|
|
|
int msb, int lsb,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2008-03-20 21:07:18 +01:00
|
|
|
extern void compile_aliasw(char*label, char*array_symbol,
|
|
|
|
|
unsigned long array_addr, int msb, int lsb,
|
|
|
|
|
unsigned argc, struct symb_s*argv);
|
2005-10-12 19:23:15 +02:00
|
|
|
|
2008-06-01 06:45:55 +02:00
|
|
|
extern void compile_island(char*label, char*type);
|
|
|
|
|
extern void compile_island_port(char*label, char*island, char*src);
|
|
|
|
|
extern void compile_island_import(char*label, char*island, char*src);
|
|
|
|
|
extern void compile_island_export(char*label, char*island);
|
|
|
|
|
|
|
|
|
|
extern void compile_island_tranif(int sense, char*island,
|
|
|
|
|
char*ba, char*bb, char*src);
|
2008-06-03 20:16:25 +02:00
|
|
|
extern void compile_island_tranvp(char*island, char*ba, char*bb,
|
|
|
|
|
unsigned width, unsigned part, unsigned off);
|
2008-06-01 06:45:55 +02:00
|
|
|
|
|
|
|
|
extern void compile_island_cleanup(void);
|
|
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
#endif
|