Forum Discussion

c-thaler's avatar
c-thaler
Icon for Occasional Contributor rankOccasional Contributor
2 years ago
Solved

Query clock frequency in Platform Designer component

My platform designer component requires the frequency of the connected clock to derive some values from it.

Is there a way to query the clock frequency from the TCL script?

I've already tried with "get_interface_property "clock" "clockRate"" for my component's clock interface. But it is always returning 0. The clock port is connected to a IOPLL Intel FPGA IP.

  • It turns out that a "package require -exact qsys 16.1" statement breaks the "clockRate" property of the clock interface. Probably a bug.

    Fortunately, I found a simple workaround. One can use the CLOCK_RATE SYSTEM_INFO function for a parameter:

    add_parameter CLOCK_FREQ INTEGER
    set_parameter_property CLOCK_FREQ DISPLAY_NAME "CLOCK_FREQ"
    set_parameter_property CLOCK_FREQ TYPE INTEGER
    set_parameter_property CLOCK_FREQ UNITS Hertz
    set_parameter_property CLOCK_FREQ DESCRIPTION "Frequency of the clock connected to the component in Hz."
    set_parameter_property CLOCK_FREQ SYSTEM_INFO CLOCK_RATE
    set_parameter_property CLOCK_FREQ SYSTEM_INFO_ARG clk

    Note that "clk" is the name of the clock interface of the component.

    The parameter can then be read by "get_parameter_value CLOCK_FREQ" and will contain the actual frequency of the connected clock in Hz.

1 Reply

  • c-thaler's avatar
    c-thaler
    Icon for Occasional Contributor rankOccasional Contributor

    It turns out that a "package require -exact qsys 16.1" statement breaks the "clockRate" property of the clock interface. Probably a bug.

    Fortunately, I found a simple workaround. One can use the CLOCK_RATE SYSTEM_INFO function for a parameter:

    add_parameter CLOCK_FREQ INTEGER
    set_parameter_property CLOCK_FREQ DISPLAY_NAME "CLOCK_FREQ"
    set_parameter_property CLOCK_FREQ TYPE INTEGER
    set_parameter_property CLOCK_FREQ UNITS Hertz
    set_parameter_property CLOCK_FREQ DESCRIPTION "Frequency of the clock connected to the component in Hz."
    set_parameter_property CLOCK_FREQ SYSTEM_INFO CLOCK_RATE
    set_parameter_property CLOCK_FREQ SYSTEM_INFO_ARG clk

    Note that "clk" is the name of the clock interface of the component.

    The parameter can then be read by "get_parameter_value CLOCK_FREQ" and will contain the actual frequency of the connected clock in Hz.