Home › Practice › RTL Design › 2-stage pipelined mid-price check
2-stage pipelined mid-price check
MediumRTLHFTsequentialpipelining
To keep high clock speed (throughput) when computing a mid-price (bid + ask) / 2 and checking it against a risk limit, split the work across two pipeline stages.
Concept first. In Stage 1 (cycle 1), add bid + ask into a 9-bit sum (so two 8-bit prices up to 255 never overflow!) and take the integer average sum[8:1], while passing valid and limit into pipeline registers. In Stage 2 (cycle 2), compare the registered mid-price against the registered limit and drive ok_v and ok. After passing, click Check area and speed to inspect the OpenSTA clock speed.
rstis synchronous, active-high: clears all pipeline registers and outputs (ok_v,ok) to 0.ok_vequalsvaliddelayed by 2 clock cycles (0 for the first 2 cycles after reset).okequals 1 on cyclet+2if and only if at cyclet(after reset)valid=1and((bid + ask) >> 1) <= limit(using exact 9-bit sum).
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.