Overview
Unified Chip Design Platform - Address Map.
Modules:
| Name | Description |
|---|---|
access |
Access. |
addrdecoder |
Address Decoder aka Demultiplexer. |
addrinfo |
Address Information. |
addrmap |
Address Map. |
addrmapfinder |
Address Map Finder. |
addrmapref |
Module, Word and Field Reference. |
addrmaster |
Generic Master. |
addrmatrix |
Master-Slave Matrix. |
addrrange |
Address Range. |
addrref |
Addressed Reference. |
addrslave |
Generic Addressed Slave. |
addrspace |
Address Space. |
addrspacealias |
Address Space Alias. |
addrspaces |
Address Spaces. |
cli |
Command Line Interface. |
const |
Constants. |
data |
Access Type Description. |
datainfo |
Data Information. |
defines |
Defines. |
resolver |
Module, Word and Field Resolver. |
util |
Utilities. |
wordinfo |
Word Information. |
Classes:
| Name | Description |
|---|---|
Access |
Access. |
ReadOp |
Read Operation. |
WriteOp |
Write Operation. |
AddrDecoder |
Address Decoder aka Demultiplexer. |
AddrInfo |
Address Info. |
AddrMap |
Address Map. |
AddrMapRef |
Address Map Reference. |
AddrMaster |
Master. |
AddrMatrix |
Bus Matrix with a number of masters and slave with optional connections. |
AddrRange |
Address Range. |
AddrSlave |
Slave. |
SlaveAddrspace |
Slave Address Space. |
Addrspace |
Address Space. |
DefaultAddrspace |
Default Address Space. |
Field |
Field. |
FullError |
Full. |
ReservedAddrspace |
A Reserved Address Space. |
Word |
Word. |
Words |
Multiple Related Words. |
AddrspaceAlias |
Address Space Alias. |
DataType |
Trans Type. |
DataInfo |
Data Information. |
WordInfo |
WordInfo Info. |
Functions:
| Name | Description |
|---|---|
any_read |
Return |
cast_access |
Cast Access. |
get_counteraccess |
Get Counter Access. |
is_read_repeatable |
Return |
is_write_repeatable |
Return |
create_fill_addrspace |
Create Fill Addrspace. |
get_addrmap |
Search Address Spaces and Create Address Map. |
get_addrspaces |
Search Address Spaces. |
create_fill_field |
Create Fill Field. |
create_fill_word |
Create Fill Word. |
get_is_const |
Calc Is Constant Flag based on Accesses. |
get_is_volatile |
Calc Volatile Flag based on Accesses. |
get_mask |
Return mask for all fields of one word. |
name_alpha |
Convert number to a alpha digit. |
read_on_modify |
Return |
resolve_field_value |
Resolve Enumeration If necessary. |
join_addrspaces |
Join Address Spaces. |
zip_addrspaces |
Zip Address Spaces. |
check_data |
Check Data. |
get_datatype |
Data Type. |
get_size |
Determine Maximum Addressed Size of Data. |
resolve |
Retrieve AddrSpace, Word and Field referenced by |
resolves |
Same as |
calc_depth_size |
Calc Either Depth Or Size. |
split_keyvaluepairs |
Split comma-separated fields into (name, value) pairs. |
Attributes:
| Name | Type | Description |
|---|---|---|
ToAddrMapRef |
TypeAlias
|
Unresolved Address Map Reference. |
AddrRef |
TypeAlias
|
Addressed Reference. |
AddrData |
TypeAlias
|
Address-Data Pair. |
ToAddrMapRef
module-attribute
ToAddrMapRef = (
AddrMapRef | AddrRange | Addrspace | str | int
)
Unresolved Address Map Reference.
Access
ReadOp
WriteOp
Bases: IdentLightObject
Write Operation.
NEXT = {data}DATA {op} {write}WRITE
Attributes:
| Name | Type | Description |
|---|---|---|
data |
Literal[None, '', '~']
|
Operation On Stored Data. |
op |
Literal[None, 0, 1, '&', '|']
|
Operation On Stored and Incoming Data. |
write |
Literal[None, '', '~']
|
Operation On Incoming Data. |
once |
bool
|
Operation is just allowed once. |
title |
str
|
Title. |
descr |
str
|
Description. |
AddrDecoder
Bases: Object
Address Decoder aka Demultiplexer.
An address decoder manages the access to a known list of slaves. The address map contains the address to slave mapping.
An address decoder contains a unique address map and a namespace with all slaves.
Methods:
| Name | Description |
|---|---|
get_addrspaces |
Address Spaces. |
Attributes:
| Name | Type | Description |
|---|---|---|
addrmap |
AddrMap
|
Address Map With All Slaves. |
slaves |
Namespace
|
Namespace With All Slaves. |
default_size |
Bytes | None
|
Default Size if not given. |
is_sub |
bool
|
Just decode address LSBs. |
addrmap
class-attribute
instance-attribute
addrmap = Field(
default_factory=lambda: AddrMap(unique=True)
)
Address Map With All Slaves.
slaves
class-attribute
instance-attribute
Namespace With All Slaves.
AddrInfo
Bases: Object
Address Info.
Methods:
| Name | Description |
|---|---|
create |
Create |
iter |
Iteratate over address ranges. |
create
staticmethod
Create AddrInfo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addrmap
|
AddrMap
|
Address Map |
required |
item
|
ToAddrMapRef
|
Thing to be resolved |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
offset |
int | None
|
address offset in bytes |
mask |
int | None
|
Value Mask (not allowed for fields) |
Example Address Map:
>>> import ucdp as u
>>> from ucdp_addr import Addrspace, Word, Field, AddrMap
>>> addrmap = AddrMap()
>>> for idx, aname in enumerate(("uart", "spi", "owi")):
... addrspace = Addrspace(name=aname, width=32, depth=8, baseaddr=8*4*idx)
... addrmap.add(addrspace)
... word = addrspace.add_word("ctrl")
... field = word.add_field("ena", u.BitType(), "RW")
... word = addrspace.add_word("stat")
... field = word.add_field("bsy", u.BitType(), "RO", offset=9)
Addrspace:
>>> addrinfo = AddrInfo.create(addrmap, "spi")
>>> str(addrinfo)
'spi [0x20 8x32 (32 bytes)]'
>>> addrinfo.ref
AddrMapRef(..., addrspace=Addrspace(name='spi', baseaddr=Hex('0x20'), size=Bytesize('32 bytes')))
>>> addrinfo.mask
>>> tuple(addrinfo.iter())
(Hex('0x20'), Hex('0x24'), Hex('0x28'), Hex('0x2C'), Hex('0x30'), Hex('0x34'), Hex('0x38'), Hex('0x3C'))
>>> addrinfo = AddrInfo.create(addrmap, "spi", offset=8, mask=0xF0)
>>> str(addrinfo)
'spi [0x28 6x32 (24 bytes)] mask=0xF0'
>>> addrinfo.mask
Hex('0xF0')
>>> tuple(addrinfo.iter())
(Hex('0x28'), Hex('0x2C'), Hex('0x30'), Hex('0x34'), Hex('0x38'), Hex('0x3C'))
Word:
>>> addrinfo = AddrInfo.create(addrmap, "spi.stat")
>>> str(addrinfo)
'spi.stat [0x24 1x32 (4 bytes)]'
>>> addrinfo.ref
AddrMapRef(..., addrspace=Addrspace(name='spi', baseaddr=Hex('0x20'), ..., word=Word(name='stat', ...)
>>> addrinfo.mask
>>> tuple(addrinfo.iter())
(Hex('0x24'),)
>>> AddrInfo.create(addrmap, "spi.stat", offset=8)
Traceback (most recent call last):
...
ValueError: 'offset' is not allowed for words and fields
Field:
>>> addrinfo = AddrInfo.create(addrmap, "spi.stat.bsy")
>>> str(addrinfo)
'spi.stat.bsy [0x24 1x32 (4 bytes)] mask=0x200'
>>> addrinfo.ref
AddrMapRef(...Hex('0x20'), ... word=Word(name='stat', ...(name='bsy', type_=BitType(), bus=RO, offset=9))
>>> addrinfo.mask
Hex('0x200')
>>> tuple(addrinfo.iter())
(Hex('0x24'),)
>>> AddrInfo.create(addrmap, "spi.stat.bsy", offset=8)
Traceback (most recent call last):
...
ValueError: 'offset' is not allowed for words and fields
>>> AddrInfo.create(addrmap, "spi.stat.bsy", mask=8)
Traceback (most recent call last):
...
ValueError: 'mask' is not allowed for fields
AddrMap
Bases: Object
Address Map.
Methods:
| Name | Description |
|---|---|
from_addrspaces |
Create From address spaces. |
add |
Add Address Space. |
get |
Add Address Space. |
iter |
Iterate over Address Spaces. |
get_free_baseaddr |
Return baseaddress of free window with |
get_overview |
Return overview table. |
get_addrspaces_overview |
Get Address Spaces Overview Data. |
get_word_fields_overview |
Get Word-Fields Overview Data. |
Attributes:
| Name | Type | Description |
|---|---|---|
size |
Bytes | None
|
Size in Bytes. |
addrwidth |
int | None
|
Address Width. |
firstaddr |
int | None
|
First used address. |
lastaddr |
int | None
|
Last used address. |
addrslice |
Slice | None
|
Address Slice. |
from_addrspaces
staticmethod
Create From address spaces.
get_free_baseaddr
Return baseaddress of free window with size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
Bytes
|
Window Size |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
align |
Alignment, default aligned to size |
|
start |
Start search behind given address |
AddrMapRef
AddrMaster
Bases: IdentObject
Master.
AddrMatrix
Bases: AddrDecoder
Bus Matrix with a number of masters and slave with optional connections.
Methods:
| Name | Description |
|---|---|
add_interconnects |
Add Interconnects. |
get_overview |
Return overview tables. |
Attributes:
| Name | Type | Description |
|---|---|---|
masters |
Namespace
|
Masters. |
master_slaves |
tuple[tuple[AddrMaster, tuple[AddrSlave, ...]], ...]
|
Masters and Their Slaves. |
slave_masters |
tuple[tuple[AddrSlave, tuple[AddrMaster, ...]], ...]
|
Slaves and Their Masters. |
AddrRange
Bases: Object
Address Range.
Examples:
>>> addrrange = AddrRange(size='4k')
>>> addrrange
AddrRange(size=Bytesize('4 KB'))
>>> addrrange.baseaddr
Hex('0x0')
>>> addrrange.width
32
>>> addrrange.depth
1024
>>> addrrange.size
Bytesize('4 KB')
>>> addrrange.addrwidth
12
>>> addrrange.endaddr
Hex('0xFFF')
>>> addrrange.nextaddr
Hex('0x1000')
>>> addrrange.wordsize
4.0
>>> str(addrrange)
'0x0 1024x32 (4 KB)'
>>> str(AddrRange(depth=16))
'0x0 16x32 (64 bytes)'
>>> str(AddrRange(size=16))
'0x0 4x32 (16 bytes)'
Attributes:
| Name | Type | Description |
|---|---|---|
baseaddr |
Hex
|
Base Address |
width |
PositiveInt
|
Width in Bits. |
depth |
PositiveInt
|
Number of words. |
size |
Bytes
|
Size in Bytes. |
addrwidth |
PositiveInt
|
Address Width. |
addrmask |
PositiveInt
|
Address Width. |
endaddr |
Hex
|
End Address - |
nextaddr |
Hex
|
Next Free Address - |
wordsize |
float
|
Number of Bytes Per Word. |
org |
str
|
Organization. |
AddrSlave
Bases: IdentObject
Slave.
Methods:
| Name | Description |
|---|---|
add_addrrange |
Add Address Range. |
Attributes:
| Name | Type | Description |
|---|---|---|
addrdecoder |
AddrDecoder
|
Demultiplexer Addressing This Slave. |
ref |
AddrRef | None
|
Addressed Module. |
addrdecoder
class-attribute
instance-attribute
Demultiplexer Addressing This Slave.
SlaveAddrspace
Addrspace
Bases: AddrRange, IdentObject
Address Space.
Methods:
| Name | Description |
|---|---|
add_word |
Add Word. |
add_words |
Add Word. |
get_word |
Retrieve Word. |
lock |
Lock For Modification. |
get_word_hiername |
Get Hierarchical Word Name. |
get_field_hiername |
Get Hierarchical Field Name. |
iter |
Iterate over words and their fields. |
is_overlapping |
Determine both Address Spaces Overlap. |
get_intersect |
Get Intersection. |
join |
Join if Possible. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Name. |
is_sub |
bool
|
Address Decoder Just Compares |
words |
Namespace
|
Words within Address Space. |
doc |
Doc
|
Documentation |
attrs |
CastableAttrs
|
Attributes. |
add_words_naming |
NamingScheme
|
Naming Scheme for words created by |
title |
str | None
|
Alias to |
descr |
str | None
|
Alias to |
comment |
str | None
|
Alias to |
comment_or_title |
str | None
|
Return |
size_used |
Bytes
|
Number of Bytes Used. |
free_offset |
int
|
Free Offset. |
info |
str
|
Info. |
base |
str
|
Base. |
access |
str
|
Access. |
is_sub
class-attribute
instance-attribute
Address Decoder Just Compares addrwidth LSBs.
words
class-attribute
instance-attribute
Words within Address Space.
add_words_naming
class-attribute
instance-attribute
Naming Scheme for words created by add_words.
add_word
add_word(
name,
offset=None,
align=None,
byteoffset=None,
bytealign=None,
depth=None,
bus=None,
core=None,
is_volatile=None,
title=None,
descr=None,
comment=None,
**kwargs,
)
Add Word.
add_words
add_words(
name,
offset=None,
align=None,
byteoffset=None,
bytealign=None,
depth=None,
naming=None,
**kwargs,
)
Add Word.
iter
iter(
wordfilter=None,
fieldfilter=None,
fill=None,
fill_word=None,
fill_field=None,
fill_word_end=None,
fill_field_end=None,
)
Iterate over words and their fields.
is_overlapping
Determine both Address Spaces Overlap.
>>> one = Addrspace(name='one', baseaddr=0x2000, size='4kB')
>>> two = Addrspace(name='two', baseaddr=0x3000, size='4kB')
>>> three = Addrspace(name='three', baseaddr=0x2000, size='5kB')
>>> one.is_overlapping(two)
False
>>> one.is_overlapping(three)
True
>>> three.is_overlapping(one)
True
>>> three.is_overlapping(two)
True
get_intersect
Get Intersection.
>>> one = Addrspace(name='one', baseaddr=0x2000, size='4kB')
>>> two = Addrspace(name='two', baseaddr=0x3000, size='4kB')
>>> three = Addrspace(name='three', baseaddr=0x2000, size='5kB')
>>> one.get_intersect(two)
>>> one.get_intersect(three)
Addrspace(name='one', baseaddr=Hex('0x2000'), size=Bytesize('4 KB'))
>>> three.get_intersect(one)
Addrspace(name='three', baseaddr=Hex('0x2000'), size=Bytesize('4 KB'))
>>> three.get_intersect(two)
Addrspace(name='three', baseaddr=Hex('0x3000'), size=Bytesize('1 KB'))
DefaultAddrspace
Field
Bases: IdentLightObject
Field.
Attributes:
| Name | Type | Description |
|---|---|---|
type_ |
BaseScalarType
|
Type. |
bus |
Access | None
|
Bus Access. |
core |
Access | None
|
Core Access. |
offset |
int | Expr
|
Rightmost Bit Position. |
is_volatile |
bool
|
Volatile. |
doc |
Doc
|
Documentation. |
attrs |
CastableAttrs
|
Attributes. |
title |
str | None
|
Alias to |
descr |
str | None
|
Alias to |
comment |
str | None
|
Alias to |
comment_or_title |
str | None
|
Return |
slice |
Slice
|
Slice with Word. |
is_const |
bool
|
Field is Constant. |
access |
str
|
Access. |
FullError
Bases: ValueError
Full.
ReservedAddrspace
Word
Bases: IdentObject
Word.
Methods:
| Name | Description |
|---|---|
add_field |
Add field. |
lock |
Lock For Modification. |
get_field |
Get Field. |
get_default |
Return Word default value for all fields of one word. |
get_mask |
Return mask for all fields of one word. |
Attributes:
| Name | Type | Description |
|---|---|---|
fields |
Namespace
|
Fields within Word. |
offset |
int | Expr
|
Rightmost Word Position. |
width |
int
|
Width in Bits. |
depth |
int | Expr | None
|
Number of words. |
doc |
Doc
|
Documentation |
attrs |
CastableAttrs
|
Attributes. |
title |
str | None
|
Alias to |
descr |
str | None
|
Alias to |
comment |
str | None
|
Alias to |
comment_or_title |
str | None
|
Return |
slice |
Slice
|
Slice with Address Space. |
wordsize |
float
|
Word Size in Bytes. |
byteoffset |
Hex
|
Offset in Bytes, if word width is multiple of 8. |
access |
str
|
Access. |
fields
class-attribute
instance-attribute
Fields within Word.
add_field
add_field(
name,
type_,
bus=None,
core=None,
offset=None,
align=None,
is_volatile=None,
title=None,
descr=None,
comment=None,
attrs=None,
**kwargs,
)
Add field.
get_default
Return Word default value for all fields of one word.
import ucdp_addr as ua word = ua.Word(name='word', offset=0, width=32) field = word.add_field('field0', u.UintType(3, default=3), ua.access.RO) field = word.add_field('field1', u.SintType(6, default=-8), ua.access.WO, align=4) field = word.add_field('field2', u.UintType(3, default=4), ua.access.RW, align=4)
word.get_default() Hex('0x00004383') word.get_default(filter_=lambda field: field.bus.read) Hex('0x00004003') word.get_default(filter_=lambda field: field.bus.write) Hex('0x00004380') word.get_default(filter_=lambda field: field.bus.read and field.bus.write) Hex('0x00004000')
get_mask
Return mask for all fields of one word.
import ucdp_addr as ua word = ua.Word(name='word', offset=0, width=32) field = word.add_field('field0', u.UintType(3), ua.access.RO) field = word.add_field('field1', u.UintType(6), ua.access.WO, align=4) field = word.add_field('field2', u.UintType(3), ua.access.RW, align=4)
word.get_mask() Hex('0x000073F7') word.get_mask(filter_=lambda field: field.bus.read) Hex('0x00007007') word.get_mask(filter_=lambda field: field.bus.write) Hex('0x000073F0') word.get_mask(filter_=lambda field: field.bus.read and field.bus.write) Hex('0x00007000')
Words
Bases: Object
Multiple Related Words.
Methods:
| Name | Description |
|---|---|
create |
Create Helper for Set of Words. |
next |
Start a new Word. |
add_field |
Add Field to Current Word or start a new one. |
Attributes:
| Name | Type | Description |
|---|---|---|
idx |
int
|
Next Word Index. |
word |
Word
|
Current Word. |
fields |
tuple[Field, ...]
|
Fields Of All Words. |
create
classmethod
Create Helper for Set of Words.
AddrspaceAlias
DataType
DataInfo
Bases: Object
Data Information.
Single Data:
>>> datainfo = DataInfo.create(5)
>>> datainfo
DataInfo(datatype=SINGLE, data=5)
>>> str(datainfo)
'SINGLE: 5'
>>> tuple(datainfo.iter(AddrRange(width=64, depth=8)))
((Hex('0x0'), 5),)
>>> tuple(datainfo.iter(AddrRange(baseaddr=0x1000, width=64, depth=8)))
((Hex('0x1000'), 5),)
Burst Data:
>>> datainfo = DataInfo.create((5, 6, 7))
>>> datainfo
DataInfo(datatype=BURST, data=(5, 6, 7))
>>> str(datainfo)
'BURST: (5, 6, 7)'
>>> tuple(datainfo.iter(AddrRange(width=64, depth=8)))
((Hex('0x0'), 5), (Hex('0x8'), 6), (Hex('0x10'), 7))
>>> tuple(datainfo.iter(AddrRange(baseaddr=0x1000, width=64, depth=8)))
((Hex('0x1000'), 5), (Hex('0x1008'), 6), (Hex('0x1010'), 7))
Scattered Data:
>>> datainfo = DataInfo.create(((16, 5), (28, 6), (60, 7)))
>>> datainfo
DataInfo(datatype=SCAT, data=((16, 5), (28, 6), (60, 7)))
>>> str(datainfo)
'SCAT: ((16, 5), (28, 6), (60, 7))'
>>> tuple(datainfo.iter(AddrRange(width=64, depth=8)))
((Hex('0x10'), 5), (Hex('0x1C'), 6), (Hex('0x3C'), 7))
>>> tuple(datainfo.iter(AddrRange(baseaddr=0x1000, width=64, depth=8)))
((Hex('0x1010'), 5), (Hex('0x101C'), 6), (Hex('0x103C'), 7))
Errors:
>>> DataInfo.create('a')
Traceback (most recent call last):
...
TypeError: a
>>> DataInfo.create(('a', 'b'))
Traceback (most recent call last):
...
TypeError: ('a', 'b')
Methods:
| Name | Description |
|---|---|
create |
Create :any: |
iter |
Iteratate over single address value pairs according to access. |
WordInfo
Bases: Object
WordInfo Info.
Methods:
| Name | Description |
|---|---|
create |
Create |
iter |
Iteratate over single address value pairs according to access. |
addrs |
Addresses. |
Attributes:
| Name | Type | Description |
|---|---|---|
ref |
AddrMapRef
|
Address Map Reference. |
addrrange |
AddrRange
|
Accessed Address Range. |
datatype |
DataType
|
Data Type. |
data |
Data
|
Data. |
mask |
Hex | None
|
Data Masking. |
rmw |
bool | None
|
Read Modify Write - Read before write required. |
read_repeatable |
bool | None
|
Read Operation Has No Side-Effects. |
write_repeatable |
bool | None
|
Write Operation Has No Side-Effects. |
read_repeatable
class-attribute
instance-attribute
Read Operation Has No Side-Effects.
write_repeatable
class-attribute
instance-attribute
Write Operation Has No Side-Effects.
create
staticmethod
Create WordInfo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addrmap
|
AddrMap
|
Address Map |
required |
item
|
ToAddrMapRef
|
Thing to be resolved |
required |
data
|
Data | str | FieldValues
|
Data |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
offset |
Offset | None
|
address offset in bytes |
mask |
int | None
|
Mask for non-field access. |
wordsize |
Size | None
|
Size of one word in bytes (Only allowed if |
any_read
Return True if there is any read.
Usage:
>>> any_read([NA])
False
>>> any_read([RO, RO])
True
>>> any_read([RW, RW])
True
>>> any_read([RO, RW, WO])
True
cast_access
Cast Access.
Usage:
>>> from ucdp_addr import addrspace
>>> access = addrspace.cast_access("RO")
>>> access
RO
>>> cast_access(access)
RO
get_counteraccess
Get Counter Access.
Usage:
>>> from ucdp_addr import get_counteraccess, access
>>> str(get_counteraccess(access.RO))
'RW'
>>> str(get_counteraccess(access.RW))
'RO'
is_read_repeatable
Return True if a read has no side-effects.
Usage:
>>> is_read_repeatable([NA])
True
>>> is_read_repeatable([RO, RO])
True
>>> is_read_repeatable([RW, RW])
True
>>> is_read_repeatable([RO, RW, WO])
True
>>> is_read_repeatable([RO, RW, RC])
False
>>> is_read_repeatable([RO, RW, RP])
False
is_write_repeatable
Return True if a write has no side-effects.
>>> is_write_repeatable([NA])
True
>>> is_write_repeatable([RO, RO])
True
>>> is_write_repeatable([RW, RW])
True
>>> is_write_repeatable([RO, RW, WO])
True
>>> is_write_repeatable([RO, RW, WL])
False
get_addrmap
Search Address Spaces and Create Address Map.
get_mask
Return mask for all fields of one word.
import ucdp_addr as ua word = ua.Word(name='word', offset=0, width=32) field = word.add_field('field0', u.UintType(3), ua.access.RO) field = word.add_field('field1', u.UintType(6), ua.access.WO, align=4) field = word.add_field('field2', u.UintType(3), ua.access.RW, align=4)
get_mask(word) Hex('0x000073F7') get_mask(word, filter_=lambda field: field.bus.read) Hex('0x00007007') get_mask(word, filter_=lambda field: field.bus.write) Hex('0x000073F0') get_mask(word, filter_=lambda field: field.bus.read and field.bus.write) Hex('0x00007000')
name_alpha
Convert number to a alpha digit.
name_alpha(0) 'a' name_alpha(25) 'z' name_alpha(26) 'aa' name_alpha(27) 'ab' name_alpha(26+25) 'az' name_alpha(26+26) 'ba' name_alpha(26+26+25) 'bz' name_alpha(1000) 'alm'
read_on_modify
Return True if a read is needed in read-modify-write operations on word word with mask.
import ucdp_addr as ua word = ua.Word(name='word', offset=0, width=32) field = word.add_field('field0', u.UintType(3), ua.access.RO) field = word.add_field('field1', u.UintType(6), ua.access.WO, align=4) field = word.add_field('field2', u.UintType(3), ua.access.RW, align=4)
read_on_modify(word, 0x00007000) False read_on_modify(word, 0x00003000) True
zip_addrspaces
Zip Address Spaces.
one = ( ... Addrspace(name='a0', baseaddr=0x0000, size=0x1000), ... Addrspace(name='a1', baseaddr=0x1000, size=0x1000)) other = ( ... Addrspace(name='b0', baseaddr=0x0000, size=0x1000), ... Addrspace(name='b1', baseaddr=0x1000, size=0x800), ... Addrspace(name='b2', baseaddr=0x1800, size=0x800)) for left, right in zip_addrspaces(one, other): print(f"{str(left)!r} {str(right)!r}") 'a0 +0x0 1024x32' 'b0 +0x0 1024x32' 'a1 +0x1000 1024x32' 'b1 +0x1000 512x32' 'a1 +0x1000 1024x32' 'b2 +0x1800 512x32'
resolve
Retrieve AddrSpace, Word and Field referenced by item from addrmap.
item may be a string pattern with word and field name separated by '.' according to this scheme:
'addrspace[.word[.field]]'. Wildcards '*' and '?' are supported. The first match is returned.
item may be an address (integer). On check=True the address is checked to be covered by a valid
addrspace and word, if the addrspace contains words.
item may be already a address map reference. On check=True the address is checked to be covered by a valid
addrspace and word, if the addrspace contains words.
Example:
import ucdp as u from ucdp_addr import Addrspace, Word, Field, AddrMap addrmap = AddrMap() for aname in ("uart", "spi", "owi"): ... addrspace = Addrspace(name=aname, width=32, depth=128) ... addrmap.add(addrspace) ... word = addrspace.add_word("ctrl") ... field = word.add_field("ena", u.BitType(), "RW") ... word = addrspace.add_word("stat") ... field = word.add_field("bsy", u.BitType(), "RO")
By string:
resolve(addrmap, "uart") AddrMapRef(..., addrspace=Addrspace(name='uart', ...)) resolve(addrmap, "uart.ctrl") AddrMapRef(..., addrspace=Addrspace(name='uart', ...), word=Word(name='ctrl', ...)) resolve(addrmap, "uart.ctrl.ena") AddrMapRef(..., addrspace=Addrspace(name='uart', ...), word=Word(name='ctrl', ...), field=Field(name='ena', ...))
By reference:
ref = resolve(addrmap, "uart.ctrl.ena") ref AddrMapRef(..., addrspace=Addrspace(name='uart', ...), word=Word(name='ctrl', ...), field=Field(name='ena', ...)) resolve(addrmap, ref) AddrMapRef(..., addrspace=Addrspace(name='uart', ...), word=Word(name='ctrl', ...), field=Field(name='ena', ...))
By address space:
resolve(addrmap, Addrspace(baseaddr=0, width=32, depth=1)) AddrMapRef(..., addrspace=Addrspace(name='uart', size=Bytesize('4 bytes')))
By address range:
resolve(addrmap, AddrRange(baseaddr=0, width=32, depth=1)) AddrMapRef(addrrange=AddrRange(size=Bytesize('4 bytes')))
By address:
resolve(addrmap, 8) AddrMapRef(addrrange=AddrRange(baseaddr=Hex('0x8'), size=Bytesize('4 bytes')))
Errors:
resolve(addrmap, "uart.missing") Traceback (most recent call last): ... ValueError: 'uart.missing' does not exists resolve(addrmap, "uart:ctrl") Traceback (most recent call last): ... ValueError: uart:ctrl does not match pattern 'addrspace[.word[.field]]' resolve(addrmap, 5.0) Traceback (most recent call last): ... TypeError: 5.0 resolve(addrmap, Addrspace(baseaddr=0x1000, width=32, depth=1)) Traceback (most recent call last): ... ValueError: Addrspace(baseaddr=Hex('0x1000'), size=Bytesize('4 bytes')) does not exists
resolves
Same as resolve but returns all matches.
import ucdp as u from ucdp_addr import Addrspace, Word, Field, AddrMap addrmap = AddrMap() for aname in ("uart", "spi", "owi"): ... addrspace = Addrspace(name=aname, width=32, depth=128) ... addrmap.add(addrspace) ... word = addrspace.add_word("ctrl") ... field = word.add_field("ena", u.BitType(), "RW") ... word = addrspace.add_word("stat") ... field = word.add_field("bsy", u.BitType(), "RO")
for item in resolves(addrmap, "*.ctrl.ena"): print(item) uart.ctrl.ena spi.ctrl.ena owi.ctrl.ena
calc_depth_size
Calc Either Depth Or Size.
calc_depth_size(32, depth=64) (64, Bytesize('256 bytes')) calc_depth_size(32, size='64') (16, Bytesize('64 bytes')) calc_depth_size(32, depth=64, size=256) (64, Bytesize('256 bytes')) calc_depth_size(32) Traceback (most recent call last): ... ValueError: Either 'depth' or 'size' are required. calc_depth_size(32, depth=64, size='64') Traceback (most recent call last): ... ValueError: 'depth' and 'size' are mutually exclusive.
split_keyvaluepairs
Split comma-separated fields into (name, value) pairs.
split_keyvaluepairs('a=4') {'a': '4'} split_keyvaluepairs('a=4, b=a') {'a': '4', 'b': 'a'} split_keyvaluepairs('a=4, b') Traceback (most recent call last): ... ValueError: Invalid key=value pair: 'b' split_keyvaluepairs('a=4, a=a') Traceback (most recent call last): ... ValueError: Duplicate key 'a'