which mask should I use for backdoor access in vr_ad? - specman

I'm trying to understand the backdoor access feature in vr_ad.
Seems there are two different masks:
One is the backdoor_mask field, and the other – get_bd_mask().
What is the difference between the two?
which of them should I use?

When performing backdoor access, the vr_ad sequencer updates the shadow model with the value written/read to/from the DUT. (reminder – in front door access, it's the monitor's responsibility to call update() ).
The exact value of the shadow model after the access considers -
- Was this field accessed? (the register in the RTL was read/written)
- Is this field readable/writable?The two "masks" guide the way the shadow model is updated.
mask_backdoor :
This field controls whether the read and write masks of the register should be applied also in backdoor access. If mask_backdoor is FALSE, the read/write masks of the registers are ignored when updating the shadow model after a backdoor access.
This means, for example, we assume that Read Only fields can be written in backdoor access. If you want read/write masks to be considered in backdoor access (same as they are in front door access) - set mask_backdoor to TRUE. (default of this is FALSE. read/write masks are ignored)
get_bd_mask() :
The backdoor access is performed by the vr_ad, by accessing the path defined with set_backdoor_path() or set_field_backdoor_path().
When performing a backdoor write, the vr_ad writes to the RTL only the fields whose path was set (naturally…). So, when it goes to update the shadow model – it should know which fields were written and hence should be updated in the shadow model, and which – were not.
For example –assume this register definition
reg_def EX_R1 {
reg_fld fld_0 : uint(bits : 8);
reg_fld fld_1 : uint(bits : 8);
set_static_info() is also {
set_field_backdoor_path("fld_1" ,"top.ex_r1[7:0]");
};
};
When you issue backdoor write of this register – vr_ad will write to top.ex_r1[7:0]. Then it will update the shadow model, but it will have to update only fld_1, and not fld_0.
In this case, for this register, get_bd_mask() returns {0x0, 0xf} indicating that the first field is masked (0), not to be updated.
Typically, backdoor access is performed by the vr_ad, so you should do nothing about this method. But – if you override the definition of the *_reg_backdoor methods – you should also extend get_bd_mask(). If in your implementation you access all the fields – then this methods should return a list of 1's. Any bit you do not access – should be masked out.

Related

Question: Can you perform contains operations on a global variable of type list in Drools

