Skip to content

Alias

Type aliases allow one type to be referenced and renamed as another, which can be used to create a localised reference to a foreign type.

Example

The Packtype definition can either use a Python dataclass style or the Packtype custom grammar:

import packtype
from packtype import Alias, Scalar

@packtype.package()
class PackageA:
    TypeA : Scalar[5]

@packtype.package()
class PackageB:
    TypeB : Alias[PackageA.TypeA]
package_a.pt
1
2
3
package package_a {
    type_a_t : Scalar[5]
}
package_b.pt
1
2
3
4
package package_b {
    import package_a::type_a_t
    type_b_t : type_a_t
}

As rendered to SystemVerilog:

1
2
3
4
5
6
7
8
package package_a;
typedef logic [4:0] type_a_t;
endpackage : package_a

package package_b;
import package_a::type_a_t;
typedef type_a_t type_b_t;
endpackage : package_b

Syntax

1
2
3
4
@packtype.package()
class PackageB:
    # Format <NAME> : Alias[<TYPE_TO_ALIAS>]
    TypeB : Alias[PackageA.TypeA]
1
2
3
4
package package_b {
    # Format <NAME> : <TYPE_TO_ALIAS>
    type_b_t : type_a_t
}