Step 2: How to Specify the FPGA Functionality

Objective

Modeling the FPGA functionality in Simulink.


Method: To specify the FPGA functionality

  1. Implement the PI-controlled system with blocks from the HDL library of the AMD Vitis Model Composer.

    The following table shows the the blocks used and the specified values of their block properties. The same controller is used in the DemoFPGApipt1 demo model.

    HDL Block

    Name

    Set Block Properties1)

    AddSub

    AddSub

    • Operation: Subtraction

    • Latency: 2

    AddSub1

    Latency: 2

    AddSub2

    Basic page:

    • Latency: 0

    Output page:

    • Precision: User Defined

    • Arithmetic type: Signed (2's comp)

    • Number of bits: 64

    • Binary point: 40

    Constant

    Kp_const

    • Constant value: 3.2351

    • Arithmetic type: Unsigned

    • Number of bits: 32

    • Binary point: 18

    Ki_const

    • Constant value: 3000

    • Arithmetic type: Unsigned

    • Number of bits: 32

    • Binary point: 18

    CMult

    CMult

    • Constant value: 10e-9

    • Number of bits: 48

    • Binary point: 48

    • Latency: 3

    Mult

    Mult

    Latency: 6

    Mult1

    Latency: 6

    Register

    Register

    ‑

    1. Keep the default values for all other block properties.

    Tip

    Press Ctrl + D from time to time to update the diagram. This helps you to detect modeling errors early.

    Check if the messages are plausible. Error messages due to open inputs at the AddSub blocks can be ignored, for example.

  2. From the FPGA Interface sublibrary of the FPGA Programming Blockset, add an FPGA_IO_WRITE_BL block to the model.

    The FPGA_IO_WRITE_BL block lets you access an I/O channel to output the controlled variable.

  3. Double-click the block to open the block dialog.

    The block dialog opens.

  4. Configure the block parameters to access an analog output channel.

    Dialog Page

    Set Parameter1)

    Unit

    I/O type: Analog_Mod_1

    Select Analog Out - Ch: 17 [Mod: 1]

    Parameters

    Scaling: mV

    1. Keep the default values for all other block parameters.

  5. Click OK.

    The block display changes.

  6. Add an FPGA_IO_READ_BL block to the model.

    The FPGA_IO_READ_BL block lets you read the actual value of the controlled system from an analog input channel.

  7. Open the block dialog and configure the parameters to access an analog input channel.

    Dialog Page

    Set Parameter1)

    Unit page

    I/O type: Analog_Mod_1

    Select Analog In - Ch: 23 [Mod: 1].

    Parameters page

    Input range: -10V..+10V

    Scaling: mV

    1. Keep the default values for all other block parameters.

    The block display changes.

  8. Add an FPGA_XDATA_READ_BL block to the model and configure the parameters of the block dialog.

    Dialog Page

    Set Parameter1)

    Unit page

    Access type: Register

    Channel name: Set point

    Parameters page

    –

    1. Keep the default values for all other block parameters.

    The FPGA_XDATA_READ_BL block lets you read data values from an application running on the real-time processor.

  9. Connect the added blocks as shown in the following illustration. Terminate the Data New ports of the register and analog input blocks with AMD Terminator blocks.


Result

You modeled the FPGA functionality in Simulink.

To keep the model clear, you can place the controller in a subsystem:

  • Select all AMD blocks.

  • Press Ctrl+G to create a subsystem from the selection.

  • Open the subsystem and rename the inports and outports.

  • Press Ctrl+S to save the model.


Next step


Redaction