i was wondering if i can perform a contains operation on the left hand side (LHS) on a drools rule.
Something of the sort:
global java.util.List myGlobalList;
dialect "mvel"
rule "checker"
when
Task() from myGlobalList
then
System.out.println(myGlobalList);
end
The example above is not a working one and im not quite sure how to make it work. I am open to suggestions with other keywords from drools (contains, exists, in)!
Only if you want to check the global's initial state. Generally, globals are out of scope of what the rule is aware of. Your rules won't be cognizant of any changes to the the global.
You should instead put your series of tasks in a list in working memory like this:
rule "checker"
when
$myTasks: List() // suggest not a raw list in working memory, but this "works"
Task() from $myTasks
then
System.out.println($myTasks);
end
Your rule, as-is, will only work if Task is present in your global list at the time the rules are fired. If a rule subsequently removes the task, that won't be visible. There's also some additional weirdness around visibility that I don't fully understand myself because you shouldn't be writing rules against globals anyway.
In theory, if you understand the Drools lifecycle -- especially how the matcher phase works and how you can re-trigger that phase based on actions in your rules (update, insert, etc.) -- you chould in theory write rules like this that key off of the global. But since the global isn't part of working memory, it can't be a party to those same actions (eg you can't call update(myGlobalList)). This also adds a lot of complexity because future maintainers of your rules will need the same understanding of the lifecycle ... it'll become a maintenance nightmare, basically.
At the end of the day, you really shouldn't be using globals at all. They're usually a code smell more than anything, it's how we used to get data out of the rules back in the "old days" (10 plus years ago), because there weren't really any better ways and we didn't know any better. They're really analogous to 'static' variables in Java -- if you've got multiple threads, you can't rely on the value in a static non-volatile variable in 'if' conditions.
So the answer to your question is -- technically yes, but practically no. Don't do it. Design your rules better.
Note that the Drools documentation warns you not to do this as well:
Do not use global variables to establish conditions in rules unless a global variable has a constant immutable value. Global variables are not inserted into the working memory of the Drools engine, so the Drools engine cannot track value changes of variables.
Do not use global variables to share data between rules. Rules always reason and react to the working memory state, so if you want to pass data from rule to rule, assert the data as facts into the working memory of the Drools engine.
Basically the only time you'd ever reference a global on the left hand side ("when") is when the global is acting as a constant. So something like this:
global Float freeShippingMinimum;
rule "Free shipping if minimum met"
when
$c: Cart( subtotal >= freeShippingMinimum,
shippingFee > 0.0 )
then
modify( $c ) {
setShippingFee( 0.0 )
}
end
In this example, you get free shipping if your subtotal meets a minimum threshold. That threshold is passed into the rules because it is a constant and it comes from some external data source. It's passed into the rules as a global because it is a constant; since it is a constant, we can refer to it on the left hand side / "when".

How does the "needsCompositing" bit work?

I'm trying to better understand how the Flutter framework interprets the "needsCompositing" / "alwaysNeedsCompositing" bits.
When the needsCompositing bit is set on a render object, does every single ancestor render object up to the nearest repaint boundary also need compositing (i.e., its own composited layer)? Is this because any of those objects might, say, add a clip which may affect the newly composited child and in order to ensure that it does, a clip layer has to be used instead?
The part that seems surprising is that this would appear to add N new layers for N render objects just because one descendant needs compositing.
If this is true, I suppose this explains why you'd want to organize things into a shallow "repaint boundary sandwich."
needsCompositing is just going to signal to the render object whether it should be pushing a layer or not, which may or may not be true depending on what properties are set on the object. alwaysNeedsCompositing is unconditionally saying that.
It has no effect on ancestors - they can independently need or not need compositing, which again will control how the layer tree is constructed so that composition will happen on the engine side.
On an update, we do pump logic up the tree to make sure things get properly marked dirty (up to the nearest RepaintBoundary). However, individual render objects may respond to that by only pumping the data further up the tree and not setting their needsCompositing to true, if they never actually need compositing.

How can I pass custom data into a MTAudioProcessingTapProcessCallback?

I am successfully using an MTAudioProcessingTap in Swift on MacOS to manipulate my audio routing for both live playback and export. However, the specific routing that should occur at runtime depends on the user's choices. What I would like to be able to do is pass in a pair of Ints to the MTAudioProcessingTapProcessCallback when I create the tap so that I can use a single callback definition that can use those Ints to determine how to do the routing. The problem is that the callback is a C function pointer that can't capture context.
I thought maybe I could use the clientInfo parameter of the MTAudioProcessingTapCallbacks to hold the values I need, but I can't find any documentation on how I can access this parameter from within the MTAudioProcessingTapProcessCallback.
I have 32 possible routing combinations, and unfortunately the only other option I see at this point is declaring 32 separate MTAudioProcessingTapProcessCallbacks, and then selecting which to use when I create the tap. But it would be so much easier for me if I could just have a single MTAudioProcessingTapProcessCallback that makes a simple decision based on passed-in data.
I figured out how it works. In order to access the data inside the clientInfo from within the Process callback:
Inside the MTAudioProcessingTapInitCallback you have to initialize the tapStorageOut with the clientInfo pointer
Inside the Process callback use MTAudioProcessingTapGetStorage(tap) to get that pointer and access the data.

Force writing only-read register #Modbus

I was wondering,
Is there anyway to force writing on a 'Read-Only' Modbus Register?
Does defining a Register as a 'Read-Only' is secure enough or can be bypassed??
Thanks for the answers!
The correct way to define a "read-only" analog variable in Modbus is to map it as an input register. There is no function code defined in Modbus to write to an input register.
For historical reasons, several vendors maps all their variables as holding registers, which are theoretically read/write, i.e, there's a Write Multiple Registers function. Whenever they map a read only variable as a holding register, they must assert that the write functions fail. However, there's no standard exception code for this, as a holding register should be read/write. This is only one of Modbus' idiosyncrasies.
Getting back to your question, if you map your variable as an input register, you can be sure that the protocol will not allow a master to write to it. If, for interoperability issues you map it as a holding register, the protocol will allow the master to use a write funcion to change its value, and it is up to you to block in your device implementation.

Specman e vr_ad: How to use read_reg_field?

in UVM e Reference document is written:
You can call read_reg_field or write_reg_field for registers whose fields
are defined as single_field_access (see “vr_ad_port_unit Syntax and Examples”).
...
For example:
write_reg_fields tx_mode_reg {.resv = 4; .dest = 2};
But there is no example for using read_reg_field...
Could you please explain how should it be used?
(I've tried the next code, but it gives compilation error:
some_var = read_reg_field my_reg_file.my_reg {.my_reg_field} )
Thank you for your help.
As far as I know there is no read_reg_fieds macro. If you want to do a read to a register and then save the value of a certain field, do this:
read_reg my_reg;
value = my_reg.my_reg_field;
Normally, when you read register, you read them completely. Reading only individual fields makes sense if your bus protocol allows narrow transfers (i.e. your data width is 32 bits, but you can do 16 bit transfers on it). I haven't seen such a thing implemented in vr_ad (could be there and I just don't know of it), but UVM RAL (the SystemVerilog register package) supports it.
Long story short, if you just care about getting your data from your DUT, using read_reg is enough.
When the Design Under Test is implemented in verilog or vhdl - you can read the register as a whole, you cannot "read just some of its fields".
A register is at a specific address, reading this register -> read from this address.
The quote of the spec about fields access is when the DUT is a SystemC model.
Connecting to SC models is done using ports. If the model defines a port for each field - you can read a field.