一个简单的
代码,目的是将进来的14位宽的数据锁存并凑成32位宽的数据串行输出。串行输出格式为:第31位到24位为固定的“E4”;第23位到10位为原始进来的数据;最后十位为固定的“0101010101”。在功能
仿真时会发生一个怪现象,temp的前8位也就是“E4”没有显示,temp的后10位被X、U代替!只有中间14位(输入值为”EAA“)正常输出!如下图所示:
在用逻辑分析仪signaltap观察
信号时,更奇怪了,发现整个寄存器32位的temp竟然没有变化,始终保持某个固定值!
我猜测是quartus的
编译器将temp中的常量位给优化了,但又想不出有什么办法禁止quartus对常量寄存器做优化,所以在此向各位前辈
请教了。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity serial_out is
port (
clkin : in std_logic;
cntout:in std_logic_vector(7 downto 0); --锁存计数器,由外界控制
parallel:in std_logic_vector(13 downto 0);
serial :Put std_logic
);
end entity;
architecture behav of serial_out is
signal temp :std_logic_vector(31 downto 0);
begin
process(clkin,cntout,temp)
variable i:integer range 0 to 31;
begin
if clkin'event and clkin='1' then
if cntout=0 then
temp(9 downto 0)<="0101010101";
temp(23 downto 10)<=parallel;
temp(31 downto 24)<="11100100";
i:=31;
else
i:=i-1;
end if;
end if;
serial<=temp(i);
end process;
end behav;
此帖出自
小平头技术问答
从你给出的程序上看,应该是你程序设计上文it,基本上你设计的程序达不到你设计目的,
仔细查看你程序吧,Quartus 优化最终不会改变的设计结果的。如果你的设计结果没符合你的
期望值,关键还是程序设计不对!
一周热门 更多>