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 

Can't write to Struct fields in parallel (possible bug?)

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: BSC (Bluespec Compiler)
View previous topic :: View next topic  
Author Message
NCCMoore



Joined: 10 Jul 2012
Posts: 6

PostPosted: Tue Mar 13, 2018 11:59 am    Post subject: Can't write to Struct fields in parallel (possible bug?) Reply with quote

Hello!

So, in the code below, I run into a scheduler error:
Code:

package StructTest;

import DefaultValue :: * ;

   interface StructTest;
      method Action set_Inputs (Bool q);
      method Bool get_elk_foo ();
      method Int#(8) get_elk_bar ();
   endinterface

   typedef struct { Bool foo;
     Int#(8) bar;
     } Group deriving (Bits) ;

   instance DefaultValue#(Group);
     defaultValue = Group {foo:False, bar:0};
   endinstance

   module mkStructTest (StructTest);
      Reg#(Group) elk <- mkReg(defaultValue);

      method Action set_Inputs(q_in);
         if (q_in)
            elk.foo <= True;
         else
            elk.foo <= False;
         
         if (q_in)
            elk.bar <= 3;
         else
            elk.bar <= 6;         
      endmethod

      method Bool get_elk_foo();
         return  (elk.foo);
      endmethod

      method Int#(8) get_elk_bar();
         return  (elk.bar);
      endmethod
   endmodule
endpackage


Quote:

code generation for mkStructTest starts
Error: "StructTest.bsv", line 21, column 16: (G0004)
Rule `set_Inputs' uses methods that conflict in parallel:
elk.write({set_Inputs_q, elk[7:0]})
and
elk.write({elk[8], set_Inputs_q
? 8'd3
: 8'd6})
Elaborated error module file created: mkStructTest.ba


It seems to me that the scheduler is complaining that I'm writing to the same register twice, however, the bit ranges of the register I'm writing to do not overlap. To me it seems like this error shouldn't be occuring, especially when the mutually exclusive bit ranges represent fields of a struct.

If anyone can offer an explanation or a workaround, I would be grateful.


Nick
Back to top
View user's profile Send private message
ShepSiegel



Joined: 14 Aug 2007
Posts: 41

PostPosted: Tue Mar 13, 2018 7:09 pm    Post subject: Reply with quote

Hi Nick,

You can't partially update your Reg elk of Type Group.

There is an explanation here:
http://wiki.bluespec.com/Home/Experienced-Users/Register-Updates

-Shep
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: BSC (Bluespec Compiler) 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