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

 _generate_header (type_table, system_name="test_ns")
 
 _window_struct_name (hdr, window_name_suffix)
 
 test_union_basic ()
 
 test_union_with_struct_field ()
 
 test_union_ordering_among_structs ()
 
 test_union_in_struct ()
 
 test_union_planner_naming ()
 
 test_union_alias ()
 
 test_union_same_width_integrals ()
 
 test_union_field_order_preserved ()
 
 test_windowed_list_bulk_message_wrapper ()
 
 test_windowed_list_header_padding_matches_frame_width ()
 
 test_windowed_list_arrays_in_header_and_value_type ()
 
 test_windowed_list_struct_element_data_uses_pointer_to_member ()
 
 test_windowed_list_bitfield_scalar_data_uses_lambda ()
 
 test_size_assert_emitted_for_struct ()
 
 test_size_assert_emitted_for_union_and_wrappers ()
 
 test_size_assert_emitted_for_window_frames ()
 
 test_size_assert_skipped_for_unbounded_struct ()
 
 test_struct_with_void_field_commented_out ()
 
 test_union_with_void_field_commented_out ()
 
 test_nested_struct_with_void_field_size_assert ()
 
 test_all_void_struct_collapses_to_void ()
 
 test_struct_containing_window_is_skipped ()
 

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

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.
Tests for UnionType support in codegen (CppTypePlanner + CppTypeEmitter).

Function Documentation

◆ _generate_header()

test_codegen._generate_header (   type_table,
  system_name = "test_ns" 
)
protected

◆ _window_struct_name()

test_codegen._window_struct_name (   hdr,
  window_name_suffix 
)
protected
Find the generated SegmentedMessageData subclass name for a window.

Auto-names compose `{into_name}_{window_name}`, so locate the helper by its
trailing window-name suffix instead of hard-coding the full identifier.

Definition at line 20 of file test_codegen.py.

Referenced by test_windowed_list_arrays_in_header_and_value_type(), test_windowed_list_bitfield_scalar_data_uses_lambda(), test_windowed_list_bulk_message_wrapper(), test_windowed_list_header_padding_matches_frame_width(), and test_windowed_list_struct_element_data_uses_pointer_to_member().

◆ test_all_void_struct_collapses_to_void()

test_codegen.test_all_void_struct_collapses_to_void ( )
A struct whose fields are all void collapses to `void` everywhere.

The all-void inner struct must not be emitted at all, and an outer struct
that references it must comment out that field and exclude it from the
generated constructor.

Definition at line 638 of file test_codegen.py.

References _generate_header().

◆ test_nested_struct_with_void_field_size_assert()

test_codegen.test_nested_struct_with_void_field_size_assert ( )
An outer struct containing an inner struct with a void field must use
the inner struct's effective (post-void-elimination) size in its size
assertion, not the manifest's wire-format size.

Definition at line 604 of file test_codegen.py.

References _generate_header().

◆ test_size_assert_emitted_for_struct()

test_codegen.test_size_assert_emitted_for_struct ( )
Each packed struct gets a `static_assert` pinning its `sizeof`.

Definition at line 473 of file test_codegen.py.

References _generate_header().

◆ test_size_assert_emitted_for_union_and_wrappers()

test_codegen.test_size_assert_emitted_for_union_and_wrappers ( )
Unions and their padding wrapper structs each get a size assert.

Definition at line 486 of file test_codegen.py.

References _generate_header().

◆ test_size_assert_emitted_for_window_frames()

test_codegen.test_size_assert_emitted_for_window_frames ( )
Both `data_frame` and `header_frame` get size asserts inside the window.

Definition at line 500 of file test_codegen.py.

References _generate_header().

◆ test_size_assert_skipped_for_unbounded_struct()

test_codegen.test_size_assert_skipped_for_unbounded_struct ( )
Structs containing an `!esi.any` field have no static size, so no assert.

Definition at line 536 of file test_codegen.py.

References _generate_header().

◆ test_struct_containing_window_is_skipped()

