Assignment operator type check failed on interface parameters - system-verilog

I'm working on parameterizing my interface to support multiple different instances:
compilation is failing on type mismatch:
assignment operator type check failed on instance hw_top (expecting
datatype compatible with 'virtual interface
foo_if#(.BASE_ADDR_1(32'h0000f480),.SIZE_1(32'h00000014),.BASE_ADDR_2(32'h00000000),.SIZE_2(32'h00000000))'
but found an incompatible
'foo_if#(.BASE_ADDR_1(32'h00002a00),.SIZE_1(32'h00000008),.BASE_ADDR_2(32'h00002a10),.SIZE_2(32'h00000008))
instance' instead).
This is how my interface is defined:
interface foo_if #(
parameter BASE_ADDR_1 = 'hf480,
parameter SIZE_1 = 'h14,
parameter BASE_ADDR_2 = 'h0,
parameter SIZE_2 = 'h0
)(
input clk,
input rst_n
);
//some logic
endinterface
This is how I instantiate it:
interface harness_if(
(
foo_if#(
.BASE_ADDR_1('h2a00),
.SIZE_1('h8),
.BASE_ADDR_2('h2a10),
.SIZE_2('h8)
) foo_if_i (
.clk (axi2af_clk),
.rst_n (resetn)
);
endinterface harness_if//
and I bind the harness if like this: harness_if
bind hw_top harness_if harness_i();
The whole idea of the parameter is that I can assign it to different values, so I'm unsure what is wrong.

The problem is that you are trying to place an instance of your interface where the port list of another interface should be. That is illegal syntax.
You want to place the interface instance inside the body of a module.
Here is a complete code example which shows 2 instances of your interface which use different parameter values:
interface foo_if #(
parameter BASE_ADDR_1 = 'hf480,
parameter SIZE_1 = 'h14,
parameter BASE_ADDR_2 = 'h0,
parameter SIZE_2 = 'h0
)(
input clk,
input rst_n
);
endinterface
module tb;
bit axi2af_clk, resetn;
foo_if # (
.BASE_ADDR_1('h2a00),
.SIZE_1 ('h8),
.BASE_ADDR_2('h2a10),
.SIZE_2 ('h8)
) foo_if_i (
.clk (axi2af_clk),
.rst_n (resetn)
);
foo_if # (
.BASE_ADDR_1('h1000),
.SIZE_1 (16),
.BASE_ADDR_2('h1010),
.SIZE_2 (16)
) foo_if_2 (
.clk (axi2af_clk),
.rst_n (resetn)
);
endmodule

Related

avc: denied default_android_hwservice, violet neverallow

First I got logs as:
11-11 11:11:14.779 2287 2287 E SELinux : **avc: denied** { add } for interface=vendor.abc.wifi.wifidiagnostic::IWifiDiagnostic sid=u:r:wifidiagnostic:s0 pid=2838 scontext=u:r:wifidiagnostic:s0 tcontext=u:object_r:**default_android_hwservice**:s0 tclass=hwservice_manager permissive=1
11-11 11:11:14.781 2838 2838 I ServiceManagement: Registered vendor.abc.wifi.wifidiagnostic#1.0::IWifiDiagnostic/default (start delay of 128ms)
11-11 11:11:14.781 2838 2838 I ServiceManagement: Removing namespace from process name vendor.abc.wifi.wifidiagnostic#1.0-service to wifidiagnostic#1.0-service.
But if I add
allow wifidiagnostic default_android_hwservice:hwservice_manager {add}
Get compile error:
libsepol.report_failure: neverallow on line 511 of system/sepolicy/public/domain.te (or line 11982 of policy.conf) violated by allow wifidiagnostic default_android_hwservice:hwservice_manager { add };
libsepol.check_assertions: **1 neverallow failures occurred**
Error while expanding policy
How can I resolve it?
wifidiagnostic is a native service which do diagnostic feature. I define the type in wifidiagnostic.te
# wifidiagnostic service
type wifidiagnostic, domain;
type wifidiagnostic_exec, exec_type, file_type, vendor_file_type;
init_daemon_domain(wifidiagnostic)
allow wifidiagnostic hwservicemanager_prop:file { getattr map open read };
allow wifidiagnostic hwservicemanager:binder { call transfer };
#allow wifidiagnostic default_android_hwservice:hwservice_manager { add };
allow wifidiagnostic hidl_base_hwservice:hwservice_manager { add };
and add lable in file_contexts
/vendor/bin/hw/vendor.abc.wifi.wifidiagnostic#1.0-service u:object_r:wifidiagnostic_exec:s0
You should also define your service type
Try following
# hwservice_contexts
vendor.abc.wifi.wifidiagnostic::IWifiDiagnostic u:object_r:vendor_abc_wifi_wifidiagnostic_hwservice:s0
# wifidiagnostic.te
type vendor_abc_wifi_wifidiagnostic_hwservice, hwservice_manager_type;
add_hwservice(wifidiagnostic, vendor_abc_wifi_wifidiagnostic_hwservice)
To allow a service to access a HAL you can use the hal_client_domain() macro (defined in system/sepolicy/public/te_macros).
I cannot tell from your description what your hal type is. Allowing access to the wifi HAL would look like this:
type wifidiagnostic, domain;
type wifidiagnostic_exec, exec_type, file_type, vendor_file_type;
# Allow context switch from init to wifidiagnostic.
init_daemon_domain(wifidiagnostic)
# Allow accessing wifi HAL.
hal_client_domain(wifidiagnostic, hal_wifi_hwservice)

Powershell function Params getting unexpected values when CSV fields are not present

I am writing a PowerShell function which can take pipeline input. Specifically I am testing it with Import-CSV. Many of the params are not mandatory, which means sometimes the CSV will not have those columns. For boolean values this is working as expected, but with string values, a missing CSV field yields a copy of the row object in the string field.
Here is an example problem parameter:
[Parameter(Mandatory=$False,
ValueFromPipeline=$True,
ValueFromPipelinebyPropertyName=$True,
HelpMessage="TCP Port of the remote server")]
[Alias('Port', 'Remote Server Port')]
[string]$RemoteServerPort = "5500",
Now, if the field is missing, I would expect the value to be "5500" as specified, but instead I get:
$RemoteServerPort = #{Name=KG; IP=10.1.1.1; Username=Admin; Password=}
I've done some looking around, but frankly I'm not even sure what to search for.
This is because you specified ValueFromPipeline=$True so that PoSh coerces the piped object to a string if it cannot bind the parameter by property name. You could solve that by removing ValueFromPipeline=$True from this parameter and introduce another one to be bound to the piped object, i.e. something like this
function MyTestFunc() {
param(
[Parameter(ValueFromPipeline=$True)]
[object]$PipedObj,
[Parameter(Mandatory=$False,
ValueFromPipelinebyPropertyName=$True,
HelpMessage="TCP Port of the remote server")]
[Alias('Port', 'Remote Server Port')]
[string]$RemoteServerPort = "5500"
)
Write-Host "Port: $RemoteServerPort / Obj: $PipedObj"
}
$o1 = [pscustomobject]#{"Server" = "123"; "Port" = "12345"}
$o2 = [pscustomobject]#{"Server" = "1234"; "OS" = "Win3.1"}
$o1 | MyTestFunc
$o2 | MyTestFunc
Will result in
Port: 12345 / Obj: #{Server=123; Port=12345}
Port: 5500 / Obj: #{Server=1234; OS=Win3.1}
A way to see in detail what is actually happening behind the scenes is to use Trace-Command like so
Trace-Command ParameterBinding {$o2 | MyTestFunc} -PSHost

Exception executing consequence for rule (Drools, Guvnor, JBPM5)

am new to BPM, using JBPM5.4 installer.
below is the my drl source code taken from Guvnor..
when firing the rules am getting the error.
rule "TestRule"
dialect "java"
when
exists (Person( name == "estaban" ))
then
Person.setName( "ESTABAN" );
end
StackTrace:
Exception in thread "main" Exception executing consequence for rule "TestRule" in com.tcs: java.lang.NullPointerExceptio
n
at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.j
ava:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.sample.ProcessMain.main(ProcessMain.java:41)
Caused by: java.lang.NullPointerException
at com.tcs.Rule_TestRule_063717b0a0b841d3ae5b0d9fa14879f8.defaultConsequence(Rule_TestRule_063717b0a0b841d3ae5b0d9fa148
79f8.java:7)
at com.tcs.Rule_TestRule_063717b0a0b841d3ae5b0d9fa14879f8DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
at com.tcs.Rule_TestRule_063717b0a0b841d3ae5b0d9fa14879f8DefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
... 6 more
You need to bind the fact found in the left-hand-side to a variable. Re-write like so:
rule "TestRule"
dialect "java"
when
$person: Person( name == "estaban" )
then
$person.setName( "ESTABAN" );
update( $person );
end
To do this in Guvnor, when you add/modify the constraint, you will see a "Modify constraints for Person" dialog box. You need to type a variable name such as "$person" in the "Variable name" text box.
This will cause it to change the generated DRL from :
Person( name == "estaban" )
to:
$person: Person( name == "estaban" )
Once you have bound the variable on the LHS then you need to modify the RHS. Select the option "Modify a field of an existing fact". You then need to select your variable name from the list provided and provide the details of which property to modify.

Yeoman Generator in CoffeeScript - HookFor Warning

I'm trying to develop a custom generator for Yeoman using CoffeeScript but I'm facing a problem. When I use the hookFor method in the constructor of my class Generator, I get a warning hookFor must be used within the constructor when I try to init my project with Yeoman and my custom generator. Here is the code of my generator in index.coffee :
path = require 'path'
util = require 'util'
yeoman = require '../../../../'
module.exports = class Generator extends yeoman.generators.Base
constructor: ->
super()
#directories = ['controllers', 'helpers', 'models', 'templates', 'views']
#hookFor 'artefact:controller', args: ['App']
deploy: ->
#directory '.', '.'
#mkdir path.join 'dev', directory for directory in #directories
Any help will be appreciated. Thanks.
Apparently, the error comes from Yeoman Generators code in the yeoman-generators/lib/base.js file.
Here is how I led to that conclusion :
The warning is caused by the variable _running set to true in hookFor function (line 296)
This variable is set to true in run function (line 78) and just after that, methods of the class Generator are iterated (line 81-137)
the constructor defined in CoffeeScript for the class Generator is called during the iteration, so #hookFor is called whereas _running is true : warning!
But, the constructor should not be called because a test is done during the iteration to prevent it (line 92) :
if ( method.constructor === '-' )
However, this test, in my opinion, should be :
if ( method === 'constructor' )
The hack does the trick. Feel free to add comment if I'm wrong.

How to set a nillable attribute for SOAP::Lite object in Perl?

I'm receiving the following error:
Exception: Error code: , messge: com.sun.istack.XMLStreamException2: org.xml.sax.SAXParseException: cvc-elt.3.1: Attribute 'http://www.w3.org/2001/XMLSchema-instance,nil' must not appear on element 'v1:get_list', because the {nillable} property of 'v1:get_list' is false. at ./soap.pl line 42.
This is my Perl code:
my $client = SOAP::Lite
->on_fault( \&faultHandler )
->uri('http://api.domain.net/')
->proxy('https://api.domain.net/MyAPI');
# Execute
$client->get_list();
How do I change/add the nillable attribute and how ?
How do I change/add the nillable attribute and how ?
You use SOAP::Data to create argument for get_list, or for call
Switch to SOAP::Simple , it has better WSDL support cpan BERLE/SOAP-Simple-0.00_03.tar.gz