 |
bluespec.com Bluespec Forums
|
View previous topic :: View next topic |
Author |
Message |
sreeju
Joined: 31 Aug 2018 Posts: 5
|
Posted: Wed Sep 05, 2018 1:02 am Post subject: Problem in ActionValue |
|
|
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 |
|
Back to top |
|
 |
quark Site Admin
Joined: 02 Nov 2007 Posts: 499
|
Posted: Thu Sep 20, 2018 1:51 pm Post subject: Re: Problem in ActionValue |
|
|
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 |
|
 |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|