Skip to content
This repository
tag: s20000812
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 214 lines (191 sloc) 7.964 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
#ifndef __target_H
#define __target_H
/*
* Copyright (c) 1998-1999 Stephen Williams (steve@icarus.com)
*
* 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
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: target.h,v 1.42 2000/08/09 03:43:45 steve Exp $"
#endif

# 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 {
      string name;
      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();

/* Start the design. This sets the main output file stream
that the target should use. */
      virtual bool start_design(const Design*) =0;

/* This is called once for each scope in the design, before
anything else is called. */
      virtual void scope(const NetScope*);

/* Output an event object. Called for each named event in the scope. */
      virtual void event(const NetEvent*);

/* Output a signal (called for each signal) */
      virtual void signal(const NetNet*);

/* Output a memory (called for each memory object) */
      virtual void memory(const NetMemory*);

/* Output a defined task. */
      virtual void task_def(const NetTaskDef*);
      virtual void func_def(const NetFuncDef*);

/* LPM style components are handled here. */
      virtual void lpm_add_sub(const NetAddSub*);
      virtual void lpm_clshift(const NetCLShift*);
      virtual void lpm_compare(const NetCompare*);
      virtual void lpm_divide(const NetDivide*);
      virtual void lpm_ff(const NetFF*);
      virtual void lpm_mult(const NetMult*);
      virtual void lpm_mux(const NetMux*);
      virtual void lpm_ram_dq(const NetRamDq*);

/* Output a gate (called for each gate) */
      virtual void logic(const NetLogic*);
      virtual void bufz(const NetBUFZ*);
      virtual void udp(const NetUDP*);
      virtual void udp_comb(const NetUDP_COMB*);
      virtual void net_assign(const NetAssign*);
      virtual void net_assign_nb(const NetAssignNB*);
      virtual void net_case_cmp(const NetCaseCmp*);
      virtual bool net_cassign(const NetCAssign*);
      virtual void net_const(const NetConst*);
      virtual bool net_force(const NetForce*);
      virtual void net_probe(const NetEvProbe*);

/* Output a process (called for each process). It is up to the
target to recurse if desired. */
      virtual bool process(const NetProcTop*);

/* Various kinds of process nodes are dispatched through these. */
      virtual void proc_assign(const NetAssign*);
      virtual void proc_assign_mem(const NetAssignMem*);
      virtual void proc_assign_nb(const NetAssignNB*);
      virtual void proc_assign_mem_nb(const NetAssignMemNB*);
      virtual bool proc_block(const NetBlock*);
      virtual void proc_case(const NetCase*);
      virtual bool proc_cassign(const NetCAssign*);
      virtual void proc_condit(const NetCondit*);
      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*);
      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*);

/* Done with the design. */
      virtual void end_design(const Design*);
};

/* This class is used by the NetExpr class to help with the scanning
of expressions. */
struct expr_scan_t {
      virtual ~expr_scan_t();
      virtual void expr_const(const NetEConst*);
      virtual void expr_concat(const NetEConcat*);
      virtual void expr_ident(const NetEIdent*);
      virtual void expr_memory(const NetEMemory*);
      virtual void expr_scope(const NetEScope*);
      virtual void expr_sfunc(const NetESFunc*);
      virtual void expr_signal(const NetESignal*);
      virtual void expr_subsignal(const NetESubSignal*);
      virtual void expr_ternary(const NetETernary*);
      virtual void expr_ufunc(const NetEUFunc*);
      virtual void expr_unary(const NetEUnary*);
      virtual void expr_binary(const NetEBinary*);
};


/* The emit functions take a design and emit it to the output stream
using the specified target. If the target is given by name, it is
located in the target_table and used. */
extern bool emit(const Design*des, const char*type);

/* This function takes a fully qualified verilog name (which may have,
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 is the table of supported output targets. It is a null
terminated array of pointers to targets. */
extern const struct target *target_table[];

/*
* $Log: target.h,v $
* Revision 1.42 2000/08/09 03:43:45 steve
* Move all file manipulation out of target class.
*
* Revision 1.41 2000/08/08 01:50:42 steve
* target methods need not take a file stream.
*
* Revision 1.40 2000/07/29 16:21:08 steve
* Report code generation errors through proc_delay.
*
* Revision 1.39 2000/07/27 05:13:44 steve
* Support elaboration of disable statements.
*
* Revision 1.38 2000/05/11 23:37:27 steve
* Add support for procedural continuous assignment.
*
* Revision 1.37 2000/05/04 03:37:59 steve
* Add infrastructure for system functions, move
* $time to that structure and add $random.
*
* Revision 1.36 2000/04/23 03:45:25 steve
* Add support for the procedural release statement.
*
* Revision 1.35 2000/04/22 04:20:20 steve
* Add support for force assignment.
*
* Revision 1.34 2000/04/12 04:23:58 steve
* Named events really should be expressed with PEIdent
* objects in the pform,
*
* Handle named events within the mix of net events
* and edges. As a unified lot they get caught together.
* wait statements are broken into more complex statements
* that include a conditional.
*
* Do not generate NetPEvent or NetNEvent objects in
* elaboration. NetEvent, NetEvWait and NetEvProbe
* take over those functions in the netlist.
*
* Revision 1.33 2000/04/10 05:26:06 steve
* All events now use the NetEvent class.
*
* Revision 1.32 2000/04/04 03:20:15 steve
* Simulate named event trigger and waits.
*
* Revision 1.31 2000/04/01 21:40:23 steve
* Add support for integer division.
*
* Revision 1.30 2000/03/29 04:37:11 steve
* New and improved combinational primitives.
*/
#endif
Something went wrong with that request. Please try again.