Skip to content

Commit

Permalink
adding documentation to user guide on enhanced packed records and arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dinkelk committed May 2, 2024
1 parent daa7e55 commit 7f95fa9
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 29 deletions.
2 changes: 1 addition & 1 deletion doc/example_architecture/array_register_set/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ begin
-- compiler will ensure that the ENTIRE register is read/written
-- during the following operations.
if Registers (1).Hw_1_Enabled = Enable and then
Registers (4).Hw_2_Enabled = Enable
Registers (4).Hw_2_Enabled = Enable
then
Registers (7).Threshold := 22;
end if;
Expand Down
8 changes: 8 additions & 0 deletions doc/example_architecture/nested_record/env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os

this_dir = os.path.dirname(os.path.realpath(__file__))
# Overwrite the normal build path mechanism and just use
# this directory as the build path. This prevents any
# name conflicts we might get from using the regular
# ".all_path".
os.environ["EXTRA_BUILD_PATH"] = this_dir + os.sep + ".."
16 changes: 16 additions & 0 deletions doc/example_architecture/nested_record/nested_record.record.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: This is an example packed record that demonstrates the nesting of other packed records within.
fields:
- name: Simple_Field
description: A simple float, we must provide a format
type: Short_Float
# Required
format: F32
- name: Nested_Field_1
description: This field is of type Example Record, which is itself a packed record definition.
type: Example_Record.T
# ^ No format specification is necessary, since the
# bit representation of a packed record is known
- name: Nested_Field_2
description: Another field of type Example Record.
type: Example_Record.T
20 changes: 14 additions & 6 deletions doc/example_architecture/record_conversion/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ with Example_Record;

procedure Main is
use Example_Record;
-- A packed version of the type.
Packed_Type : Example_Record.T := (Value_1 => 2, Value_2 => -1, Value_3 => Green, Value_4 => 0.5);
-- A packed big-endian version of the type.
Packed_Be_Type : Example_Record.T := (Value_1 => 2, Value_2 => -1, Value_3 => Green, Value_4 => 0.5);
-- A packed little-endian version of the type.
Packed_Le_Type : Example_Record.T_Le;
-- An unpacked version of the type.
Unpacked_Type : Example_Record.U;
begin
-- Convert from packed to unpacked:
Unpacked_Type := U (Packed_Type);
-- Convert from unpacked to packed:
Packed_Type := T (Unpacked_Type);
-- Convert from big-endian packed to unpacked:
Unpacked_Type := Unpack (Packed_Be_Type);
-- Convert from unpacked to big-endian packed:
Packed_Be_Type := Pack (Unpacked_Type);
-- Convert from big-endian to little-endian:
Packed_Le_Type := Swap_Endianness (Packed_Be_Type);
-- Convert from little-endian to big-endian:
Packed_Be_Type := Swap_Endianness (Packed_Le_Type);
-- Convert from little-endian packed to unpacked:
Unpacked_Type := Unpack (Packed_Le_Type);
end Main;
Binary file modified doc/user_guide/user_guide.pdf
Binary file not shown.
Loading

0 comments on commit 7f95fa9

Please sign in to comment.