Interface 基于FPGA的输入信号边缘检测

Interface 基于FPGA的输入信号边缘检测,interface,synchronization,vhdl,fpga,spi,Interface,Synchronization,Vhdl,Fpga,Spi,我正在尝试使用4线SPI(cs、sclk、miso、mosi)连接Virtex 4(ML401)FPGA和TIVA C系列板。tiva充当主设备,FPGA充当从设备。 我能够从主机接收SPI数据,并在FPGA上的LED上显示数据(方法2)。然而, 我需要找到芯片选择信号的上升和下降转换(我的应用程序需要同步)。 我用FIFO尝试了许多方法(在模拟中效果很好),但在FPGA上不起作用,如图所示: prc_sync_cs: process(clk)

我正在尝试使用4线SPI(cs、sclk、miso、mosi)连接Virtex 4(ML401)FPGA和TIVA C系列板。tiva充当主设备,FPGA充当从设备。 我能够从主机接收SPI数据,并在FPGA上的LED上显示数据(方法2)。然而, 我需要找到芯片选择信号的上升和下降转换(我的应用程序需要同步)。 我用FIFO尝试了许多方法(在模拟中效果很好),但在FPGA上不起作用,如图所示:

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
注:spi_cs是从TIVA板输入到FPGA的异步spi芯片选择信号,而其他信号(spi_cs_s、spi_cs_ss、spi_cs_h2l、spi_cs_l2h等)是在FPGA内部创建的

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
方法1)

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
prc\u sync\u cs:进程(clk)
开始
如果(clk'事件和clk='1'),则
spi\U cs\U s方法1
这不会对
spi_cs
信号执行任何类型的时钟域交叉,因此不是可靠的电路

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
方法2 如果(spi_cs='0'或spi_cs='1'),那么在综合设计中,
这一行始终是正确的,我不希望您能够使用该行来检测边缘

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
方法3 这确实为
spi_cs
提供了时钟域交叉,总体上看起来相当不错。您在LED上看到
“10101010”
的原因是,在SPI事务开始或结束时,它们一次只在一个
clk
时段显示与此不同的内容。这可能比你用肉眼在LED上看到的要快得多

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
此外,如果spi_cs_h2l='X'或spi_cs_h2l='U'或spi_cs_h2l='Z'或spi_cs_l2h='X'或spi_cs_l2h='U'或spi_cs_l2h='Z',则
将不会转换为FPGA中的任何实际硬件,因为实际硬件没有检查
'U'
'Z'
等的方法

                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;
方法3更新
听起来像是
spi_cs
实际上处于低激活状态。您需要确保信号的初始值,如
spi_cs_s
spi_cs_ss
都是正确的。在这种情况下,我认为您应该将它们全部初始化为
'1'
,因为这似乎是
spi\u cs
的正常状态。因此,您的信号声明看起来像
信号spi\u cs\u s:std\u逻辑:='1'
。您应该能够在模拟中看到这种行为正常。

您的代码中的
clk
spi\u cs
同步,还是只是FPGA中的其他时钟?clk是FPGA的全局时钟。spi_cs是从tiva板到fpga的异步输入。我需要将spi_cs与需要检测过渡边的信号clk同步。(我编辑了我解释信号的帖子)使用xilinx chipscope或硬件逻辑分析仪看看发生了什么事情怎么样?@mbschenkel-我没有jtag调试探针。我正在使用闪存读卡器将*.ace文件下载到FPGA。嗨,杰夫。。在方法3中,所有led都已初始化为零,在led_测试过程中,我只保留了一条IF语句,说明如果spi_cs_h2l='1',则加载FPGA时,led@JagPK cs同步触发器将初始化为'0'。由于CS为“1”,它将始终检测上升沿并点亮LED。您可以尝试使用
信号spi_cs_ss:std_logic:=“1”初始化cs regs@JonathanDrolet-我的if条件指定需要检测下降沿(spi_cs_h2l)以改变LED。。因此,即使检测到上升沿,也不应改变LED。@JagPK与原始帖子相比,您似乎对该功能进行了大量修改。你能给我们看看这个过程的新代码吗?@JonathanDrolet-我在第一次评论中提到过。重新启动:使用方法3,所有led都已初始化为零,在我的帖子中提到的“led_测试”过程中,我只保留了一条IF语句,声明
如果spi_cs_h2l='1',则led
                prc_sync_cs: process(clk)
                begin
                    if (clk'event and clk = '1') then
                        spi_cs_s  <= spi_cs;
                end if; 
                end process prc_sync_cs;

                spi_cs_l2h <= not (spi_cs_s) and spi_cs;
                spi_cs_h2l <= not (spi_cs) and spi_cs_s;