请选择 进入手机版 | 继续访问电脑版

集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 985|回复: 0

iis_capture

[复制链接]
fpga_feixiang 发表于 2021-10-14 20:14:14 | 显示全部楼层 |阅读模式
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity iis_capture is
        port(
                reset                :in                std_logic;
                --iis interface
                lrclk                :in                std_logic;
                sclk                :in                std_logic;
                sdi                        :in                std_logic;
                --iis data
                data                ut        std_logic_vector(31 downto 0);
                data_rdy        ut        std_logic;
               
                test_point        ut        std_logic
        );
end iis_capture;

architecture arch_iis_capture of iis_capture is
signal lr_flag, lr_flag_temp        : std_logic;
signal iis_capture_permit                : std_logic:='0';
signal counter                                        : integer range 63 downto 0;
signal l_ch_valid, r_ch_valid        : std_logic;
signal data_num                                        : integer range 31 downto 0;

signal data_test                                : std_logic_vector(31 downto 0);

begin

process(sclk, reset)
begin
        if reset='1' then
                lr_flag <= '0';
                lr_flag_temp <= '0';
        elsif sclk'event and sclk='1' then
                lr_flag <= lrclk;
                lr_flag_temp <= lr_flag;
        end if;
end process;

iis_capture_permit <= '1' when lr_flag='0' and lr_flag_temp='1';

process(sclk, reset, iis_capture_permit)
begin
        if reset='1' then
                counter <= 0;
        elsif (sclk'event and sclk='1') and iis_capture_permit='1' then
                if counter = 63 then -- 64 sclk [0~63] per cycle
                        counter <= 0; -- counter is 0 at 64th [zeroth] sclk rising edge
                else
                        counter <= counter + 1;
                end if;
        end if;
end        process;

l_ch_valid <= '1' when counter>=0 and counter<=15 else
              '0';

r_ch_valid <= '1' when counter>=32 and counter<=47 else
              '0';

process(sclk, reset, iis_capture_permit)
begin
        if reset='1' then
                data <= X"0000_0000";
        elsif (sclk'event and sclk='1') and iis_capture_permit='1' then
                if l_ch_valid='1' or r_ch_valid='1' then
                        data(data_num) <= sdi;
                        data_test(data_num) <= sdi;
                end if;
        end if;
end process;

data_num <= 31 - counter when l_ch_valid='1' else
            47 - counter when r_ch_valid='1' else
                        0;

data_rdy <= '1' when counter=48 else
            '0';

test_point <= iis_capture_permit;
                       
end arch_iis_capture;
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-3-29 21:49 , Processed in 0.125614 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表