Register Abstraction Layer Difference Access Type - verilog

I am writing a set of register models using uvm_reg class. Individual register size is 8-bit. Register block is created to contains those registers:
class my_reg_block extends uvm_reg_block;
my_byte_reg reg_00;
my_byte_reg reg_01;
my_byte_reg reg_10;
my_byte_reg reg_11;
...
// build()
my_map.add_reg(reg_00, 32'h0000 /*offset*/, ""RW");
my_map.add_reg(reg_01, 32'h0001 /*offset*/, ""RW");
my_map.add_reg(reg_10, 32'h0002 /*offset*/, ""RW");
my_map.add_reg(reg_11, 32'h0003 /*offset*/, ""RW");
...
I have a register adapter that will translate read/write into bus transaction.
So, I am able to do this inside my sequence:
reg_00.write(status, 'hff, .parent(this));
The bus transaction will do write to that specific register: reg_00.
My problem is that the bus has byte_enable that allow it to write accross 4 register in double-word access. Using the existing register model above, is it possible to write/read in 4 register at the same time? Or do I need to create another set of registers (with 32-bit size)?
It would be something like this pseudo-code:
{reg_11,reg_10,reg_01,reg_00}.write(status, 'hffffffff, .parent(this));
Any suggestion?

you could try passing additional information like byte_enable to the adapter using the extension argument in the write function. Then the adapter can decide accordingly if this is a legal double word transaction and assign the bus transaction fields accordingly. see partial example below
virtual function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw);
bus_trans trans;
uvm_reg_item item;
regtrans_params params;
item = get_item();
trans = bus_trans::type_id::create("trans");
if(item.extension == null)
`uvm_fatal("", "item.extension==null !!")
if(!$cast(params, item.extension))
`uvm_fatal("", "FAILED $cast(params, item.extension) !!")
trans.dst_chip_addr = params.chip_addr;
in the sequence:
block.reg_00.write(status, 32'hfffffffff .extension(params));

Related

How does one access an Extension to a table in Acumatica Business Logic

Apologies if this question has been answered elsewhere, I have had trouble finding any resources on this.
The scenario is this. I have created a custom field in the Tax Preferences screen called Usrapikey.
This value holds an api key for a call that gets done in some custom business logic.
The custom business logic however occurs on the Taxes screen.
So within the event handler I need to access that API key value from the other screen. I have tried instantiating graphs and using linq and bql but to no avail.
below is what I have currently and my error is: No overload for method 'GetExtension' takes 1 arguments
If I am going about this the wrong way please let me know if there is a more civilized way to do this
protected virtual void _(Events.FieldUpdated<TaxRev, TaxRev.startDate> e)
{
var setup = PXGraph.CreateInstance<TXSetupMaint>();
var TXSetupEX = setup.GetExtension<PX.Objects.TX.TXSetupExt>(setup);
var rateObj = GetValues(e.Row.TaxID, TXSetupEX.Usrapikey);
decimal rate;
var tryRate = (Decimal.TryParse(rateObj.rate.combined_rate, out rate));
row.TaxRate = (decimal)rate * (decimal)100;
row.TaxBucketID = 1;
}
Many Thanks!
Well, acumatica support got back. It seems if you want to access the base page use:
TXSetup txsetup = PXSetup<TXSetup>.Select(Base);
To get the extension use:
TXSetupExt rowExt = PXCache<TXSetup>.GetExtension<TXSetupExt>(txsetup);
Then you can access the extension fields like so:
var foo = rowExt.Usrfield;

"Dereference" a sub-resource in the Azure Python SDK return value

I would like to retrieve the public IP address associated with a given network interface. I need to do something like
client = NetworkManagementClient(...)
interface = client.network_interfaces.get('rg', 'nic-name')
ip_config_id = interface[0].public_ip_address.id
ip_config = some_magic(ip_config_id) # What goes here?
return ip_config.ip_address
This question suggests that in order to implement the some_magic routine, I should parse the ID (by splitting on slashes) and call client.public_ip_addresses.get(). This question indicates that I can call resource_client.resources.get_by_uid, but that doesn't return a PublicIPAddress object (I know I can call as_dict on it and get the data that way).
Is there a way to get an object of the appropriate type (in this case PublicIPAddress) from an object's ID in Azure (without manually parsing the ID)?
Update:
Due to this issue: public_ip_address method within NetworkManagementClient will not return values, we cannot fetch the ip address from PublicIPAddress.
So currently, you can use any other workaround, For example:
myip = client.public_ip_addresses.get(" resource_group_name","public_ip_address_name")
print(myip.ip_address)
You can change this line of code ip_config_id = interface[0].public_ip_address.id to something like my_public_ip_address = interface.ip_configurations[0].public_ip_address, then the return type is PublicIPAddress.
For example:

Obtaining FluentValidation max string length rules and their max values

We want to implement a character counter in our Javascript data entry form, so the user gets immediate keystroke feedback as to how many characters he has typed and how many he has left (something like "25/100", indicating current string length is 25 and 100 is the max allowed).
To do this, I would like to write a service that returns a list of dto property names and their max allowed lengths.
{Name='SmallComment', MaxLength=128}
{Name='BigComment', MaxLength=512}
The best way I can think of to do this would be to create an instance of the validator for that dto and iterate through it to pull out the .Length(min,max) rules. I had other ideas as well, like storing the max lengths in an attribute, but this would require rewriting all the validators to set up the rules based on the attributes.
Whatever solution is best, the goal is to store the max length for each property in a single place, so that changing that length affects the validation rule and the service data passed down to the javascript client.
If you want to maintain a single source of reference for both client/server I would take a metadata approach and provide a Service that returns the max lengths to the client for all types, something like:
public class ValidationMetadataServices : Service
{
public object Any(GetFieldMaxLengths request)
{
return new GetFieldMaxLengthsResponse {
Type1 = GetFieldMaxLengths<Type1>(),
Type2 = GetFieldMaxLengths<Type2>(),
Type3 = GetFieldMaxLengths<Type3>(),
};
}
static Dictionary<string,int> GetFieldMaxLengths<T>()
{
var to = new Dictionary<string,int>();
typeof(T).GetPublicProperties()
.Where(p => p.FirstAttribute<StringLengthAttribute>() != null)
.Each(p => to[p.PropertyName] =
p.FirstAttribute<StringLengthAttribute>().MaximumLength);
return to;
}
}
But FluentValidation uses Static properties so that would require manually specifying a rule for each property that validates against the length from the property metadata attribute.

Zstack read attribute

I want to know how can I read some attribute on local and remote zigbee device using TI zstack and how to put its value to uart. I'm zstack beginner. I managed to use uart with usb to uart converter and can send data to my pc. So I need to know how to get the attribute data. I've read api manual but didn't anderstand how to use zcl_SendRead function. Thanks.
Follow section "3.3 Send Read" of the "Z-Stack ZCL API.pdf" this should contain enough info for getting the read attr to the correct destination device. The contents of the readCmd is an array of attribute ID's, specific to the attribute(s) you want to read. You will need to consult the ZCL specification or device documentation to determine the correct Attr ID and Cluster ID.
An example for sending a read attr is shown below. It reads the ATTRID_MS_TEMPERATURE_MEASURED_VALUE attribute (from the ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT cluster) from device with short address 0x1234 and endpoint 0x1.
afAddrType_t dstAddr;
dstAddr.addrMode = afAddr16Bit;
dstAddr.addr.shortAddr = 0x1234; //set this to correct address
dstAddr.addr.endPoint = 0x1; // set this to correct ep
zclReadCmd_t *cmd = osal_mem_alloc((sizeof zclReadCmd_t) + sizeof(uint16));
cmd->numAttr = 1;
cmd->attrID[0] = ATTRID_MS_TEMPERATURE_MEASURED_VALUE;
zcl_SendRead( SAMPLETHERMOSTAT_ENDPOINT, &dstAddr,
ZCL_CLUSTER_ID_MS_TEMPERATURE_MEASUREMENT,
&cmd, ZCL_FRAME_CLIENT_SERVER_DIR,
hdr->fc.disableDefaultRsp, hdr->transSeqNum );
Once this command is sent you need to process the received the response, you will notice that the functions are contained in the ZStack Sample Applications but not populated, for instance the SampleSwitch application has zclSampleSw_ProcessInReadRspCmd() function, this will be called to process the read attr response and you will need to populate it to do what you want to do with the response.
Regards,
TC.

JSR 256 battery events

How can I detect whenever the power cord is unplugged from electrical socket using JSR 256?
You would add javax.microedition.io.Connector.sensor to the API Permissions tab of the Application Descriptor of the project properties.
From a quick look at the specifications of the JSR:
(you might want to look for code examples, starting with Appendix D of the spec itself, the latest JavaME SDK, Sony Ericsson developer website, then google)
As always, I would be worried about fragmentation in the diverse implementations of the JSR, but here's my first idea:
import javax.microedition.sensor.*;
SensorInfo[] powerSensorInfoArray = SensorManager.findSensors("power","ambient");
//let's assume there is one SensorInfo in the array.
//open a connection to the sensor.
SensorConnection connection = (SensorConnection)Connector.open(powerSensorInfoArray[0].getUrl(), Connector.READ);
// add a DataListener to the connection
connection.setDataListener(new MyDataListener(), 1);
// implement the data listener
public class MyDataListener implements DataListener {
public void dataReceived(SensorConnection aSensor, Data[] aDataArray, boolean isDataLost) {
//let's assume there is only one channel for the sensor and no data was lost.
// figure out what kind of data the channel provides.
int dataType = aDataArray[0].getChannelInfo().getDataType();
//now, I suggest you switch on dataType and print the value on the screen
// experimentation on the JSR256 implementation you're targetting seems to be
// the only way to figure out out power data is formatted and what values mean.
//only one of the following 3 lines will work:
double[] valueArray = aDataArray[0].getDoubleValues();
int[] valueArray = aDataArray[0].getIntValues();
Object[] valueArray = aDataArray[0].getObjectValues();
// let's assume one value in the valueArray
String valueToPrint = "" + valueArray[0];
// see what happens with that and you plug or unplug the power supply cable.
}
}
You'll need to add javax.microedition.io.Connector.sensor to your MIDlet permissions.
-------EDIT------
Documentation from the JSR-256 implementation on Sony-Ericsson Satio phone (S60 5th edition):
The battery charge sensor has the following characteristics:
Quantity: battery_charge
Context type: device
URL: sensor:battery_charge;contextType=device;model=SonyEricsson
Channels: (index: name, range, unit)
0: battery_charge, 0-100, percent
1: charger_state, 0-1, boolean

Resources