Skip Nav
Home » Forums » SystemC Forum

Icon - KMLM List KMLM List

View email archives for the history of this mailing list.

List Home All Archives Dates Threads Authors Subjects
systemc-forum - Re: [Systemc-forum] unexpection error Message Thread: Previous | Next
  • To: Michael Beach <michaelb@xxxxxxxx>
  • From: Grzegorz Jakacki <jakacki@xxxxxxxxxxx>
  • Date: Mon, 15 Apr 2002 13:09:13 +0800 (CST)
  • Cc: Martin Janssen <Martin.Janssen@xxxxxxxxxxxx>, yigui Luo <yiguish2002@xxxxxxxxxxxx>, <systemc-forum@xxxxxxxxxxxxxxxxxxx>
Send Email to systemc-forum@osci.kavi.com:
Send new message
Reply to this message
On Mon, 15 Apr 2002, Michael Beach wrote:

> On Monday 15 April 2002 03:44, Martin Janssen wrote:
> > Hi Robert,
> >
> > sc_time_stamp() returns a sc_time value. This type has no
> > implicit conversion to double, hence
> >
> >   printf( "... %d ...", sc_time_stamp() );
> >
> > doesn't work and may have caused the unknown exception.

Just to minimize possible confusion: C++ compiler NEVER applies implicit
conversion to arguments passed by `...', thus the existence of implicit
conversion from sc_time to whatever would not change the behaviour of
printf("...", sc_time_stamp()).

Regards
Grzegorz

>
> You need to be careful of the format specifier used in the call to printf()
> too (if you decide to use printf() rather than an ostream). The %d specifier
> is inappropriate if you are actually trying to output a double (as in the
> case of sc_simulation_time() or sc_time_stamp().to_double()) as it is
> intended to output values of type int. For values of type double, %f is
> probably what you want.
>
> Most compilers won't give warnings or errors for this, as ISO standard C and
> C++ specify no mechanism by which this sort of thing might be detected. gcc
> (when supplied with appropriate declarations of the functions in question) is
> the notable exception to this generalization.
>
> Regards
> M.Beach
>
> > Try one of the following:
> >
> >   // in terms of the time resolution
> >   printf( "... %d ...", sc_time_stamp().to_double() );
> >   // in seconds
> >   printf( "... %d ...", sc_time_stamp().to_seconds() );
> >   // in terms of the default time unit
> >   printf( "... %d ...", sc_simulation_time() );
> >   // as a string
> >   printf( "... %s ...", sc_time_stamp().to_string().c_str() );
> >
> >   // my recommendation:
> >   cout << "global time: " << sc_time_stamp() << endl;
> >
> > Martin
> > -oo-
> >
> > yigui Luo wrote:
> > > Hi , all:
> > >    In the following little programme:
> > > /*************************************************/
> > > #include "systemc.h"
> > > #include "stdio.h"
> > > #include "stdlib.h"
> > > struct ff:sc_module{
> > >   sc_in<bool> p1;
> > >   sc_in_clk clk;
> > >   sc_out<bool> p2;
> > >
> > >   void mydisplay();
> > >
> > >   SC_CTOR(ff){
> > >           SC_CTHREAD(mydisplay,clk.pos());
> > >     }
> > >   };
> > >
> > >   void ff::mydisplay(){
> > >           while(true){
> > >                   wait();
> > >                   printf("global_time:%d  ",sc_time_stamp());     }
> > >   }
> > >
> > >
> > > int sc_main(int argc,char* argv[]){
> > >    sc_signal<bool> pp1;
> > >    sc_signal<bool> pp2;
> > >   sc_clock clk("clk",1,0.5,0,true);
> > >
> > >    ff ff1("ff1");
> > >    ff1.p1(pp1);
> > >    ff1.clk(clk);
> > >    ff1.p2(pp2);
> > >    sc_start(clk, -1);
> > >   return 1;
> > > }
> > > /**********************************************/
> > > there is no error on compiling and link to exe,but
> > > when execution the tt2.exe,tell me "UNKOWN
> > > UNEXPECTATION ERROR",why,can tell me ?
> > > Thanks!
> > >
> > >
> > > Robert
> > >
> > >
> > > _________________________________________________________
> > > Do You Yahoo!?
> > > 30 张免费世界杯球票 7 天送完!有种你就快来抢!
> > > http://cn.promo.yahoo.com/49/
> > >
> > > _______________________________________________
> > > Systemc-forum mailing list
> > > Systemc-forum@xxxxxxxxxxxxxxxxxxx
> > > https://server2.systemc.org/mailman/listinfo/systemc-forum
> >
> > _______________________________________________
> > Systemc-forum mailing list
> > Systemc-forum@xxxxxxxxxxxxxxxxxxx
> > https://server2.systemc.org/mailman/listinfo/systemc-forum
>
> _______________________________________________
> Systemc-forum mailing list
> Systemc-forum@xxxxxxxxxxxxxxxxxxx
> https://server2.systemc.org/mailman/listinfo/systemc-forum
>

###################################################################
# Grzegorz Jakacki                         China IC Design Center #
# Senior Engineer, CAD Dept.               1 Gaojiayuan, Chaoyang #
# tel. +86-10-64365577 x2009               Beijing 100015, China  #
# Copyright (C) 2002 Grzegorz Jakacki, CIDC. All Rights Reserved. #
###################################################################




By Date: Previous | Next Current Thread By Thread: Previous | Next

  Mail converted by the most-excellent MHonArc 2.6.10