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 

Problem in ActionValue

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ...
View previous topic :: View next topic  
Author Message
sreeju



Joined: 31 Aug 2018
Posts: 2

PostPosted: Wed Sep 05, 2018 1:02 am    Post subject: Problem in ActionValue Reply with quote

Code:
import Randomizable :: * ;
import ClientServer ::*;
import GetPut ::*;
import FIFO ::*;

interface ReadGenerator_IFC;
  interface Get#(Bit#(4)) getstim;
endinterface

module mkReadGenerator(ReadGenerator_IFC);


     Reg #(Bit #(2)) i <- mkReg(0);
     Reg #(Bit #(4)) a <- mkReg(0); 
     Reg #(Bit #(4)) b <- mkReg(0);
     Reg #(Bit #(4)) cntr <- mkReg(0);
     Randomize#(Bit#(4))      id         <- mkGenericRandomizer;

 rule j(i == 0);
    id.cntrl.init();
    i <= 1;
  endrule
 
 
  rule k  (i == 1);
    //let a <- id.next();
    $display("%0d", cntr);
    i <= 2;
  endrule

 rule handshaking  (i==2);
   let a = id.next;
   $display("%0d good going %0d",$time,a);
   cntr <= cntr + 1;
   i <= 3;
   //$finish;
  endrule

rule last(cntr == 15);
    $finish;
  endrule
 
 // interface getstim = toGet(a);
  interface Get getstim ;
    method ActionValue#(Bit#(4))get() if(i==3);
    let h = id.next();
   
     i <= 1;
      return(h) ;
    endmethod
  endinterface
endmodule




I am new to bluespec. I created this code, but in the above code the actionvalue does not returning randomized value. it shows the following error






Error: "master1_read_generator.bsv", line 70, column 14: (T0020)
Type error at:
h

Expected type:
Bit#(4)

Inferred type:
ActionValue#(Bit#(4)).



Please help me in resolving it
Sad
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 495

PostPosted: Thu Sep 20, 2018 1:51 pm    Post subject: Re: Problem in ActionValue Reply with quote

Ordinary values can be assigned with equals-sign (=), but ActionValue must be assigned using left arrow (<-). The left arrow causes the Action part to be added to the actions of the rule while the Value part is returned and assigned to the variable name:
Code:
let h <- id.next();
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ... 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