I have two block, lets A and B. And block A output prog_out[7:0] is connected to B block input prog_in[7:0] so i do not have control over prog_in.
I Created the top_level (block A + Block B).
class transaction;
rand bit[7:0] prog_trim; // another input to block A and B (i.e input to top level)
bit [7:0] prog_out; // output of block A
rand bit [3:0] step ; // input to top_level
constraint c_prog_trim_value {
prog_trim <=(prog_out - step) ; }
endclass
I have written a constraint so that prog_trim should have always less then (prog_trim-step).
prog_trim <=(prog_out - step).
But I am not getting the expected result (i can see prog_trim is greater then (prog_out -step))
The problem here is prog_out_fll is the output of block A so how can we retrieve the value of prog_out_fll in transaction class during constraint writing?
The example you posted doesn’t compile. It’s difficult to give assistance when you don’t provide all of the information concerning what you are currently doing.
It seems like you are trying to randomize a class with a set of constraints. One of the inputs seems to be an output from a design block. Since the class doesn’t connect to signals, you need to provide this when calling randomize.
You can either set the value of prog_out prior to calling randomize(), or make prog_out a random variable and use the ‘with’ statement to constrain it when the randomize() call is made.