Vhdl 不模拟的数组数组
我正在创建一个非常简单的SPI从设备作为更大设备的一部分,并希望对SPI数据进行反序列化。我的架构如下所示:Vhdl 不模拟的数组数组,vhdl,Vhdl,我正在创建一个非常简单的SPI从设备作为更大设备的一部分,并希望对SPI数据进行反序列化。我的架构如下所示: library IEEE; use IEEE.std_logic_1164.all; use IEEE.numeric_std.all; entity controller is port ( CLK : in std_logic; MOSI : in std_logic; nC
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;
entity controller is
port (
CLK : in std_logic;
MOSI : in std_logic;
nCS : in std_logic;
SCLK : in std_logic;
OUTPUT_DATA_EN : out std_logic;
OUTPUT_DATA : out std_logic_vector (31 downto 0);
nRST : in std_logic
);
end controller;
architecture BEH of controller is
signal SCLK_PREV : std_logic;
signal nCS_PREV : std_logic;
type sr8x8 is array(0 to 7) of std_logic_vector(7 downto 0);
signal BIT_SHIFT_REG : std_logic_vector(7 downto 0);
signal BITS_RECEIVED : unsigned(3 downto 0);
signal SHIFT_REG : sr8x8;
signal BYTES_RECEIVED : unsigned (7 downto 0);
begin
process(CLK)
begin
if rising_edge(CLK) then
if nRST = '0' then
BIT_SHIFT_REG <= (others => '0');
SHIFT_REG <= (others => (others => '0'));
BITS_RECEIVED <= (others => '0');
BYTES_RECEIVED <= (others => '0');
OUTPUT_DATA <= (others => '0');
OUTPUT_DATA_EN <= '0';
else
if nCS = '1' then
BIT_SHIFT_REG <= (others => '0');
SHIFT_REG <= (others => (others => '0'));
BITS_RECEIVED <= (others => '0');
BYTES_RECEIVED <= (others => '0');
end if;
if nCS = '0' and SCLK_PREV = '0' and SCLK = '1' then
BIT_SHIFT_REG(7 downto 1) <= BIT_SHIFT_REG(6 downto 0);
BIT_SHIFT_REG(0) <= MOSI;
BITS_RECEIVED <= BITS_RECEIVED + 1;
end if;
if nCS = '0' and SCLK_PREV = '1' and SCLK = '0' then
if BITS_RECEIVED = 8 then
SHIFT_REG(to_integer(BYTES_RECEIVED)) <= BIT_SHIFT_REG;
BITS_RECEIVED <= X"0";
BYTES_RECEIVED <= BYTES_RECEIVED + 1;
end if;
end if;
if nCS_PREV = '0' and nCS = '1' then
if SHIFT_REG(0) = X"00" then
OUTPUT_DATA(31 downto 24) <= SHIFT_REG(1);
OUTPUT_DATA(23 downto 16) <= SHIFT_REG(2);
OUTPUT_DATA(15 downto 8) <= SHIFT_REG(3);
OUTPUT_DATA(7 downto 0) <= SHIFT_REG(4);
OUTPUT_DATA_EN <= '1';
end if;
end if;
SCLK_PREV <= SCLK;
nCS_PREV <= nCS;
end if;
end if;
end process;
end BEH;
我是否在做一些对合成和/或模拟无效的事情?我有一些代码,其计算结果就像正确的值存储在SHIFT\u REG
中一样,但内容从未显示在模拟器中
编辑:如果灵敏度列表简化为
过程(CLK)
,问题仍然存在。从灵敏度列表中删除所有不需要的内容-同步重置只需要时钟:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity controller is
end entity;
architecture foo of controller is
type sr8x8 is array(0 to 7) of std_logic_vector(7 downto 0);
signal SHIFT_REG : sr8x8;
signal BYTES_RECEIVED : unsigned (7 downto 0);
signal clk: std_logic := '0';
signal nRST: std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if nRST = '0' then
SHIFT_REG <= (others => (others => '0'));
BYTES_RECEIVED <= (others => '0');
end if;
end if;
end process;
CLOCK:
process
begin
wait for 10 ns;
clk <= not clk;
if Now > 100 ns then
wait;
end if;
end process;
STIMULUS:
process
begin
wait for 20 ns;
nRST <= '0';
wait for 20 ns;
nRST <= '1';
wait for 60 ns;
wait;
end process;
end architecture;
其中:
因此,正如我们所看到的,重置数组只需要CLK
和nRST
出于模拟的目的,我在您的VHDL设计描述中没有看到任何东西会阻止您至少获得SHIFT\u REG
和BYTES\u接收的重置
Altium Designer的用户文档和设计流程对第三方不易获得,Aldec Active HDL的用户文档也不易获得。从您的设计描述或叙述中几乎没有什么洞察
您最好联系Altium支持部门,该部门可能会为您提供Aldec支持服务 首先,根据您的目标技术和合成工具,阵列阵列可能会合成为某种内存块。你可能无法以你正在尝试的方式重置这些记忆。检查工具的文档和合成结果
对于模拟器:根据您发布的代码,一切都应该正常工作。我最好的猜测是,还有另一个进程驱动着SHIFT\u REG
。即使你认为你没有在这个过程中触发任务,它仍然在驱动“U”。与此过程中的“0”一起,它仍然解析为“U”。这可能没有帮助,但您可以大幅减少敏感度列表-您需要的只是CLK
。合成工具生成了关于没有列出其他信号的警告,因此我添加了它们。我最初只是使用CLK,因为对我来说,进程应该只在CLK事件上运行是有道理的。我一回到那台计算机就会尝试。合成工具不应该生成这些警告,除非你没有发布的代码部分有其他错误(或者它不是一个很好的合成工具)。我从灵敏度列表中删除了所有内容,除了CLK
。我必须已经修复了一些代码,因为它不再抱怨灵敏度列表中缺少信号,但是,我仍然在模拟中得到未定义的值。我将Altium与Aldec OEM模拟器一起使用。很难假设过程中的两个“…”区域代表了什么,但任何非同步分配都将遵循两端ifs。这听起来像是在流程之外的某个地方有额外的驱动程序。显示更多代码。我已添加完整代码。有些东西我不认为合成得特别好,但我认为它们都是有效的,所以在我开始优化之前,我试图解决模拟问题。似乎SHIFT\u REG
中的数据是有效的,因为当nCS
变高时,OUTPUT\u data
是好的。我添加了完整的代码。当nCS
变高时,OUTPUT\u data
中的数据显示有效,因此SHIFT\u REG
在传输到OUTPUT\u data
时具有有效内容。当nCS
变高时,OUTPUT\u data
获取SHIFT\u REG
在上一时钟节拍上的值。你的代码看起来不错,但现在已经相当大了。我们不知道输入信号是什么,因此无法从我们所处的位置进行调试。请考虑做一个VETSMOD的例子。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity controller is
end entity;
architecture foo of controller is
type sr8x8 is array(0 to 7) of std_logic_vector(7 downto 0);
signal SHIFT_REG : sr8x8;
signal BYTES_RECEIVED : unsigned (7 downto 0);
signal clk: std_logic := '0';
signal nRST: std_logic;
begin
process(clk)
begin
if rising_edge(clk) then
if nRST = '0' then
SHIFT_REG <= (others => (others => '0'));
BYTES_RECEIVED <= (others => '0');
end if;
end if;
end process;
CLOCK:
process
begin
wait for 10 ns;
clk <= not clk;
if Now > 100 ns then
wait;
end if;
end process;
STIMULUS:
process
begin
wait for 20 ns;
nRST <= '0';
wait for 20 ns;
nRST <= '1';
wait for 60 ns;
wait;
end process;
end architecture;
library ieee;
use ieee.std_logic_1164.all;
entity tb is
end entity;
architecture foo of tb is
signal clk: std_logic := '0';
signal mosi: std_logic;
signal nCS: std_logic;
signal sclk: std_logic;
signal output_data_en: std_logic;
signal output_data: std_logic_vector (31 downto 0);
signal nRST: std_logic;
begin
DUT:
entity work.controller
port map (
clk => clk,
mosi => mosi,
nCS => nCS,
sclk => sclk,
output_data_en => output_data_en,
output_data => output_data,
nRST => nRST
);
CLOCK:
process
begin
wait for 10 ns;
clk <= not clk;
if Now > 100 ns then
wait;
end if;
end process;
STIMULUS:
process
begin
wait for 20 ns;
nRST <= '0';
wait for 20 ns;
nRST <= '1';
wait for 60 ns;
wait;
end process;
end architecture;