Converting 3bit data into 4bit but with different sample times inside simulink

I am currently developing a 100BASE-T1 Automotive Ethernet PHY model in Simulink. On the receive side, the PHY consists of the Physical Medium Attachment (PMA) and Physical Coding Sublayer (PCS). The PMA receives the serial signal stream from the channel and converts it into symbol pairs (RA, RB), which are then decoded into 3-bit code groups using a lookup table. These 3-bit values are passed through a receive-side descrambler implemented in Stateflow, which outputs rx_data[2:0] (3-bit data), pcs_rx_dv (data valid), and pcs_rx_er (error indication) at a sample time of 30 ns (33.33 MHz). The next stage must provide data to the MAC interface, which expects RXD[3:0], RX_DV, and RX_ER, requiring a conversion from a 3-bit PCS stream to a 4-bit MAC data stream.
To perform this conversion, I currently write the incoming 3-bit data into a buffer and then read the buffered bits out as 4-bit nibbles. To avoid startup underflow, output generation begins only after accumulating the first three 3-bit symbols (9 bits total) in the buffer. While this approach initially works, the buffer eventually starves when both writing and reading are performed at the same 30 ns sample rate. This occurs because 3 bits are written every 30 ns while 4 bits are read every 30 ns, resulting in an input rate of 100 Mbps and an output rate of 133.3 Mbps. As a result, buffer occupancy continuously decreases until an underflow condition is reached.
The current implementation works like this:
-pcs_rx_dv becomes true, I store the incoming 3bit rx_data into a buffer of size 12 bits
-the condition for first 4bit output from buffer is: at least 9 bits of current packets are received,there are atleast 4bits in the buffer.
it start outputting the packet bits as 4bit, but after 7 or 8 outputs, the buffer lacks 1 bit the output RX_DV becomes false which breaks the whole pipeline forward?
how can I convert 3bit data into 4bit without breaking the packet transmission?what blocks to use instead of stateflow charts

답변 (0개)

카테고리

도움말 센터File Exchange에서 WLAN Toolbox에 대해 자세히 알아보기

제품

릴리스

R2025a

질문:

u
u
2026년 6월 16일

편집:

u
u
2026년 6월 18일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by