Question about implementing EWMA calculation in P4 data plane

24 views
Skip to first unread message

Xudong Liao

unread,
Aug 9, 2023, 12:26:45 PMAug 9
to p4-dev
Hello, 

I am currently working on a project that involves using EWMA (Exponential Weighted Moving Average) to calculate a statistical value with a register in the P4 data plane. Code snippets are shown below, but the code cannot be compiled due to the invalid expression in "update_lo_1_value" . Does anyone know how to do it in p4 data plane?

register value_record {
    width : 64;
    instance_count : 4;
}

blackbox stateful_alu alu_record_value {
    reg: value_record;
    condition_lo: register_lo == 0;
    // update the value
    update_lo_1_predicate : not condition_lo;
    update_lo_1_value : (register_lo - (register_lo >> 3)) + (new_value >>3);
    // init this value
    update_lo_2_predicate : condition_lo;
    update_lo_2_value : new_value;
}

Thanks,
Xudong

Andy Fingerhut

unread,
Aug 9, 2023, 2:00:49 PMAug 9
to Xudong Liao, p4-dev
From the source code in your question, you appear to be using a P4_14 compiler for Tofino.

You may want to consider using P4_16 instead, as recent Tofino SDEs support it perhaps even better than P4_14 is supported.

There is a fairly low limit to what your NDA permits you to ask about the Tofino SDE on public forums.

Andy

--
You received this message because you are subscribed to the Google Groups "p4-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to p4-dev+un...@lists.p4.org.
To view this discussion on the web visit https://groups.google.com/a/lists.p4.org/d/msgid/p4-dev/d6a01f54-ef00-485f-a369-74fe857cb16dn%40lists.p4.org.
Reply all
Reply to author
Forward
0 new messages