CIRCT 23.0.0git
Loading...
Searching...
No Matches
Classes | Functions | Variables
test_codegen Namespace Reference

Classes

class  AckArgs
 
class  CallbackWindowedList
 
class  CallServiceCallback
 
class  ChannelWindowedListRead
 
class  ChannelWindowedListWrite
 
class  CustomServiceDeclChannel
 
class  EventStruct
 
class  HostComms
 
class  IndexedFuncGroup
 
class  MmioReadWrite
 
class  NotifyArgs
 
class  OddInner
 
class  OddStruct
 
class  StructArgs
 
class  StructResult
 
class  TelemetryMetric
 
class  Top
 
class  TransformListItem
 
class  TypedFuncArrayResult
 
class  TypedFuncMultiArg
 
class  TypedFuncNestedStruct
 
class  TypedFuncStruct
 
class  TypedFuncSubByteSigned
 
class  TypedFuncVoidArg
 
class  TypedFuncVoidResult
 
class  TypedFuncWindowedList
 
class  TypedReadChannelStruct
 
class  TypedWriteChannelByte
 
class  VoidComms
 

Functions

 _build_harness_manifest ()
 
 test_codegen_round_trip (tmp_path)
 
str _emit (type_table, str system_name="test_ns")
 
 test_unbounded_field_skips_struct_with_comment ()
 

Variables

 SendI8 = Bundle([BundledChannel("send", ChannelDirection.FROM, Bits(8))])
 
 RecvI8 = Bundle([BundledChannel("recv", ChannelDirection.TO, Bits(8))])
 
 SendI0 = Bundle([BundledChannel("send", ChannelDirection.FROM, Bits(0))])
 
 RecvI0 = Bundle([BundledChannel("recv", ChannelDirection.TO, Bits(0))])
 
int ArrayArg = SInt(8) * 1
 
 ArrayResult = TypeAlias(SInt(8) * 2, "ArrayResult")
 
int _TRANSFORM_LIST_BULK_WIDTH = 16
 
int _TRANSFORM_LIST_ITEMS_PER_FRAME = 1
 
 _TRANSFORM_LIST_STRUCT = StructType([("data", List(TransformListItem))])
 
 _transform_list_window
 
int _WINDOW_PROBE_TAG = 0xCAFE
 
list _WINDOW_PROBE_ITEMS = [10, 20, 30, 40]
 
int _WINDOW_PROBE_BULK_WIDTH = 16
 
int _WINDOW_PROBE_ITEMS_PER_FRAME = 1
 
 _window_probe_struct
 
 _window_probe_window
 
 bsp = get_bsp(sys.argv[2] if len(sys.argv) > 2 else None)
 
 s = System(bsp(Top), name="TestCodegen", output_directory=sys.argv[1])
 
 _HARNESS_DIR = Path(__file__).parent
 
 requires_cmake
 
 _uint1 = types.UIntType("ui1", 1)
 
 _uint2 = types.UIntType("ui2", 2)
 
 _uint3 = types.UIntType("ui3", 3)
 
 _uint7 = types.UIntType("ui7", 7)
 
 _uint8 = types.UIntType("ui8", 8)
 
 _uint12 = types.UIntType("ui12", 12)
 
 _uint16 = types.UIntType("ui16", 16)
 
 _uint24 = types.UIntType("ui24", 24)
 
 _uint32 = types.UIntType("ui32", 32)
 
 _uint64 = types.UIntType("ui64", 64)
 
 _sint5 = types.SIntType("si5", 5)
 
 _sint7 = types.SIntType("si7", 7)
 
 _sint8 = types.SIntType("si8", 8)
 
 _sint16 = types.SIntType("si16", 16)
 
 _sint24 = types.SIntType("si24", 24)
 
 _sint32 = types.SIntType("si32", 32)
 
 _sint64 = types.SIntType("si64", 64)
 
 _bits128 = types.BitsType("bits128", 128)
 
 _uint96 = types.UIntType("ui96", 96)
 
 _uint128 = types.UIntType("ui128", 128)
 
 _sint96 = types.SIntType("si96", 96)
 
 _sint128 = types.SIntType("si128", 128)
 

Detailed Description

Hardware design for the codegen + port-kind coverage integration test.

Where ``serialization_probes.py`` exercises wire-format invariants, this design
exercises the *port-kind* surface area of the ESI runtime + facade codegen.
Each probe module here is named for the codegen / runtime path it exercises
so a regression in any single path lights up exactly one driver assertion.
End-to-end tests for `esiaccel.codegen`.

