UVM TB and DUT parameter control - uvm

Please help to resolve one issue that I am facing with planning my TB.
Let’s assume my DUT has some input port which is parameter, something like:
module Multiplier #(parameter WIDTH = 8) (
input [WIDTH-1:0] addr,
Now I want my test to control this WIDTH parameter.
I want the test to randomize the WIDTH parameter, then apply that parameter to DUT. And based on that parameter value my whole testbench will be changed the transaction signals, driver, monitor and so on.
What is the best way to implement this parametric test?
I am thinking to have the WIDTH parameter in test class, and randomize it there. Then assign it to the DUT during instantiation. And for TB, put the randomize value in config_db and in agent get it and assign it to config class appropriate parameter.
Thanks
Hayk

I would generate a random variable in my Makefile (or whatever build/compilation system you are using). Then depending on your simulator, set the parameter from the simulation run command.
ModelSim:
The Parameters value can be passed with ‘vsim’ command in the ModelSim simulator. Assuming we want to supply a parameter value globally to all the modules:
-gWIDTH=<random_value>
VCS
-pvalue+hierarchical_name_of_parameter=<random_value>
All simulators have an equivalent.

Related

Step Function For Array in Anylogic

How to use an step function for an array in Anylogic?
step function is applied to double values, but I want to applied on elements of an array at a specific time.
You can't... so this is a solution:
Instead of an array you should use a linkedHashMap where your key is the specific time and the element is the step value you want at that time. So you defined it as follow:
And you put the values like this:
stepsArray.put(3.0,2.3);
where 3.0 is the time in which the step will occur and 2.3 is the value the step will take. You have to put there all the values you need. You are the one who has to fill these values according to your needs.
Then you create an cyclic event that will evaluate if it's time to apply a step and you create a variable of type double that will be the one storing the value of the step.
So, the event:
double theTime=round(100*time())/100.0;//it's better to round up the time just in case
if(stepsArray.containsKey(theTime)){
variable=stepsArray.get(theTime);
}
note that I'm using a variable, not a dynamic variable.. they you can connect the variable to wherever your step is needed in the sd model.
This method is a bit complicated, but it's the most general for your completely ambiguous question.
Not sure Felipe's approach is the best one but maybe I misunderstand the question.
Have you tried using a "table function" object? Define it as below where the horizontal axis represents the time unit and the vertical your step function data:
Then, use a cyclic event that every relevant time unit (depends on your model) pulls the current required value from the table function:

Is there a recommended way to parameterise Gatling simulations?

I'd like to be able to run Gatling via SBT and parameterize the number of constant users per second and the total duration of the simulation.
Something like:
setUp(testScenario.inject(constantUsersPerSec(<parameter>) during(<number> <seconds|minutes|hours>))
What would be the best way to pass arguments to SBT and read them in the Simulation class?
You can try pass them as environment parameters
val variable = Option(System.getProperty("variable")) getOrElse """default_value"""
and set them in the command : -Dvariable=yourValue

How to work around array of components with fixed size error?

I have a class with a port of dimensions [x,y] which is connected to another class having a matching port. Now I want to provide value to these variables [x,y] through external function call in which I basically read a .xml file and obtain values for x and y. But Dymola gives an error for this since during compilation it comes out as a non fixed size array.
Screenshot of error is attached.
The array sizes are structural parameters and they usually cannot depend on external function calls because they should be known at compile time. This is however supported in for example OpenModelica where a dll of the external function is built and called and the results are fetched during model compilation.
The only way to support this in all tools is to generate the model using an external tool which reads the xml and changes the .mo file with the values read.
You could probably have something like Parameters.mo:
package Parameters
constant Integer nTube = <EXTERN_NTUBE>;
constant Integer nSeg = <EXTERN_NSEG>;
end Parameters;
and your external tool will read the XML and bind and in Parameters.mo which you can then use in your models via Parameters.nTube and Parameters.nSeg. Maybe it would be good to give some defaults so that it works to use this file directly:
package Parameters
constant Integer nTube = 1;
constant Integer nSeg = 2;
end Parameters;
and then your external tool will replace 1 and 2 with the needed values before compilation.
This should be improved in Dymola 2017 (without the need for modifying the Modelica code). In earlier versions of Dymola it should work if the you translate the C-functions called to compute nTube and nSeg.
If that does not help your complete code would be needed to analyze the problem.

setting sampling time in c mex s func

What is the equivalent of the following for a C-mex s function? That is, how do I set discrete sample time of a block to the top level fixed step size in C?
My problem is, I could not find a way to "get" the top level fixed step size parameter in C-mex.
function setup(block)
block.SampleTimes = [str2double(get_param(bdroot, 'FixedStep')) 0];
Use ssGetFixedStepSize to get the base rate of the model. You may also want to ssSetErrorStatus if the that call returns 0, because that means your model is not configured with a FixedStep solver.
If, for some reason, you really want to go about fetching the information similar to what you have in the question, then you might be able to get access to it if you dig through the SimStruct pointer's fields. To do this, breakpoint in the mex file using a debugger and watch that variable.
Another option would be a few mexCallMATLAB calls to get the information you want.

OpenSSL GOST Parameter set

If there a way to insert custom parameters into the GOST 2001 parameters set programmatically and what API should be used? After being managed to generate EVP_PKEY by simulating OpenSSLs' function I found out that parameters are bound to NID, so there's a need in adding custom ones there. Ideas anyone?
Problem solved next way:
Upper error FILL_GOST2001_PARAMS:unsupported parameter set appears if you don't set your CurveName as one of already existing parameter set NID, so it should be like this: EC_GROUP_set_curve_name(CurveGroup,NID_id_GostR3410_2001_TestParamSet).
However setting one for default parameters set doesn't mean that It'll be used every time, for example in EC_KEY_check_key() function, you call it. What OpenSSL does is - it takes parameters from your EC_KEY object, so it's easily customizable, as long as those are correct (point is on curve and etc.).

Resources