I have,
class pq_ctx;
logic [7:0] pkts1; // w6<7:0>
logic [7:0] pkts2; // w6<7:0>
logic [3:0] skip; // w5<63:60>
logic [3:0] max_exp; // w5<59:56>
endclass
and I have register mask_pqctx[23:0].
I need each bit of mask_pqctx to mask each bit in class element. How do I do it?
class pq_ctx;
rand logic [7:0] pkts1; // w6<7:0>
rand logic [7:0] pkts2; // w6<7:0>
rand logic [3:0] skip; // w5<63:60>
rand logic [3:0] max_exp; // w5<59:56>
rand logic [23:0]mask_pqctx ;
constraint c1 {
mask_pqctx[23:16] inside {[1:8]};
mask_pqctx[15:8] inside {[1:8]};
mask_pqctx[7:4] inside {[1:4]};
mask_pqctx[3:0] inside {[1:4]};
(8'd1 << mask_pqctx[23:16]) -8'd1 == pkts1;
(8'd1 << mask_pqctx[15:8]) -8'd1 == pkts2;
(4'd1 << mask_pqctx[7:4]) -4'd1 == skip;
(4'd1 << mask_pqctx[3:0]) -4'd1 == max_exp;};
endclass
module top();
pq_ctx obj;
initial
begin
obj=new();
repeat(100) begin
obj.randomize();
$display("mast_pqctx[23:16] = %d,mast_pqctx[15:8]=%d, mast_pqctx[7:4]=%d, mast_pqctx[3:0]=%0d, pkts1=%b, pkts2=%b,skip=%0b,max_exp=%0b",obj.mask_pqctx[23:16],obj.mask_pqctx[15:8], obj.mask_pqctx[7:4], obj.mask_pqctx[3:0],obj.pkts1,obj.pkts2,obj.skip,obj.max_exp);
end
end
endmodule
In reply to mann_verif:
Your question is not very clear. In Digital logic,masks can be used for many different things. They can be used to prevent reading or writing bits, setting or clearing bits. What are you dining with your mask? How do the 24 bits of the mask_pqctx map to the bits in your class? Where is mask_pqctx declared in relation to the class? When is the mask applied?
In reply to dave_59:
In reply to mann_verif:
Your question is not very clear. In Digital logic,masks can be used for many different things. They can be used to prevent reading or writing bits, setting or clearing bits. What are you dining with your mask? How do the 24 bits of the mask_pqctx map to the bits in your class? Where is mask_pqctx declared in relation to the class? When is the mask applied?
Hi Dave,
Here are more details,
I have a class with above properties, I have a mask register which has 24 bits to mask each bit in class. I program this register in cfg sequence, when a modification is needed at bit level for class properties. To get the new class contents original class is bitwise anded with mask with any required programming.
In reply to mann_verif:
You only answered 1 of my 4 questions. The best I can say is:
{ pkts1, pkts2, skip, max_exp } = mask_pqctx & { pkts1, pkts2, skip, max_exp };