Skip to content

Address Space

Address Space.

Classes:

Name Description
FullError

Full.

Field

Field.

Word

Word.

Words

Multiple Related Words.

Addrspace

Address Space.

ReservedAddrspace

A Reserved Address Space.

DefaultAddrspace

Default Address Space.

Functions:

Name Description
get_is_volatile

Calc Volatile Flag based on Accesses.

get_is_const

Calc Is Constant Flag based on Accesses.

name_alpha

Convert number to a alpha digit.

create_fill_word

Create Fill Word.

create_fill_field

Create Fill Field.

resolve_field_value

Resolve Enumeration If necessary.

get_mask

Return mask for all fields of one word.

read_on_modify

Return True if a read is needed in read-modify-write operations on word word with mask.

FullError

Bases: ValueError

Full.

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 doc.title.

descr str | None

Alias to doc.descr.

comment str | None

Alias to doc.comment.

comment_or_title str | None

Return comment if set, otherwise title.

slice Slice

Slice with Word.

is_const bool

Field is Constant.

access str

Access.

type_ instance-attribute

type_

Type.

bus class-attribute instance-attribute

bus = None

Bus Access.

core class-attribute instance-attribute

core = None

Core Access.

offset instance-attribute

offset

Rightmost Bit Position.

is_volatile class-attribute instance-attribute

is_volatile = False

Volatile.

doc class-attribute instance-attribute

doc = Doc()

Documentation.

attrs class-attribute instance-attribute

attrs = ()

Attributes.

title property

title

Alias to doc.title.

descr property

descr

Alias to doc.descr.

comment property

comment

Alias to doc.comment.

comment_or_title property

comment_or_title

Return comment if set, otherwise title.

slice property

slice

Slice with Word.

is_const property

is_const

Field is Constant.

access property

access

Access.

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 doc.title.

descr str | None

Alias to doc.descr.

comment str | None

Alias to doc.comment.

comment_or_title str | None

Return comment if set, otherwise title.

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 = Field(
    default_factory=Namespace, init=False, repr=False
)

Fields within Word.

offset instance-attribute

offset

Rightmost Word Position.

width instance-attribute

width

Width in Bits.

depth class-attribute instance-attribute

depth = None

Number of words.

doc class-attribute instance-attribute

doc = Doc()

Documentation

attrs class-attribute instance-attribute

attrs = ()

Attributes.

title property

title

Alias to doc.title.

descr property

descr

Alias to doc.descr.

comment property

comment

Alias to doc.comment.

comment_or_title property

comment_or_title

Return comment if set, otherwise title.

slice property

slice

Slice with Address Space.

wordsize property

wordsize

Word Size in Bytes.

byteoffset property

byteoffset

Offset in Bytes, if word width is multiple of 8.

access property

access

Access.

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.

lock

lock()

Lock For Modification.

get_field

get_field(name)

Get Field.

get_default

get_default(filter_=None)

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

get_mask(filter_=None)

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.

idx instance-attribute

idx

Next Word Index.

word instance-attribute

word

Current Word.

fields property

fields

Fields Of All Words.

create classmethod

create(
    name, addrspace, word_kwargs, naming="dec", **kwargs
)

Create Helper for Set of Words.

next

next()

Start a new Word.

add_field

add_field(*args, **kwargs)

Add Field to Current Word or start a new one.

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 addrwidth LSBs.

words Namespace

Words within Address Space.

doc Doc

Documentation

attrs CastableAttrs

Attributes.

add_words_naming NamingScheme

Naming Scheme for words created by add_words.

title str | None

Alias to doc.title.

descr str | None

Alias to doc.descr.

comment str | None

Alias to doc.comment.

comment_or_title str | None

Return comment if set, otherwise title.

size_used Bytes

Number of Bytes Used.

free_offset int

Free Offset.

info str

Info.

base str

Base.

access str

Access.

name class-attribute instance-attribute

name = ''

Name.

is_sub class-attribute instance-attribute

is_sub = True

Address Decoder Just Compares addrwidth LSBs.

words class-attribute instance-attribute

words = Field(default_factory=Namespace, repr=False)

Words within Address Space.

doc class-attribute instance-attribute

doc = Doc()

Documentation

attrs class-attribute instance-attribute

attrs = ()

Attributes.

add_words_naming class-attribute instance-attribute

add_words_naming = 'dec'

Naming Scheme for words created by add_words.

title property

title

Alias to doc.title.

descr property

descr

Alias to doc.descr.

comment property

comment

Alias to doc.comment.

comment_or_title property

comment_or_title

Return comment if set, otherwise title.

size_used property

size_used

Number of Bytes Used.

free_offset property

free_offset

Free Offset.

info property

info

Info.

base property

base

Base.

access property

access

Access.

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.

get_word

get_word(name)

Retrieve Word.

lock

lock()

Lock For Modification.

get_word_hiername

get_word_hiername(word)

Get Hierarchical Word Name.

get_field_hiername

get_field_hiername(word, field)

Get Hierarchical Field Name.

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

is_overlapping(other)

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_intersect(other)

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'))

join

join(other)

Join if Possible.

TODO: doc

ReservedAddrspace

Bases: Addrspace

A Reserved Address Space.

DefaultAddrspace

Bases: Addrspace

Default Address Space.

get_is_volatile

get_is_volatile(bus, core)

Calc Volatile Flag based on Accesses.

get_is_const

get_is_const(bus, core)

Calc Is Constant Flag based on Accesses.

name_alpha

name_alpha(num)

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'

create_fill_word

create_fill_word(addrspace, idx, offset, depth)

Create Fill Word.

create_fill_field

create_fill_field(word, idx, offset, width)

Create Fill Field.

resolve_field_value

resolve_field_value(field, value)

Resolve Enumeration If necessary.

get_mask

get_mask(word, filter_=None)

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')

read_on_modify

read_on_modify(word, mask)

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