bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

returning polymorphic types with BDPI

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: Bluesim
View previous topic :: View next topic  
Author Message
patil.nikhil



Joined: 17 Aug 2007
Posts: 69
Location: University of Texas at Austin

PostPosted: Mon Sep 10, 2007 4:40 am    Post subject: returning polymorphic types with BDPI Reply with quote

Hi,

THe following code:
Code:

import "BDPI" function ActionValue#(any_t)    replay_read (Bit#(64) handle, Nat size_in_bits) provisos (Bits#(any_t, _));

(*synthesize*)
module mkRPL(Empty);
    rule r;
        Nat v <- replay_read(0, 0);
        $display(v);
    endrule
endmodule

void replay_read(unsigned int *value, uint64_t fhandle, int size_in_bits)
{
...
}


generates code like:
mkRPL.cxx:
Code:

void mkRPL::RL_r()
{
  v__h38 = replay_read(&v__h38, 0llu, 0u);
  dollar_display(this, "32", v__h38);
}

but, in imported_BDPI_functions.h, declares it as:
Code:

  void replay_read(unsigned int *, unsigned long long , unsigned int );

causing g++ to emit this:
Code:

mkRPL.cxx: In member function 'void mkRPL::RL_r()':
mkRPL.cxx:23: error: void value not ignored as it ought to be


Is this a bug, or I am doing something wrong?

nikhil
Back to top
View user's profile Send private message Visit poster's website
jnewbern



Joined: 18 Jul 2007
Posts: 71

PostPosted: Mon Sep 10, 2007 7:37 am    Post subject: returning polymorphic types with BDPI Reply with quote

Nikhil,

This is a bug in the generated code, as you have identified. This bug has already been found and fixed and the fix will be included in the next release.

The next scheduled release is a couple of months away, so if you need a solution sooner please contact me at [email protected] and we can work something out.

Regards,
Jeff Newbern
Back to top
View user's profile Send private message
patil.nikhil



Joined: 17 Aug 2007
Posts: 69
Location: University of Texas at Austin

PostPosted: Mon Sep 10, 2007 8:59 am    Post subject: Reply with quote

Hi,

Thank you for your response, we'll await the next release! I managed a workaround for now. I am posting here in case somebody else needs it too.

I changed my function to return an unsigned int as well, so it looks like:
Code:

unsigned int replay_read (unsigned int *value, ..arguments..)
{
   memset(value, ...); // the usual way.
   return *value; // HACK.
}

This did not directly work, since the autogenerated imported_BDPI_functions.h has a wrong declaration. So after g++ craps out, I just use this script:
Code:

   sed 's/void replay_read/unsigned int replay_read/' -i build/imported_BDPI_functions.h
   c++ -Wno-unused -fno-rtti -g -D_FILE_OFFSET_BITS=64 -I/opt/bluespec/lib/Bluesim build/*cxx -L /opt/bluespec/lib/Bluesim/g++4/ -lbsprim -lbskernel -lbsui -ledit build/replay.o -lcurses -obuild/a.out


This hack is working for now, but I'll contact you if I have any problems in the future.

Thanks
nikhil
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: Bluesim All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP