2014-07-23 22:39:29 +02:00
|
|
|
#ifndef IVL_vvp_priv_H
|
|
|
|
|
#define IVL_vvp_priv_H
|
2001-03-19 02:20:46 +01:00
|
|
|
/*
|
2014-07-23 22:39:29 +02:00
|
|
|
* Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
|
2001-03-19 02:20:46 +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
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2001-03-19 02:20:46 +01:00
|
|
|
*/
|
|
|
|
|
|
2004-01-20 22:00:47 +01:00
|
|
|
# include "vvp_config.h"
|
2001-03-19 02:20:46 +01:00
|
|
|
# include "ivl_target.h"
|
|
|
|
|
# include <stdio.h>
|
|
|
|
|
|
2014-12-03 01:54:32 +01:00
|
|
|
extern int debug_draw;
|
|
|
|
|
|
2001-03-19 02:20:46 +01:00
|
|
|
/*
|
|
|
|
|
* The target_design entry opens the output file that receives the
|
2007-02-26 20:49:48 +01:00
|
|
|
* compiled design, and sets the vvp_out to the descriptor.
|
2001-03-19 02:20:46 +01:00
|
|
|
*/
|
|
|
|
|
extern FILE* vvp_out;
|
|
|
|
|
|
2008-04-16 06:51:03 +02:00
|
|
|
/*
|
|
|
|
|
* Keep a count of errors that would render the output unusable.
|
|
|
|
|
*/
|
|
|
|
|
extern int vvp_errors;
|
|
|
|
|
|
2011-11-29 00:29:53 +01:00
|
|
|
extern unsigned transient_id;
|
|
|
|
|
|
2011-02-28 04:20:16 +01:00
|
|
|
/*
|
|
|
|
|
* Set to non-zero when the user wants to display file and line number
|
|
|
|
|
* information for procedural statements.
|
|
|
|
|
*/
|
|
|
|
|
extern unsigned show_file_line;
|
|
|
|
|
|
2007-12-16 07:05:56 +01:00
|
|
|
struct vector_info {
|
|
|
|
|
unsigned base;
|
|
|
|
|
unsigned wid;
|
|
|
|
|
};
|
|
|
|
|
|
2008-05-28 02:51:28 +02:00
|
|
|
/*
|
|
|
|
|
* Convenient constants...
|
|
|
|
|
*/
|
|
|
|
|
/* Width limit for typical immediate arguments. */
|
|
|
|
|
# define IMM_WID 32
|
|
|
|
|
|
2010-07-07 23:33:10 +02:00
|
|
|
/* The number of words available in a thread. */
|
|
|
|
|
# define WORD_COUNT 16
|
|
|
|
|
|
2001-06-18 05:10:34 +02:00
|
|
|
/*
|
|
|
|
|
* Mangle all non-symbol characters in an identifier, quotes in names
|
|
|
|
|
*/
|
|
|
|
|
extern const char *vvp_mangle_id(const char *);
|
|
|
|
|
extern const char *vvp_mangle_name(const char *);
|
|
|
|
|
|
2008-06-02 06:08:31 +02:00
|
|
|
extern char* draw_Cr_to_string(double value);
|
|
|
|
|
|
2002-08-04 00:30:48 +02:00
|
|
|
/*
|
|
|
|
|
* This generates a string from a signal that uniquely identifies
|
|
|
|
|
* that signal with letters that can be used in a label.
|
2005-10-12 19:26:17 +02:00
|
|
|
*
|
|
|
|
|
* NOTE: vvp_signal_label should be removed. All it does is a %p of
|
|
|
|
|
* the pointer, and return a pointer to a static. The code that wants
|
|
|
|
|
* to reference a signal needs to use the format V_%p, so the presence
|
|
|
|
|
* of this function is just plain inconsistent.
|
2002-08-04 00:30:48 +02:00
|
|
|
*/
|
|
|
|
|
extern const char* vvp_signal_label(ivl_signal_t sig);
|
|
|
|
|
|
2005-09-01 06:11:37 +02:00
|
|
|
extern unsigned width_of_nexus(ivl_nexus_t nex);
|
|
|
|
|
extern ivl_variable_type_t data_type_of_nexus(ivl_nexus_t nex);
|
|
|
|
|
|
2013-10-12 03:05:45 +02:00
|
|
|
/*
|
|
|
|
|
* Calculate the width (in bits) of a packed type.
|
|
|
|
|
*/
|
|
|
|
|
extern unsigned width_of_packed_type(ivl_type_t net);
|
|
|
|
|
|
2008-06-02 06:08:31 +02:00
|
|
|
extern int can_elide_bufz(ivl_net_logic_t net, ivl_nexus_ptr_t nptr);
|
|
|
|
|
|
2001-03-19 02:20:46 +01:00
|
|
|
/*
|
|
|
|
|
* This function draws a process (initial or always) into the output
|
2001-03-27 05:31:06 +02:00
|
|
|
* file. It normally returns 0, but returns !0 of there is some sort
|
|
|
|
|
* of error.
|
2001-03-19 02:20:46 +01:00
|
|
|
*/
|
|
|
|
|
extern int draw_process(ivl_process_t net, void*x);
|
|
|
|
|
|
2001-04-02 04:28:12 +02:00
|
|
|
extern int draw_task_definition(ivl_scope_t scope);
|
2001-04-06 04:28:02 +02:00
|
|
|
extern int draw_func_definition(ivl_scope_t scope);
|
2001-04-02 04:28:12 +02:00
|
|
|
|
2001-03-21 02:49:43 +01:00
|
|
|
extern int draw_scope(ivl_scope_t scope, ivl_scope_t parent);
|
|
|
|
|
|
2002-07-08 06:04:07 +02:00
|
|
|
extern void draw_lpm_mux(ivl_lpm_t net);
|
2014-07-14 03:09:13 +02:00
|
|
|
extern void draw_lpm_substitute(ivl_lpm_t net);
|
2002-07-08 06:04:07 +02:00
|
|
|
|
2014-01-05 18:15:30 +01:00
|
|
|
extern void draw_ufunc_vec4(ivl_expr_t expr);
|
2012-10-23 02:20:43 +02:00
|
|
|
extern void draw_ufunc_real(ivl_expr_t expr);
|
2013-10-20 00:11:13 +02:00
|
|
|
extern void draw_ufunc_string(ivl_expr_t expr);
|
2013-04-21 01:27:51 +02:00
|
|
|
extern void draw_ufunc_object(ivl_expr_t expr);
|
2014-12-03 01:54:32 +01:00
|
|
|
|
2014-01-06 17:35:23 +01:00
|
|
|
extern char* process_octal_codes(const char*txt, unsigned wid);
|
|
|
|
|
|
2007-11-01 05:45:34 +01:00
|
|
|
/*
|
|
|
|
|
* modpath.c symbols.
|
|
|
|
|
*
|
|
|
|
|
* draw_modpath arranges for a .modpath record to be written out.
|
|
|
|
|
*
|
|
|
|
|
* cleanup_modpath() cleans up any pending .modpath records that may
|
2008-06-12 19:04:29 +02:00
|
|
|
* have been scheduled by draw_modpath() but not yet written.
|
2007-11-01 05:45:34 +01:00
|
|
|
*
|
|
|
|
|
* Note: draw_modpath drive_label must be malloc'ed by the
|
|
|
|
|
* caller. This function will free the string sometime in the future.
|
|
|
|
|
*/
|
|
|
|
|
extern void draw_modpath(ivl_signal_t path_sig, char*drive_label);
|
|
|
|
|
extern void cleanup_modpath(void);
|
|
|
|
|
|
2003-02-28 21:21:13 +01:00
|
|
|
/*
|
|
|
|
|
* This function draws the execution of a vpi_call statement, along
|
|
|
|
|
* with the tricky handling of arguments. If this is called with a
|
|
|
|
|
* statement handle, it will generate a %vpi_call
|
|
|
|
|
* instruction. Otherwise, it will generate a %vpi_func instruction.
|
|
|
|
|
*/
|
2003-03-15 05:45:18 +01:00
|
|
|
extern void draw_vpi_task_call(ivl_statement_t net);
|
|
|
|
|
|
2014-01-04 23:06:58 +01:00
|
|
|
extern void draw_vpi_func_call(ivl_expr_t expr);
|
2012-10-23 02:20:43 +02:00
|
|
|
extern void draw_vpi_rfunc_call(ivl_expr_t expr);
|
2015-12-09 14:24:19 +01:00
|
|
|
extern void draw_vpi_sfunc_call(ivl_expr_t expr);
|
2003-02-28 21:21:13 +01:00
|
|
|
|
2012-12-10 02:59:16 +01:00
|
|
|
extern void draw_class_in_scope(ivl_type_t classtype);
|
|
|
|
|
|
2010-11-29 20:23:00 +01:00
|
|
|
/*
|
|
|
|
|
* Enumeration draw routine.
|
|
|
|
|
*/
|
|
|
|
|
void draw_enumeration_in_scope(ivl_enumtype_t enumtype);
|
|
|
|
|
|
2008-05-28 05:06:58 +02:00
|
|
|
/*
|
|
|
|
|
* Switches (tran)
|
|
|
|
|
*/
|
|
|
|
|
extern void draw_switch_in_scope(ivl_switch_t sw);
|
|
|
|
|
|
2008-06-02 06:08:31 +02:00
|
|
|
/* Draw_net_input and friends uses this. */
|
|
|
|
|
struct vvp_nexus_data {
|
|
|
|
|
/* draw_net_input uses this */
|
|
|
|
|
const char*net_input;
|
2009-10-12 01:51:06 +02:00
|
|
|
/* draw_isnald_net_input uses these */
|
|
|
|
|
const char*island_input;
|
|
|
|
|
ivl_island_t island;
|
|
|
|
|
/* */
|
2008-06-02 06:08:31 +02:00
|
|
|
unsigned drivers_count;
|
|
|
|
|
int flags;
|
|
|
|
|
/* draw_net_in_scope uses these to identify the controlling word. */
|
|
|
|
|
ivl_signal_t net;
|
|
|
|
|
unsigned net_word;
|
|
|
|
|
};
|
|
|
|
|
#define VVP_NEXUS_DATA_STR 0x0001
|
|
|
|
|
|
|
|
|
|
|
2001-03-27 08:27:40 +02:00
|
|
|
/*
|
|
|
|
|
* Given a nexus, draw a string that represents the functor output
|
|
|
|
|
* that feeds the nexus. This function can be used to get the input to
|
|
|
|
|
* a functor, event, or even a %load in cases where I have the
|
2005-08-06 19:58:16 +02:00
|
|
|
* ivl_nexus_t object. The draw_net_input function will get the string
|
|
|
|
|
* cached in the nexus, if there is one, or will generate a string and
|
|
|
|
|
* cache it.
|
2001-03-27 08:27:40 +02:00
|
|
|
*/
|
2001-11-01 05:26:57 +01:00
|
|
|
extern const char* draw_net_input(ivl_nexus_t nex);
|
2014-07-08 21:12:54 +02:00
|
|
|
void EOC_cleanup_drivers(void);
|
2001-03-22 06:06:21 +01:00
|
|
|
|
2008-06-02 06:08:31 +02:00
|
|
|
/*
|
2009-10-12 01:51:06 +02:00
|
|
|
* This is different from draw_net_input in that it is intended to be
|
|
|
|
|
* used within the network of an island. This finds and prepares the
|
|
|
|
|
* link for a nexus within the scope of the given island, instead of
|
|
|
|
|
* the net as a whole.
|
2008-06-02 06:08:31 +02:00
|
|
|
*/
|
2009-10-12 01:51:06 +02:00
|
|
|
extern const char* draw_island_net_input(ivl_island_t island, ivl_nexus_t nex);
|
2008-06-02 06:08:31 +02:00
|
|
|
|
2005-10-12 19:26:17 +02:00
|
|
|
/*
|
|
|
|
|
* This function is different from draw_net_input in that it will
|
|
|
|
|
* return a reference to a net as its first choice. This reference
|
|
|
|
|
* will follow the net value, even if the net is assigned or
|
|
|
|
|
* forced. The draw_net_input above will return a reference to the
|
|
|
|
|
* *input* to the net and so will not follow direct assignments to
|
|
|
|
|
* the net. This function will not return references to local signals,
|
|
|
|
|
* and will in those cases resort to the net input, or a non-local
|
|
|
|
|
* signal if one exists for the nexus.
|
|
|
|
|
*/
|
|
|
|
|
extern const char*draw_input_from_net(ivl_nexus_t nex);
|
|
|
|
|
|
2006-02-02 03:43:57 +01:00
|
|
|
/*
|
|
|
|
|
* This evaluates an expression and leaves the result in the numbered
|
|
|
|
|
* integer index register. It also will set bit-4 to 1 if the value is
|
|
|
|
|
* not fully defined (i.e. contains x or z).
|
|
|
|
|
*/
|
|
|
|
|
extern void draw_eval_expr_into_integer(ivl_expr_t expr, unsigned ix);
|
|
|
|
|
|
2014-11-20 03:32:19 +01:00
|
|
|
/*
|
|
|
|
|
* This evaluates an expression as a condition flag and leaves the
|
|
|
|
|
* result in a flag that is returned. This result may be used as an
|
|
|
|
|
* operand for conditional jump instructions.
|
|
|
|
|
*/
|
|
|
|
|
extern int draw_eval_condition(ivl_expr_t expr);
|
|
|
|
|
|
2016-01-25 03:36:26 +01:00
|
|
|
/*
|
|
|
|
|
* Return true if the signal is the return value of a function.
|
|
|
|
|
*/
|
|
|
|
|
extern int signal_is_return_value(ivl_signal_t sig);
|
2002-09-27 18:33:34 +02:00
|
|
|
|
2002-06-02 20:57:17 +02:00
|
|
|
extern int number_is_unknown(ivl_expr_t ex);
|
2008-06-13 22:32:06 +02:00
|
|
|
extern int number_is_immediate(ivl_expr_t ex, unsigned lim_wid, int negative_is_ok);
|
2008-06-13 06:41:11 +02:00
|
|
|
extern long get_number_immediate(ivl_expr_t ex);
|
2009-02-24 22:50:18 +01:00
|
|
|
extern uint64_t get_number_immediate64(ivl_expr_t ex);
|
2002-06-02 20:57:17 +02:00
|
|
|
|
2013-12-27 16:04:42 +01:00
|
|
|
/*
|
|
|
|
|
* draw_eval_vec4 evaluates vec4 expressions. The result of the
|
|
|
|
|
* evaluation is the vec4 result in the top of the vec4 expression stack.
|
|
|
|
|
*/
|
2014-10-24 18:32:32 +02:00
|
|
|
extern void draw_eval_vec4(ivl_expr_t ex);
|
2014-02-08 02:50:13 +01:00
|
|
|
extern void resize_vec4_wid(ivl_expr_t expr, unsigned wid);
|
2013-12-27 16:04:42 +01:00
|
|
|
|
2003-01-26 22:15:58 +01:00
|
|
|
/*
|
2012-10-23 02:20:43 +02:00
|
|
|
* draw_eval_real evaluates real value expressions. The result of the
|
|
|
|
|
* evaluation is the real result in the top of the real expression stack.
|
2003-01-26 22:15:58 +01:00
|
|
|
*/
|
2012-10-23 02:20:43 +02:00
|
|
|
extern void draw_eval_real(ivl_expr_t ex);
|
2003-01-26 22:15:58 +01:00
|
|
|
|
2005-09-14 04:53:13 +02:00
|
|
|
/*
|
|
|
|
|
* draw_eval_bool64 evaluates a bool expression. The return code from
|
|
|
|
|
* the function is the index of the word register that contains the
|
2008-01-29 21:19:59 +01:00
|
|
|
* result. The word is allocated with allocate_word(), so the caller
|
2005-09-14 04:53:13 +02:00
|
|
|
* must arrange for it to be released with clr_word(). The width must
|
|
|
|
|
* be such that it fits in a 64bit word.
|
|
|
|
|
*/
|
|
|
|
|
extern int draw_eval_bool64(ivl_expr_t ex);
|
|
|
|
|
|
2012-06-18 03:43:25 +02:00
|
|
|
/*
|
2015-06-02 19:40:24 +02:00
|
|
|
* The draw_eval_string function evaluates the expression as a string,
|
2012-06-18 03:43:25 +02:00
|
|
|
* and pushes the string onto the string stack.
|
|
|
|
|
*/
|
|
|
|
|
extern void draw_eval_string(ivl_expr_t ex);
|
|
|
|
|
|
2012-07-16 05:44:07 +02:00
|
|
|
/*
|
2015-06-02 19:40:24 +02:00
|
|
|
* The draw_eval_string function evaluates the expression as an object,
|
2012-07-16 05:44:07 +02:00
|
|
|
* and pushes the object onto the object stack.
|
|
|
|
|
*/
|
|
|
|
|
extern int draw_eval_object(ivl_expr_t ex);
|
|
|
|
|
|
2011-11-29 00:29:53 +01:00
|
|
|
extern int show_stmt_assign(ivl_statement_t net);
|
|
|
|
|
extern void show_stmt_file_line(ivl_statement_t net, const char*desc);
|
|
|
|
|
|
2014-11-20 03:32:19 +01:00
|
|
|
/*
|
|
|
|
|
*/
|
|
|
|
|
extern int test_immediate_vec4_ok(ivl_expr_t expr);
|
|
|
|
|
extern void draw_immediate_vec4(ivl_expr_t expr, const char*opcode);
|
|
|
|
|
|
2016-04-02 20:49:38 +02:00
|
|
|
/*
|
|
|
|
|
* Draw a delay statement.
|
|
|
|
|
*/
|
|
|
|
|
extern void draw_delay(void*ptr, unsigned wid, const char*input,
|
|
|
|
|
ivl_expr_t rise_exp, ivl_expr_t fall_exp,
|
|
|
|
|
ivl_expr_t decay_exp);
|
|
|
|
|
|
2003-01-26 22:15:58 +01:00
|
|
|
/*
|
|
|
|
|
* These functions manage word register allocation.
|
|
|
|
|
*/
|
|
|
|
|
extern int allocate_word(void);
|
|
|
|
|
extern void clr_word(int idx);
|
|
|
|
|
|
2013-12-27 16:04:42 +01:00
|
|
|
/*
|
|
|
|
|
* These functions manage flag bit allocation.
|
|
|
|
|
*/
|
|
|
|
|
extern int allocate_flag(void);
|
|
|
|
|
extern void clr_flag(int idx);
|
|
|
|
|
|
2001-05-17 06:37:02 +02:00
|
|
|
/*
|
|
|
|
|
* These are used to count labels as I generate code.
|
|
|
|
|
*/
|
|
|
|
|
extern unsigned local_count;
|
|
|
|
|
extern unsigned thread_count;
|
|
|
|
|
|
2014-07-23 22:39:29 +02:00
|
|
|
#endif /* IVL_vvp_priv_H */
|