 |
bluespec.com Bluespec Forums
|
View previous topic :: View next topic |
Author |
Message |
snape
Joined: 23 Jun 2018 Posts: 1
|
Posted: Wed Jul 04, 2018 5:29 am Post subject: CReg |
|
|
I have used CReg in my code in the following way:
Vector#(64,Array#(Reg#(Page_4K_status))) vect_reg1_s <-replicateM(mkCRegU(3));
I am unable to call a field from the structure Page_4K_status.
The error shown is:
The expression does not have a field `pg4Ks' because it is not a struct or
interface. Found type:
Array#(Reg#(Common::Page_4K_status)) |
|
Back to top |
|
 |
quark Site Admin
Joined: 02 Nov 2007 Posts: 499
|
Posted: Mon Jul 09, 2018 6:14 pm Post subject: Re: CReg |
|
|
It sounds like you are missing the bracket index for selecting from the Array of Reg interfaces.
You probably have something like this in your code:
Code: | vect_reg1_s[vec_idx].pg4Ks
| but you need this:
Code: | vect_reg1_s[vec_idx][creg_idx].pg4Ks
|
The error message says that you're trying to select the field "pg4Ks" from something which is an Array. Before you can select the field, you first need to select and index of the Array.
Note that the "mkCRegU" module returns an Array of Reg interfaces, which you need to select from:
Code: | module mkExample();
Reg#(int) crg_x [3] <- mkCRegU (3);
rule r1;
crg_x [0] <= crg_x [0] + 1;
endrule
rule r2;
crg_x [1] <= crg_x [1] + 3;
endrule
rule r3;
$display ("%d", crg_x [2]);
endrule
endmodule
|
In your case, you have a Vector of Arrays, so you need two indices. |
|
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
|