Files
iverilog/target.h
T

194 lines
7.6 KiB
C
Raw Permalink Normal View History

#ifndef IVL_target_H
#define IVL_target_H
1998-11-03 23:28:49 +00:00
/*
* Copyright (c) 1998-2014 Stephen Williams ([email protected])
1998-11-03 23:28:49 +00: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-28 18:41:23 -07:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1998-11-03 23:28:49 +00:00
*/
# include "netlist.h"
/*
* This header file describes the types and constants used to describe
* the possible target output types of the compiler. The backends
* provide one of these in order to tell the previous steps what the
* backend is able to do.
*/
/*
* The backend driver is hooked into the compiler, and given a name,
* by creating an instance of the target structure. The structure has
* the name that the compiler will use to locate the driver, and a
* pointer to a target_t object that is the actual driver.
*/
struct target {
2000-11-04 01:54:01 +00:00
const char* name;
1998-11-03 23:28:49 +00:00
struct target_t* meth;
};
/*
* The emit process uses a target_t driver to send the completed
* design to a file. It is up to the driver object to follow along in
* the iteration through the design, generating output as it can.
*/
struct target_t {
2013-11-16 16:27:05 -08:00
inline target_t() : errors(0) { }
1998-11-03 23:28:49 +00:00
virtual ~target_t();
2013-11-16 16:27:05 -08:00
/* Set this to count errors encountered during emit. */
int errors;
2000-08-08 01:50:42 +00:00
/* Start the design. This sets the main output file stream
that the target should use. */
virtual bool start_design(const Design*) =0;
1998-11-03 23:28:49 +00:00
1999-11-27 19:07:57 +00:00
/* This is called once for each scope in the design, before
anything else is called. */
2000-08-08 01:50:42 +00:00
virtual void scope(const NetScope*);
1999-11-27 19:07:57 +00:00
virtual bool class_type(const NetScope*, netclass_t*);
/* This is called to convert module ports from a NetNet* to an
* ivl_signal_t object. */
virtual void convert_module_ports(const NetScope*);
2000-04-04 03:20:15 +00:00
/* Output an event object. Called for each named event in the scope. */
2000-08-08 01:50:42 +00:00
virtual void event(const NetEvent*);
2000-04-04 03:20:15 +00:00
2010-11-20 15:09:32 -08:00
/* Output an enumeration typespec. */
virtual bool enumeration(const NetScope*, netenum_t*);
1998-11-03 23:28:49 +00:00
/* Output a signal (called for each signal) */
virtual void signal(const NetNet*) =0;
virtual bool signal_paths(const NetNet*);
1998-11-03 23:28:49 +00:00
/* Analog branches */
virtual bool branch(const NetBranch*);
1999-07-03 02:12:51 +00:00
/* Output a defined task. */
2001-04-02 02:28:12 +00:00
virtual void task_def(const NetScope*);
2004-05-31 23:34:36 +00:00
virtual bool func_def(const NetScope*);
1999-07-03 02:12:51 +00:00
1999-09-03 04:28:38 +00:00
/* LPM style components are handled here. */
virtual void lpm_abs(const NetAbs*);
2000-08-08 01:50:42 +00:00
virtual void lpm_add_sub(const NetAddSub*);
virtual bool lpm_array_dq(const NetArrayDq*);
2000-08-08 01:50:42 +00:00
virtual void lpm_clshift(const NetCLShift*);
virtual bool lpm_cast_int2(const NetCastInt2*);
virtual bool lpm_cast_int4(const NetCastInt4*);
2008-06-17 17:07:19 -07:00
virtual bool lpm_cast_real(const NetCastReal*);
2000-08-08 01:50:42 +00:00
virtual void lpm_compare(const NetCompare*);
virtual void lpm_divide(const NetDivide*);
2000-09-17 21:26:15 +00:00
virtual void lpm_modulo(const NetModulo*);
2000-08-08 01:50:42 +00:00
virtual void lpm_ff(const NetFF*);
virtual void lpm_mult(const NetMult*);
virtual void lpm_mux(const NetMux*);
virtual void lpm_pow(const NetPow*);
1999-09-03 04:28:38 +00:00
virtual bool concat(const NetConcat*);
virtual bool part_select(const NetPartSelect*);
virtual bool replicate(const NetReplicate*);
1998-11-03 23:28:49 +00:00
/* Output a gate (called for each gate) */
2000-08-08 01:50:42 +00:00
virtual void logic(const NetLogic*);
2008-05-19 21:42:52 -07:00
virtual bool tran(const NetTran*);
virtual bool ureduce(const NetUReduce*); /* unary reduction operator */
virtual bool bufz(const NetBUFZ*);
2000-08-08 01:50:42 +00:00
virtual void udp(const NetUDP*);
virtual void net_case_cmp(const NetCaseCmp*);
virtual bool net_const(const NetConst*);
virtual bool net_sysfunction(const NetSysFunc*);
2002-03-09 02:10:22 +00:00
virtual bool net_function(const NetUserFunc*);
2005-07-07 16:22:49 +00:00
virtual bool net_literal(const NetLiteral*);
2000-08-08 01:50:42 +00:00
virtual void net_probe(const NetEvProbe*);
2005-05-24 01:44:27 +00:00
virtual bool sign_extend(const NetSignExtend*);
virtual bool substitute(const NetSubstitute*);
1998-11-03 23:28:49 +00:00
1999-07-17 03:39:11 +00:00
/* Output a process (called for each process). It is up to the
target to recurse if desired. */
2000-08-08 01:50:42 +00:00
virtual bool process(const NetProcTop*);
virtual bool process(const NetAnalogTop*);
1998-11-03 23:28:49 +00:00
/* Various kinds of process nodes are dispatched through these. */
2008-09-27 00:54:13 +01:00
virtual void proc_alloc(const NetAlloc*);
2008-07-30 18:01:41 -07:00
virtual bool proc_assign(const NetAssign*);
2000-08-08 01:50:42 +00:00
virtual void proc_assign_nb(const NetAssignNB*);
virtual bool proc_block(const NetBlock*);
virtual void proc_case(const NetCase*);
virtual bool proc_cassign(const NetCAssign*);
virtual bool proc_condit(const NetCondit*);
virtual bool proc_contribution(const NetContribution*);
2000-08-08 01:50:42 +00:00
virtual bool proc_deassign(const NetDeassign*);
virtual bool proc_delay(const NetPDelay*);
virtual bool proc_disable(const NetDisable*);
2013-09-16 20:01:06 -07:00
virtual void proc_do_while(const NetDoWhile*);
2000-08-08 01:50:42 +00:00
virtual bool proc_force(const NetForce*);
virtual void proc_forever(const NetForever*);
2008-09-27 00:54:13 +01:00
virtual void proc_free(const NetFree*);
2000-08-08 01:50:42 +00:00
virtual bool proc_release(const NetRelease*);
virtual void proc_repeat(const NetRepeat*);
virtual bool proc_trigger(const NetEvTrig*);
virtual void proc_stask(const NetSTask*);
virtual void proc_utask(const NetUTask*);
virtual bool proc_wait(const NetEvWait*);
virtual void proc_while(const NetWhile*);
1998-11-03 23:28:49 +00:00
/* Done with the design. The target returns !0 if there is
some error in the code generation. */
virtual int end_design(const Design*);
1998-11-03 23:28:49 +00:00
};
/* This class is used by the NetExpr class to help with the scanning
of expressions. */
struct expr_scan_t {
virtual ~expr_scan_t();
2008-07-30 18:01:41 -07:00
virtual void expr_access_func(const NetEAccess*);
virtual void expr_array_pattern(const NetEArrayPattern*);
1998-11-03 23:28:49 +00:00
virtual void expr_const(const NetEConst*);
virtual void expr_last(const NetELast*);
virtual void expr_new(const NetENew*);
2012-11-11 17:42:31 -08:00
virtual void expr_null(const NetENull*);
virtual void expr_param(const NetEConstParam*);
2012-11-25 10:13:05 -08:00
virtual void expr_property(const NetEProperty*);
2003-05-30 02:55:32 +00:00
virtual void expr_rparam(const NetECRealParam*);
virtual void expr_creal(const NetECReal*);
virtual void expr_concat(const NetEConcat*);
virtual void expr_event(const NetEEvent*);
1999-11-27 19:07:57 +00:00
virtual void expr_scope(const NetEScope*);
virtual void expr_scopy(const NetEShallowCopy*);
2002-01-28 00:52:41 +00:00
virtual void expr_select(const NetESelect*);
virtual void expr_sfunc(const NetESFunc*);
1998-11-07 17:05:05 +00:00
virtual void expr_signal(const NetESignal*);
1999-07-17 19:50:59 +00:00
virtual void expr_ternary(const NetETernary*);
virtual void expr_ufunc(const NetEUFunc*);
1998-11-03 23:28:49 +00:00
virtual void expr_unary(const NetEUnary*);
1998-11-07 17:05:05 +00:00
virtual void expr_binary(const NetEBinary*);
2010-11-20 15:09:32 -08:00
virtual void expr_netenum(const NetENetenum*);
1998-11-03 23:28:49 +00:00
};
2008-01-29 12:19:59 -08:00
/* This function takes a fully qualified Verilog name (which may have,
1998-11-03 23:28:49 +00:00
for example, dots in it) and produces a mangled version that can be
used by most any language. */
extern string mangle(const string&str);
/* This function takes a string and produces an escaped version that can be
used inside a string constant for a C++ compiler. */
extern string stresc(const string&str);
#endif /* IVL_target_H */