A bit of context, I'm an intern getting to grips with UVM, and this is my first post on this forum, so apologies if my question is poorly asked.
I've been given a sequence that has hard coded variables, and my aim is to set these variables to the values calculated in the test's connect phase. I know that the test creates an instance of the sequence in the run phase, but as the sequence isn't a child of the test, we can't simply "look up" to the parent test's values. So far I've tried a few options:
- I tried introducing parameters to the sequence code. Then in the test when I instantiate the sequence, I passed through the value that overrides the default value of the sequence parameter. This works if I hard code the overriding value, however in my case the value to introduce comes from a variable, so I get the "Class specialization parameter must be constant" error, which makes sense.
- I then tried doing a factory override of the sequence class, where I change the default value of the parameter to the value I want (I found some information on it here https://verificationacademy.com/cookbook/usingfactoryoverrides). However this also doesn't work, as the parameter value has to be the same in each case, which doesn't work for my case where the value can vary.
- I then looked at using the config_db to "set" the value in the test, and "get" the value in the sequence (I found some information on it here https://verificationacademy.com/forums/uvm/pass-parameter-uvmtest-uvmsequenceitem). This looked like the answer, but I was advised against it as I would be cluttering the database.
- As a shot in the dark, I tried creating a package that contains the variable I need, and thought I could import the package in both the test and sequence, get the test to alter the package value and get the sequence to read the package value. So in a way it acts as a global variable. This didn't work.
So my question is, how do I go about this? Config_db seems like the way forward, but are there any alternatives? I've tried a lot of options and searched the forums before resorting to posting a question, so please don't belittle a poor beginner. ;)