The bulk of the verification is delegated to `codegen_harness.cpp` in this
directory: the Python side generates a `types.h` from a representative
manifest, compiles the harness against it, and runs the result. The harness
exercises every accessor path (Path A / B / C, bool, nested struct, array,
union, window) and checks both the user-visible round-trip and the
underlying wire bytes. Reviewers can read the harness directly to see what
the codegen is contracted to do.

A small number of Python-level tests cover behaviours the harness can't
exercise — ordering, name collisions, type aliases, and the "skip with a
comment" path for unsupported / window-containing / fully-collapsed
structs.

Function Documentation

◆ _build_harness_manifest()

test_codegen._build_harness_manifest ( )
protected
Build the type table the `codegen_harness.cpp` test program references.

The aliases below give every emitted struct a stable, hand-written C++
name (e.g. `StdU`) so the harness can use plain identifiers rather than
spelling the auto-generated mangled names.

Definition at line 70 of file test_codegen.py.

Referenced by test_codegen_round_trip().

◆ _emit()

str test_codegen._emit (   type_table,
str   system_name = "test_ns" 
)
protected
Run the planner + emitter against `type_table` and return `types.h`.

Definition at line 392 of file test_codegen.py.

Referenced by test_unbounded_field_skips_struct_with_comment().

◆ test_codegen_round_trip()

test_codegen.test_codegen_round_trip (   tmp_path)
Compile `codegen_harness.cpp` against a freshly-generated `types.h`
and run it. The harness asserts every wire-format and accessor invariant
end-to-end; this Python test just drives the cmake build and reports
failures.

Definition at line 296 of file test_codegen.py.

References _build_harness_manifest().

◆ test_unbounded_field_skips_struct_with_comment()

test_codegen.test_unbounded_field_skips_struct_with_comment ( )
A struct whose payload type has no bounded width (e.g. `!esi.any`)
cannot be expressed in the raw-bytes layout; the codegen drops the
whole struct and leaves an `Unsupported type` comment behind so callers
see why the symbol they expected is missing.

Definition at line 401 of file test_codegen.py.

References _emit().

Variable Documentation

◆ _bits128

test_codegen._bits128 = types.BitsType("bits128", 128)
protected

Definition at line 59 of file test_codegen.py.

◆ _HARNESS_DIR

test_codegen._HARNESS_DIR = Path(__file__).parent
protected

Definition at line 31 of file test_codegen.py.

◆ _sint128

test_codegen._sint128 = types.SIntType("si128", 128)
protected

Definition at line 63 of file test_codegen.py.

◆ _sint16

test_codegen._sint16 = types.SIntType("si16", 16)
protected

Definition at line 50 of file test_codegen.py.

◆ _sint24

test_codegen._sint24 = types.SIntType("si24", 24)
protected

Definition at line 51 of file test_codegen.py.

◆ _sint32

test_codegen._sint32 = types.SIntType("si32", 32)
protected

Definition at line 52 of file test_codegen.py.

◆ _sint5

test_codegen._sint5 = types.SIntType("si5", 5)
protected

Definition at line 47 of file test_codegen.py.

◆ _sint64

test_codegen._sint64 = types.SIntType("si64", 64)
protected

Definition at line 53 of file test_codegen.py.

◆ _sint7

test_codegen._sint7 = types.SIntType("si7", 7)
protected

Definition at line 48 of file test_codegen.py.

◆ _sint8

test_codegen._sint8 = types.SIntType("si8", 8)
protected

Definition at line 49 of file test_codegen.py.

◆ _sint96

test_codegen._sint96 = types.SIntType("si96", 96)
protected

Definition at line 62 of file test_codegen.py.

◆ _TRANSFORM_LIST_BULK_WIDTH

int test_codegen._TRANSFORM_LIST_BULK_WIDTH = 16
protected

Definition at line 521 of file test_codegen.py.

◆ _TRANSFORM_LIST_ITEMS_PER_FRAME

int test_codegen._TRANSFORM_LIST_ITEMS_PER_FRAME = 1
protected

Definition at line 522 of file test_codegen.py.

◆ _TRANSFORM_LIST_STRUCT

test_codegen._TRANSFORM_LIST_STRUCT = StructType([("data", List(TransformListItem))])
protected

Definition at line 529 of file test_codegen.py.

◆ _transform_list_window

test_codegen._transform_list_window
protected
Initial value:
1= Window.serial_of(_TRANSFORM_LIST_STRUCT,
2 _TRANSFORM_LIST_BULK_WIDTH,
3 _TRANSFORM_LIST_ITEMS_PER_FRAME)

Definition at line 530 of file test_codegen.py.

◆ _uint1

test_codegen._uint1 = types.UIntType("ui1", 1)
protected

