This subtree provides the header device.h
, which contains declarations for symbols that represent device-specific information, like the clock frequency.
device.h
When a library needs to make use of device-specific information, it should only pull in the header itself, and not depend directly on any of the libraries in this directory. Instead, the symbols' definitions will be provided at link time by the executable's build rule, which should depend on exactly one of the libraries in this directory (failing to do so is Undefined Behavior).
If an executable is designed to be device-independent (i.e., obtains all of its device-specific information from device.h
), the following Meson template may be used to generate executable targets for most devices:
foreach device_name, device_lib : sw_lib_arch_core_devices executable( 'my_binary_' + device_name, sources: [...], dependencies: [ ..., device_lib, ], ) # ... endforeach
Note that this will not generate targets for some specialized devices, such as DV testbenches.
It is sometimes necessary to add a new device. The following considerations should be taken:
device_type_t
. Multiple variants of the same device (e.g., a DV testbench with different settings) may use the same device_type_t
.sw_lib_arch_core_devices
..c
file, but the targets should, ultimately, look like this:sw_lib_arch_my_dev1 = declare_dependency( link_with: static_library( 'my_dev1', sources: [ 'device_my_dev_base.c' 'device_my_dev1.c' ], ), ) sw_lib_arch_my_dev2 = declare_dependency( link_with: static_library( 'my_dev2', sources: [ 'device_my_dev_base.c' 'device_my_dev2.c' ], ), )
sw_lib_arch_core_devices
shorthand above.