Class RegisterDescriptor
- java.lang.Object
-
- cbsw.RegisterDescriptor
-
public class RegisterDescriptor extends java.lang.Object
A bit-field descriptor
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
description
A human-readable description.protected int
length
The length in bits of the bit-field.protected java.lang.String
name
A short, unique name for the bit-field.protected java.lang.String
offset
The offset in bits of the bit-field.protected boolean
ro
Used to mark the bit-field as read-only.
-
Constructor Summary
Constructors Constructor Description RegisterDescriptor()
No-argument constructor called by unmarshaller
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
get(Io io)
Reads a register bit-field from hardwarejava.lang.String
get(java.util.BitSet regBits)
Returns a hex String representation of the register bitsbyte[]
getBytes(java.util.BitSet regBits)
Returns an array of bytes spanning the register bitsbyte[]
getBytes(java.util.BitSet regBits, int offset)
Returns an array of bytes spanning the register bitsjava.lang.String
getDescription()
Returns the bit-field descriptionint
getLength()
Returns the bit-field lengthjava.lang.String
getName()
Returns the bit-field namejava.lang.String
getOffset()
Returns the bit-field offsetboolean
isReadOnly()
Whether the underlying bit-field is marked read-only.boolean
matches(java.lang.String regex)
Test whether the bit-field name matches the regex.void
put(java.util.BitSet bits, java.lang.String regValue, Io io)
Writes a register bit-field to the hardwarevoid
set(java.util.BitSet regBits, boolean flag)
Set the register bits for all offsetsvoid
set(java.util.BitSet regBits, java.lang.String regString)
Set the register bits for all offsets
-
-
-
Field Detail
-
description
protected java.lang.String description
A human-readable description. Preferably terse.
-
name
protected java.lang.String name
A short, unique name for the bit-field. Used as the key to locate it.
-
offset
protected java.lang.String offset
The offset in bits of the bit-field. Can be a comma-separated list.
-
length
protected int length
The length in bits of the bit-field.
-
ro
protected boolean ro
Used to mark the bit-field as read-only.
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
Returns the bit-field description
- Returns:
- The descriptive text
-
getName
public java.lang.String getName()
Returns the bit-field name
- Returns:
- The name
-
matches
public boolean matches(java.lang.String regex)
Test whether the bit-field name matches the regex.
- Parameters:
regex
- The regex pattern to match.- Returns:
- true if match else false.
-
getOffset
public java.lang.String getOffset()
Returns the bit-field offset
- Returns:
- The offset
-
getLength
public int getLength()
Returns the bit-field length
- Returns:
- The length
-
isReadOnly
public boolean isReadOnly()
Whether the underlying bit-field is marked read-only.
- Returns:
- True if the bit-field is marked read-only
-
getBytes
public byte[] getBytes(java.util.BitSet regBits)
Returns an array of bytes spanning the register bits
- Parameters:
regBits
- The register bits- Returns:
- The array of bytes containing the register values
-
getBytes
public byte[] getBytes(java.util.BitSet regBits, int offset)
Returns an array of bytes spanning the register bits
- Parameters:
regBits
- The register bitsoffset
- The bit-field offset- Returns:
- The array of bytes containing the register values
-
get
public java.lang.String get(java.util.BitSet regBits)
Returns a hex String representation of the register bits
- Parameters:
regBits
- The register bits- Returns:
- Hex String representation of register bits
-
set
public void set(java.util.BitSet regBits, boolean flag)
Set the register bits for all offsets
- Parameters:
regBits
- The register bitsflag
- boolean representation of value to set
-
set
public void set(java.util.BitSet regBits, java.lang.String regString)
Set the register bits for all offsets
- Parameters:
regBits
- The register bitsregString
- Hex String representation of value to set
-
put
public void put(java.util.BitSet bits, java.lang.String regValue, Io io)
Writes a register bit-field to the hardware
- Parameters:
bits
- The register bitsregValue
- Hex representation of value to writeio
- The IO interface
-
get
public java.lang.String get(Io io)
Reads a register bit-field from hardware
- Parameters:
io
- The IO interface- Returns:
- Hex encoded String register value
-
-