Gpo (gpo)

Design

The GPO device worker controls the GPIO pins present on an embedded platform. It is configured for general purpose output.

A block diagram representation of the implementation is given in Figure 187:

gpo block diagram.

Figure 187: gpo block diagram.

Interface

<HdlDevice Language="vhdl" Spec="gp_out-spec.xml" Version="2" Libraries='util util_prims'>

  <Property Name="NUM_OUTPUTS" Type="uChar" Parameter="true" Default="1" Description="Number of GP Outputs. The max number of GP Outputs supported is 16."/>

  <Property Name="mask_enable" Type="uChar" Writable="true" Default="0x03"
    Description="Bitfield that allows enabling or disabling the use of the
    property 'mask_data'; or input port 'data' and 'mask'. Bit 0 is the property and bit 1 is the input port.
    If a bit is a 1 then the corresponding way of controlling the GPIO pin is enabled."/>

  <Property Name="mask_data" Type="uLong" Writable="true"
    Default="0" Description="Bitfield containing the data to write the GPIO pins
    and the mask. The mask allows setting GPIO pins on or off in a single operation and
    only affects the corresponding data pin; mask bit 0 will allow for data bit 0 to be
    set. The MSW must be the mask and LSW must be the data. For example if mask_data
    = 0x00010003, the mask = 0x0001 and data = 0x0003. This would set gpo_pin[0] to 1
    and leave all other pins untouched."/>

    <Property Name="pin_state" Type="uShort" Volatile="true" Description="Current state of the GPIO pins."/>

    <StreamInterface Name="in" DataWidth="32"/>

    <Signal Output="gpo_pin" Width="NUM_OUTPUTS"/>

</HdlDevice>

Implementations

Dependencies

The dependencies to other elements in OpenCPI are:

  • assets/hdl/devices/gpo.hdl/gpo.vhd

  • assets/primitives/util_prims/set_clr/src/set_clr.vhd

  • assets/hdl/devices/gpo_em.hdl/gpo_em.vhd

Limitations

Limitations of gpo are:

  • None.

Testing

Tested platforms include xsim.

The gpo device worker unit test has two test cases and utilizes the gpo_em device emulator. Case 1 tests controlling the GPIO pins via the mask_data property and case 2 tests controlling them via the input port.

For the mask_data property and the data port, the tests that are done are: setting data bits high but not setting masks, setting data bits high and setting the appropriate mask bits high, and clearing data bits.

The gpo_em device emulator detects if the state of the GPIO pins have changed and sends the current state of the GPIO pins as message if there has been change.

The generate.py script generates the input data and generates a golden.dat file. For case 1 the input file is a 0 byte file since the input port data is ignored in this case.

The verify.py script checks that the output data matches the expected output data contained in the golden.dat files.