1998-11-04 00:28:49 +01:00
|
|
|
#ifndef __target_H
|
|
|
|
|
#define __target_H
|
|
|
|
|
/*
|
2011-03-07 20:18:23 +01:00
|
|
|
* Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com)
|
1998-11-04 00:28:49 +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.
|
1998-11-04 00:28:49 +01: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 02:54:01 +01:00
|
|
|
const char* name;
|
1998-11-04 00:28:49 +01: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 {
|
|
|
|
|
virtual ~target_t();
|
|
|
|
|
|
2000-08-08 03:50:42 +02:00
|
|
|
/* Start the design. This sets the main output file stream
|
|
|
|
|
that the target should use. */
|
2000-08-09 05:43:45 +02:00
|
|
|
virtual bool start_design(const Design*) =0;
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
/* This is called once for each scope in the design, before
|
|
|
|
|
anything else is called. */
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void scope(const NetScope*);
|
1999-11-27 20:07:57 +01:00
|
|
|
|
2011-03-07 20:18:23 +01:00
|
|
|
/* 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 05:20:15 +02:00
|
|
|
/* Output an event object. Called for each named event in the scope. */
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void event(const NetEvent*);
|
2000-04-04 05:20:15 +02:00
|
|
|
|
2010-11-21 00:09:32 +01:00
|
|
|
/* Output an enumeration typespec. */
|
|
|
|
|
virtual bool enumeration(const NetScope*, netenum_t*);
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/* Output a signal (called for each signal) */
|
2000-08-27 17:51:50 +02:00
|
|
|
virtual void signal(const NetNet*) =0;
|
2006-11-10 06:44:44 +01:00
|
|
|
virtual bool signal_paths(const NetNet*);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
2008-11-10 02:11:04 +01:00
|
|
|
/* Analog branches */
|
|
|
|
|
virtual bool branch(const NetBranch*);
|
|
|
|
|
|
1999-07-03 04:12:51 +02:00
|
|
|
/* Output a defined task. */
|
2001-04-02 04:28:12 +02:00
|
|
|
virtual void task_def(const NetScope*);
|
2004-06-01 01:34:36 +02:00
|
|
|
virtual bool func_def(const NetScope*);
|
1999-07-03 04:12:51 +02:00
|
|
|
|
1999-09-03 06:28:38 +02:00
|
|
|
/* LPM style components are handled here. */
|
2008-05-06 07:00:39 +02:00
|
|
|
virtual void lpm_abs(const NetAbs*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void lpm_add_sub(const NetAddSub*);
|
2007-01-16 06:44:14 +01:00
|
|
|
virtual bool lpm_array_dq(const NetArrayDq*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void lpm_clshift(const NetCLShift*);
|
2010-10-16 19:53:20 +02:00
|
|
|
virtual bool lpm_cast_int2(const NetCastInt2*);
|
|
|
|
|
virtual bool lpm_cast_int4(const NetCastInt4*);
|
2008-06-18 02:07:19 +02:00
|
|
|
virtual bool lpm_cast_real(const NetCastReal*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void lpm_compare(const NetCompare*);
|
|
|
|
|
virtual void lpm_divide(const NetDivide*);
|
2000-09-17 23:26:15 +02:00
|
|
|
virtual void lpm_modulo(const NetModulo*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void lpm_ff(const NetFF*);
|
|
|
|
|
virtual void lpm_mult(const NetMult*);
|
|
|
|
|
virtual void lpm_mux(const NetMux*);
|
2008-01-31 02:53:06 +01:00
|
|
|
virtual void lpm_pow(const NetPow*);
|
1999-09-03 06:28:38 +02:00
|
|
|
|
2004-12-30 00:55:43 +01:00
|
|
|
virtual bool concat(const NetConcat*);
|
2004-12-11 03:31:25 +01:00
|
|
|
virtual bool part_select(const NetPartSelect*);
|
2005-02-08 01:12:36 +01:00
|
|
|
virtual bool replicate(const NetReplicate*);
|
2004-12-11 03:31:25 +01:00
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
/* Output a gate (called for each gate) */
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void logic(const NetLogic*);
|
2008-05-20 06:42:52 +02:00
|
|
|
virtual bool tran(const NetTran*);
|
2005-02-03 05:56:20 +01:00
|
|
|
virtual bool ureduce(const NetUReduce*); /* unary reduction operator */
|
2000-08-14 06:39:56 +02:00
|
|
|
virtual bool bufz(const NetBUFZ*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void udp(const NetUDP*);
|
|
|
|
|
virtual void net_case_cmp(const NetCaseCmp*);
|
2000-08-14 06:39:56 +02:00
|
|
|
virtual bool net_const(const NetConst*);
|
2006-06-18 06:15:50 +02:00
|
|
|
virtual bool net_sysfunction(const NetSysFunc*);
|
2002-03-09 03:10:22 +01:00
|
|
|
virtual bool net_function(const NetUserFunc*);
|
2005-07-07 18:22:49 +02:00
|
|
|
virtual bool net_literal(const NetLiteral*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual void net_probe(const NetEvProbe*);
|
2005-05-24 03:44:27 +02:00
|
|
|
virtual bool sign_extend(const NetSignExtend*);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
1999-07-17 05:39:11 +02:00
|
|
|
/* Output a process (called for each process). It is up to the
|
|
|
|
|
target to recurse if desired. */
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual bool process(const NetProcTop*);
|
2008-11-07 06:31:34 +01:00
|
|
|
virtual bool process(const NetAnalogTop*);
|
1998-11-04 00:28:49 +01:00
|
|
|
|
|
|
|
|
/* Various kinds of process nodes are dispatched through these. */
|
2008-09-27 01:54:13 +02:00
|
|
|
virtual void proc_alloc(const NetAlloc*);
|
2008-07-31 03:01:41 +02:00
|
|
|
virtual bool proc_assign(const NetAssign*);
|
2000-08-08 03:50:42 +02: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*);
|
2002-01-19 20:02:08 +01:00
|
|
|
virtual bool proc_condit(const NetCondit*);
|
2008-11-07 06:31:34 +01:00
|
|
|
virtual bool proc_contribution(const NetContribution*);
|
2000-08-08 03:50:42 +02:00
|
|
|
virtual bool proc_deassign(const NetDeassign*);
|
|
|
|
|
virtual bool proc_delay(const NetPDelay*);
|
|
|
|
|
virtual bool proc_disable(const NetDisable*);
|
|
|
|
|
virtual bool proc_force(const NetForce*);
|
|
|
|
|
virtual void proc_forever(const NetForever*);
|
2008-09-27 01:54:13 +02:00
|
|
|
virtual void proc_free(const NetFree*);
|
2000-08-08 03:50:42 +02: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-04 00:28:49 +01:00
|
|
|
|
2001-03-27 05:31:06 +02: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-04 00:28:49 +01: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-31 03:01:41 +02:00
|
|
|
virtual void expr_access_func(const NetEAccess*);
|
1998-11-04 00:28:49 +01:00
|
|
|
virtual void expr_const(const NetEConst*);
|
2012-11-17 18:20:13 +01:00
|
|
|
virtual void expr_new(const NetENew*);
|
2012-11-12 02:42:31 +01:00
|
|
|
virtual void expr_null(const NetENull*);
|
2003-03-11 00:40:53 +01:00
|
|
|
virtual void expr_param(const NetEConstParam*);
|
2003-05-30 04:55:32 +02:00
|
|
|
virtual void expr_rparam(const NetECRealParam*);
|
2003-01-26 22:15:58 +01:00
|
|
|
virtual void expr_creal(const NetECReal*);
|
1999-06-09 05:00:05 +02:00
|
|
|
virtual void expr_concat(const NetEConcat*);
|
2003-04-22 06:48:29 +02:00
|
|
|
virtual void expr_event(const NetEEvent*);
|
1999-11-27 20:07:57 +01:00
|
|
|
virtual void expr_scope(const NetEScope*);
|
2002-01-28 01:52:41 +01:00
|
|
|
virtual void expr_select(const NetESelect*);
|
2000-05-04 05:37:58 +02:00
|
|
|
virtual void expr_sfunc(const NetESFunc*);
|
1998-11-07 18:05:05 +01:00
|
|
|
virtual void expr_signal(const NetESignal*);
|
1999-07-17 21:50:59 +02:00
|
|
|
virtual void expr_ternary(const NetETernary*);
|
1999-09-01 00:38:29 +02:00
|
|
|
virtual void expr_ufunc(const NetEUFunc*);
|
1998-11-04 00:28:49 +01:00
|
|
|
virtual void expr_unary(const NetEUnary*);
|
1998-11-07 18:05:05 +01:00
|
|
|
virtual void expr_binary(const NetEBinary*);
|
2010-11-21 00:09:32 +01:00
|
|
|
virtual void expr_netenum(const NetENetenum*);
|
1998-11-04 00:28:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-01-29 21:19:59 +01:00
|
|
|
/* This function takes a fully qualified Verilog name (which may have,
|
1998-11-04 00:28:49 +01: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);
|
|
|
|
|
|
2001-04-23 01:09:45 +02:00
|
|
|
/* 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);
|
|
|
|
|
|
1998-11-04 00:28:49 +01:00
|
|
|
#endif
|