test_codegen.test_struct_containing_window_is_skipped ( )
Structs that embed a WindowType field (e.g. DMA transport wrappers like
{valid: i8, client_data: <window>}) should not be emitted because the C++
window helper is a variable-size multi-frame container whose sizeof cannot
match the manifest's compact frame bit-width.

Definition at line 682 of file test_codegen.py.

References _generate_header().

◆ test_struct_with_void_field_commented_out()

test_codegen.test_struct_with_void_field_commented_out ( )
Void-typed struct fields are commented out so the header stays valid C++.

`void x;` is not a valid C++ field declaration. The codegen must instead
emit `// void x;` and exclude the field from the generated constructor.

Definition at line 549 of file test_codegen.py.

References _generate_header().

◆ test_union_alias()

test_codegen.test_union_alias ( )
A TypeAlias wrapping a union emits the union then a using alias.

Definition at line 130 of file test_codegen.py.

References _generate_header().

◆ test_union_basic()

test_codegen.test_union_basic ( )
A simple union with two scalar fields produces a C++ union.

Definition at line 33 of file test_codegen.py.

References _generate_header().

◆ test_union_field_order_preserved()

test_codegen.test_union_field_order_preserved ( )
Union fields are emitted in declaration order, not reversed.

Definition at line 159 of file test_codegen.py.

References _generate_header().

◆ test_union_in_struct()

test_codegen.test_union_in_struct ( )
A struct with a union field emits the union before the struct.

Definition at line 100 of file test_codegen.py.

References _generate_header().

◆ test_union_ordering_among_structs()

test_codegen.test_union_ordering_among_structs ( )
Unions are properly ordered with respect to struct dependencies.

Definition at line 85 of file test_codegen.py.

References _generate_header().

◆ test_union_planner_naming()

test_codegen.test_union_planner_naming ( )
The planner auto-generates deterministic names for unions.

Definition at line 119 of file test_codegen.py.

◆ test_union_same_width_integrals()

test_codegen.test_union_same_width_integrals ( )
Integrals of the same width don't need padding wrappers.

Definition at line 143 of file test_codegen.py.

References _generate_header().

◆ test_union_with_struct_field()

test_codegen.test_union_with_struct_field ( )
A union containing a struct field emits the struct before the union.

Definition at line 65 of file test_codegen.py.

References _generate_header().

◆ test_union_with_void_field_commented_out()

test_codegen.test_union_with_void_field_commented_out ( )
Void-typed union members are commented out and skip wrapper generation.

Definition at line 583 of file test_codegen.py.

References _generate_header().

◆ test_windowed_list_arrays_in_header_and_value_type()

test_codegen.test_windowed_list_arrays_in_header_and_value_type ( )
Window helpers copy array header fields and array-valued elements.

Definition at line 317 of file test_codegen.py.

References _generate_header(), and _window_struct_name().

◆ test_windowed_list_bitfield_scalar_data_uses_lambda()

test_codegen.test_windowed_list_bitfield_scalar_data_uses_lambda ( )
A window data field that is itself a non-byte-aligned int uses a lambda projection.

Definition at line 435 of file test_codegen.py.

References _generate_header(), and _window_struct_name().

◆ test_windowed_list_bulk_message_wrapper()

test_codegen.test_windowed_list_bulk_message_wrapper ( )
Bulk-encoded list windows emit a SegmentedMessageData helper.

Definition at line 191 of file test_codegen.py.

References _generate_header(), and _window_struct_name().

◆ test_windowed_list_header_padding_matches_frame_width()

test_codegen.test_windowed_list_header_padding_matches_frame_width ( )
Headers pad out to the data frame width for count-only windows.

Definition at line 279 of file test_codegen.py.

References _generate_header(), and _window_struct_name().

◆ test_windowed_list_struct_element_data_uses_pointer_to_member()

test_codegen.test_windowed_list_struct_element_data_uses_pointer_to_member ( )
Struct-typed data fields use a pointer-to-member projection, not a lambda.

Even if the struct contains a non-byte-aligned (bit-field) member, the data
field itself is a struct type, which is byte-aligned and supports
pointer-to-member projection.

Definition at line 390 of file test_codegen.py.

References _generate_header(), and _window_struct_name().

Variable Documentation

◆ _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.

◆ _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.

◆ 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.