OpenCores
URL https://opencores.org/ocsvn/csa/csa/trunk

Subversion Repositories csa

[/] [csa/] [trunk/] [bench/] [csa_pli.c] - Diff between revs 40 and 41

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 40 Rev 41
Line 35... Line 35...
 
 
        systf_h=vpi_handle(vpiSysTfCall,NULL);
        systf_h=vpi_handle(vpiSysTfCall,NULL);
        if(!systf_h)
        if(!systf_h)
        {
        {
                vpi_printf("ERROR: could not obtain the handle to systf call\n");
                vpi_printf("ERROR: could not obtain the handle to systf call\n");
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        trarg_itr=vpi_iterate(vpiArgument, systf_h);
        trarg_itr=vpi_iterate(vpiArgument, systf_h);
        if(!trarg_itr)
        if(!trarg_itr)
        {
        {
                vpi_printf("ERROR: could not obtain the iterate to argument\n");
                vpi_printf("ERROR: could not obtain the iterate to argument\n");
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        // get the first argument
        // get the first argument
        trarg_h=vpi_scan(trarg_itr);
        trarg_h=vpi_scan(trarg_itr);
        if(vpi_get(vpiType,trarg_h)!=vpiConstant)
        if(vpi_get(vpiType,trarg_h)!=vpiConstant)
        {
        {
                if(vpi_get(vpiConstType,trarg_h)!=vpiStringConst)
                if(vpi_get(vpiConstType,trarg_h)!=vpiStringConst)
                {
                {
                        vpi_printf("the first argument type is incorrect (not a string constant)\n");
                        vpi_printf("the first argument type is incorrect (not a string constant)\n");
                        tf_dofinish();
                        //tf_dofinish();
                        return 0;
                        return 0;
                }
                }
        }
        }
 
 
        // get the next argumnent
        // get the next argumnent
        trarg_h=vpi_scan(trarg_itr);
        trarg_h=vpi_scan(trarg_itr);
        trarg_type=vpi_get(vpiType,trarg_h);
        trarg_type=vpi_get(vpiType,trarg_h);
        if(trarg_type==vpiConstant)
        if(trarg_type==vpiConstant || trarg_type == vpiIntegerVar)
        // offset ?
        // offset ?
        {
        {
                if(vpi_get(vpiConstType,trarg_h)!=vpiDecConst)
                if(trarg_type==vpiConstant
 
                        && vpi_get(vpiConstType,trarg_h)!=vpiDecConst
 
                        && vpi_get(vpiConstType,trarg_h)!=vpiBinaryConst      // iverilog have this bug
 
                        )
                {
                {
                        vpi_printf("[%d]the offset must be dec constant [%d] \n",vpi_get(vpiConstType,trarg_h));
                        vpi_printf("[%d]the offset must be dec constant [%d] \n",__LINE__,vpi_get(vpiConstType,trarg_h));
                        tf_dofinish();
                        //tf_dofinish();
                        return 0;
                        return 0;
                }
                }
                trarg_h=vpi_scan(trarg_itr);
                trarg_h=vpi_scan(trarg_itr);
                trarg_type=vpi_get(vpiType,trarg_h);
                trarg_type=vpi_get(vpiType,trarg_h);
        }
        }
 
 
        if(trarg_type!=vpiReg)
        if(trarg_type!=vpiReg)
        {
        {
                vpi_printf("error:the current argument's type must be reg [%d]",trarg_type);
                vpi_printf("[%d]error:the current argument's type must be reg [%d]\n",__LINE__,trarg_type);
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        reg_size=vpi_get(vpiSize,trarg_h);
        reg_size=vpi_get(vpiSize,trarg_h);
 
 
Line 93... Line 96...
                s_vpi_value  value_s;
                s_vpi_value  value_s;
                trarg_type=vpi_get(vpiType,trarg_h);
                trarg_type=vpi_get(vpiType,trarg_h);
                if(trarg_type!=vpiConstant || vpi_get(vpiConstType,trarg_h)!=vpiBinaryConst)
                if(trarg_type!=vpiConstant || vpi_get(vpiConstType,trarg_h)!=vpiBinaryConst)
                {
                {
                        vpi_printf("error:size type must be a binary constant");
                        vpi_printf("error:size type must be a binary constant");
                        tf_dofinish();
                        //tf_dofinish();
                        return 0;
                        return 0;
                }
                }
                value_s.format=vpiIntVal;
                value_s.format=vpiIntVal;
                vpi_get_value(trarg_h,&value_s);
                vpi_get_value(trarg_h,&value_s);
                if(value_s.value.integer*8>reg_size)
                if(value_s.value.integer*8>reg_size)
Line 125... Line 128...
        systf_handle = vpi_handle(vpiSysTfCall, NULL);
        systf_handle = vpi_handle(vpiSysTfCall, NULL);
        arg_itr = vpi_iterate(vpiArgument, systf_handle);
        arg_itr = vpi_iterate(vpiArgument, systf_handle);
        if (arg_itr == NULL)
        if (arg_itr == NULL)
        {
        {
                vpi_printf("ERROR: failed to obtain systf arg handles\n");
                vpi_printf("ERROR: failed to obtain systf arg handles\n");
                tf_dofinish();
                //tf_dofinish();
                return(0);
                return(0);
        }
        }
 
 
        /* read file name */
        /* read file name */
        arg_handle = vpi_scan(arg_itr);
        arg_handle = vpi_scan(arg_itr);
Line 137... Line 140...
        vpi_get_value(arg_handle, &value_s);
        vpi_get_value(arg_handle, &value_s);
        fp=fopen(value_s.value.str,"rb");
        fp=fopen(value_s.value.str,"rb");
        if(!fp)
        if(!fp)
        {
        {
                vpi_printf("ERROR: failed to open the file [%s]\n",value_s.value.str);
                vpi_printf("ERROR: failed to open the file [%s]\n",value_s.value.str);
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        arg_handle = vpi_scan(arg_itr);
        arg_handle = vpi_scan(arg_itr);
        arg_type=vpi_get(vpiType,arg_handle);
        arg_type=vpi_get(vpiType,arg_handle);
        arg_handle_reg=arg_handle;
        arg_handle_reg=arg_handle;
        if(arg_type==vpiConstant)
        if(arg_type==vpiConstant || arg_type == vpiIntegerVar)
 
        // offset ?
        {
        {
                value_s.format = vpiIntVal;
                value_s.format = vpiIntVal;
                vpi_get_value(arg_handle, &value_s);
                vpi_get_value(arg_handle, &value_s);
                if(0<fseek(fp,value_s.value.integer,SEEK_SET))
                if(0<fseek(fp,value_s.value.integer,SEEK_SET))
                {
                {
Line 162... Line 166...
        // calute the size
        // calute the size
        read_size=vpi_get(vpiSize,arg_handle_reg);
        read_size=vpi_get(vpiSize,arg_handle_reg);
        arg_handle = vpi_scan(arg_itr);
        arg_handle = vpi_scan(arg_itr);
        if(arg_handle)
        if(arg_handle)
        {
        {
 
 
 
                vpi_printf("[%d] go here\n",__LINE__);
                value_s.format = vpiIntVal;
                value_s.format = vpiIntVal;
                vpi_get_value(arg_handle, &value_s);
                vpi_get_value(arg_handle, &value_s);
                if(value_s.value.integer<read_size*8)
                if(value_s.value.integer<read_size*8)
                        read_size=value_s.value.integer*8;
                        read_size=value_s.value.integer*8;
        }
        }
Line 243... Line 249...
 
 
        systf_h=vpi_handle(vpiSysTfCall,NULL);
        systf_h=vpi_handle(vpiSysTfCall,NULL);
        if(!systf_h)
        if(!systf_h)
        {
        {
                vpi_printf("ERROR: could not obtain the handle to systf call\n");
                vpi_printf("ERROR: could not obtain the handle to systf call\n");
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        trarg_itr=vpi_iterate(vpiArgument, systf_h);
        trarg_itr=vpi_iterate(vpiArgument, systf_h);
        if(!trarg_itr)
        if(!trarg_itr)
        {
        {
                vpi_printf("ERROR: could not obtain the iterate to argument\n");
                vpi_printf("ERROR: could not obtain the iterate to argument\n");
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
 
 
        // get the first argument
        // get the first argument
        trarg_h=vpi_scan(trarg_itr);
        trarg_h=vpi_scan(trarg_itr);
        if(vpi_get(vpiType,trarg_h)!=vpiConstant&&vpi_get(vpiConstType,trarg_h)!=vpiStringConst)
        if(vpi_get(vpiType,trarg_h)!=vpiConstant&&vpi_get(vpiConstType,trarg_h)!=vpiStringConst)
        {
        {
                vpi_printf("the first argument type is incorrect (not a string constant)\n");
                vpi_printf("the first argument type is incorrect (not a string constant)\n");
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        // get flag
        // get flag
        trarg_h=vpi_scan(trarg_itr);
        trarg_h=vpi_scan(trarg_itr);
Line 279... Line 285...
                if(
                if(
                           strcasecmp(value_s.value.str,"A")
                           strcasecmp(value_s.value.str,"A")
                           )
                           )
                {
                {
                        vpi_printf("error, not only support addpend A flag[%s]\n",value_s.value.str);
                        vpi_printf("error, not only support addpend A flag[%s]\n",value_s.value.str);
                        tf_dofinish();
                        //tf_dofinish();
                        return 0;
                        return 0;
                }
                }
 
 
                trarg_h=vpi_scan(trarg_itr);
                trarg_h=vpi_scan(trarg_itr);
                trarg_type=vpi_get(vpiType,trarg_h);
                trarg_type=vpi_get(vpiType,trarg_h);
        }
        }
 
 
        if(trarg_type!=vpiConstant&&trarg_type!=vpiReg&&trarg_type!=vpiPartSelect&&trarg_type!=vpiRegBit)
        if(
 
                trarg_type!=vpiConstant
 
                &&trarg_type!=vpiReg
 
                &&trarg_type!=vpiPartSelect
 
                //&&trarg_type!=vpiRegBit
 
                &&trarg_type!=vpiNet
 
                )
        {
        {
                vpi_printf("[%d]error, the last argument is not a constant val [%d]\n",__LINE__,trarg_type);
                vpi_printf("[%d]error, the last argument is not a valid val [%d]\n",__LINE__,trarg_type);
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
        if(trarg_type==vpiConstant)
        if(trarg_type==vpiConstant)
        {
        {
                if(0!=vpi_get(vpiConstType,trarg_h))
                if(0!=vpi_get(vpiConstType,trarg_h))
                {
                {
                        vpi_printf("error, the last argument is not a sub 0 type constant val \n");
                        vpi_printf("error, the last argument is not a sub 0 type constant val \n");
                        tf_dofinish();
                        //tf_dofinish();
                        return 0;
                        return 0;
                }
                }
        }
        }
 
 
        return 0;
        return 0;
Line 320... Line 332...
 
 
        systf_handle = vpi_handle(vpiSysTfCall, NULL);
        systf_handle = vpi_handle(vpiSysTfCall, NULL);
        if(systf_handle== NULL)
        if(systf_handle== NULL)
        {
        {
                vpi_printf("ERROR: failed to obtain systf call handles\n");
                vpi_printf("ERROR: failed to obtain systf call handles\n");
                tf_dofinish();
                //tf_dofinish();
                return(0);
                return(0);
        }
        }
        arg_itr = vpi_iterate(vpiArgument, systf_handle);
        arg_itr = vpi_iterate(vpiArgument, systf_handle);
        if (arg_itr == NULL)
        if (arg_itr == NULL)
        {
        {
                vpi_printf("ERROR: failed to obtain systf arg handles\n");
                vpi_printf("ERROR: failed to obtain systf arg handles\n");
                tf_dofinish();
                //tf_dofinish();
                return(0);
                return(0);
        }
        }
 
 
        /* read file name */
        /* read file name */
        arg_handle = vpi_scan(arg_itr);
        arg_handle = vpi_scan(arg_itr);
Line 350... Line 362...
                fp=fopen(value_s.value.str,"wb");
                fp=fopen(value_s.value.str,"wb");
        }
        }
        if(!fp)
        if(!fp)
        {
        {
                vpi_printf("can not open file to write\n");
                vpi_printf("can not open file to write\n");
                tf_dofinish();
                //tf_dofinish();
                return 0;
                return 0;
        }
        }
 
 
        // write data
        // write data
        {
        {

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.