Definition at line 37 of file test_codegen.py.

◆ _uint12

test_codegen._uint12 = types.UIntType("ui12", 12)
protected

Definition at line 42 of file test_codegen.py.

◆ _uint128

test_codegen._uint128 = types.UIntType("ui128", 128)
protected

Definition at line 61 of file test_codegen.py.

◆ _uint16

test_codegen._uint16 = types.UIntType("ui16", 16)
protected

Definition at line 43 of file test_codegen.py.

◆ _uint2

test_codegen._uint2 = types.UIntType("ui2", 2)
protected

Definition at line 38 of file test_codegen.py.

◆ _uint24

test_codegen._uint24 = types.UIntType("ui24", 24)
protected

Definition at line 44 of file test_codegen.py.

◆ _uint3

test_codegen._uint3 = types.UIntType("ui3", 3)
protected

Definition at line 39 of file test_codegen.py.

◆ _uint32

test_codegen._uint32 = types.UIntType("ui32", 32)
protected

Definition at line 45 of file test_codegen.py.

◆ _uint64

test_codegen._uint64 = types.UIntType("ui64", 64)
protected

Definition at line 46 of file test_codegen.py.

◆ _uint7

test_codegen._uint7 = types.UIntType("ui7", 7)
protected

Definition at line 40 of file test_codegen.py.

◆ _uint8

test_codegen._uint8 = types.UIntType("ui8", 8)
protected

Definition at line 41 of file test_codegen.py.

◆ _uint96

test_codegen._uint96 = types.UIntType("ui96", 96)
protected

Definition at line 60 of file test_codegen.py.

◆ _WINDOW_PROBE_BULK_WIDTH

int test_codegen._WINDOW_PROBE_BULK_WIDTH = 16
protected

Definition at line 595 of file test_codegen.py.

◆ _WINDOW_PROBE_ITEMS

list test_codegen._WINDOW_PROBE_ITEMS = [10, 20, 30, 40]
protected

Definition at line 594 of file test_codegen.py.

◆ _WINDOW_PROBE_ITEMS_PER_FRAME

int test_codegen._WINDOW_PROBE_ITEMS_PER_FRAME = 1
protected

Definition at line 596 of file test_codegen.py.

◆ _window_probe_struct

test_codegen._window_probe_struct
protected
Initial value:
1= StructType([("tag", Bits(16)),
2 ("items", List(Bits(32)))])

Definition at line 597 of file test_codegen.py.

◆ _WINDOW_PROBE_TAG

int test_codegen._WINDOW_PROBE_TAG = 0xCAFE
protected

Definition at line 593 of file test_codegen.py.

◆ _window_probe_window

test_codegen._window_probe_window
protected
Initial value:
1= Window.serial_of(_window_probe_struct,
2 _WINDOW_PROBE_BULK_WIDTH,
3 _WINDOW_PROBE_ITEMS_PER_FRAME)

Definition at line 599 of file test_codegen.py.

◆ ArrayArg

int test_codegen.ArrayArg = SInt(8) * 1

Definition at line 486 of file test_codegen.py.

◆ ArrayResult

test_codegen.ArrayResult = TypeAlias(SInt(8) * 2, "ArrayResult")

Definition at line 487 of file test_codegen.py.

Referenced by test_codegen.TypedFuncArrayResult.construct().

◆ bsp

test_codegen.bsp = get_bsp(sys.argv[2] if len(sys.argv) > 2 else None)

Definition at line 882 of file test_codegen.py.

◆ RecvI0

test_codegen.RecvI0 = Bundle([BundledChannel("recv", ChannelDirection.TO, Bits(0))])

Definition at line 29 of file test_codegen.py.

◆ RecvI8

test_codegen.RecvI8 = Bundle([BundledChannel("recv", ChannelDirection.TO, Bits(8))])

Definition at line 27 of file test_codegen.py.

◆ requires_cmake

test_codegen.requires_cmake
Initial value:
1= pytest.mark.skipif(shutil.which("cmake") is None,
2 reason="cmake not available")

Definition at line 33 of file test_codegen.py.

◆ s

test_codegen.s = System(bsp(Top), name="TestCodegen", output_directory=sys.argv[1])

Definition at line 883 of file test_codegen.py.

◆ SendI0

test_codegen.SendI0 = Bundle([BundledChannel("send", ChannelDirection.FROM, Bits(0))])

Definition at line 28 of file test_codegen.py.

◆ SendI8

test_codegen.SendI8 = Bundle([BundledChannel("send", ChannelDirection.FROM, Bits(8))])

Definition at line 26 of file test_codegen.py.