如何在 VHDL 中的数据样本之间切换?

How to switch between datasamples in VHDL?

我已经为我的 I2S 接口编写了代码。此接口具有 PISO 功能(并行输入和串行输出)。在我的测试台中,我添加了 2 x 24 位数据样本(左/右通道)。现在我想在这个样本和新的第二个样本之间切换(类似于:Left1、Right1、Left2、Right2、Left1、Right1)。

elsif rising_edge(BCLK) then
                PDL_BUF <= PDL1;
                PDR_BUF <= PDR1;
                READY   <= '1';
                VALID   <= '1';

                bitcounter := bitcounter + 1;       

                if bitcounter = 1 then
                    WSP <= '1';
                else 
                    WSP <= '0';

                end if;

                if bitcounter >= 0 and bitcounter <= 23 then  
                    WS <= '0';
                elsif bitcounter > 24 then -- and bitcounter <= 48 
                    WS <= '1';
                    WSP <= '0'; 

                end if;

                if WS = '0' then
                    SD <= PDL_BUF(23);
                    PDL_BUF <= PDL_BUF(22 downto 0) & '0';
                else --if WS = '1' then 
                    SD <= PDR_BUF(23);
                    PDR_BUF <= PDR_BUF(22 downto 0) & '0';

                end if;

                if bitcounter = 48 then
                    bitcounter := 0;                

                end if;
        end if;
    end process;

这是一个为两个通道重复两次的块,很明显你不能访问另一个通道。

您需要添加一个块,我们称之为合并块。 在合并块中,将两个样本都视为输入,然后您可以将它们都包含在代码中。