/* * Copyright (c) 2003 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 */ #ifdef HAVE_CVS_IDENT #ident "$Id: words.cc,v 1.3 2005/07/06 04:29:25 steve Exp $" #endif # include "compile.h" # include "vpi_priv.h" # include # include # include #ifdef HAVE_MALLOC_H # include #endif # include #if 0 void compile_word(char*label, char*type, char*name) { assert(strcmp(type, "real") == 0); free(type); vvp_fun_signal_real*fun = new vvp_fun_signal_real; vvp_net_t*net = new vvp_net_t; net->fun = fun; define_functor_symbol(label, net); vpiHandle obj = vpip_make_real_var(name, net); free(name); compile_vpi_symbol(label, obj); free(label); vpip_attach_to_current_scope(obj); } #endif void compile_var_real(char*label, char*name, int msb, int lsb) { vvp_fun_signal_real*fun = new vvp_fun_signal_real; vvp_net_t*net = new vvp_net_t; net->fun = fun; define_functor_symbol(label, net); vpiHandle obj = vpip_make_real_var(name, net); free(name); compile_vpi_symbol(label, obj); free(label); vpip_attach_to_current_scope(obj); } /* * A variable is a special functor, so we allocate that functor and * write the label into the symbol table. */ void compile_variable(char*label, char*name, int msb, int lsb, char signed_flag) { unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1; vvp_fun_signal*vsig = new vvp_fun_signal(wid); vvp_net_t*node = new vvp_net_t; node->fun = vsig; define_functor_symbol(label, node); /* Make the vpiHandle for the reg. */ vpiHandle obj = (signed_flag > 1) ? vpip_make_int(name, msb, lsb, node) : vpip_make_reg(name, msb, lsb, signed_flag!=0, node); compile_vpi_symbol(label, obj); vpip_attach_to_current_scope(obj); free(label); free(name); } /* * Here we handle .net records from the vvp source: * *