CPLD程序代码仿真出现问题,请各位大侠帮帮忙,谢谢

2019-07-16 02:05发布

Library IEEE;
USE IEEE.STD_logic_1164.all;
USE IEEE.STD_logic_unsigned.all;
ENtiTY code IS
PORT(en:in std_logic;
data  :in std_logic;
clk:in std_logic;
clr:in std_logic;
code_out  :out std_logic;
clk2x : out std_logic
);
END code;
ARCHITECTURE code OF code IS
SIGNAL clk1,clk2,mo:std_logic;
SIGNAL count_m100   :std_logic_vector(6 downto 0);
SIGNAL cnt   :std_logic_vector(2 downto 0);
SIGNAL shift_r     :std_logic_vector(2 downto 0);
begin
----------------分频器--------------------------
process(clk)
begin
       if(clk'event and clk='1')then
         cnt<=cnt+1;
       end if;
  --if(clr='1') then
   --clk2<='0';
  --elsif(en ='1')then
   --clk2<=not(clk2);
  --end if;
--end if;
end process;
clk2<=cnt(0);
clk2x<=clk2;
-------------------------------------
process(clk,en,clr)
begin
if(clr='1')then
  count_m100<="0000000";
elsif(clk'event and clk='1')then
  if(count_m100="1100011")then       --0-99 100次
   count_m100<="0000000";
  elsif(en='1')then
   count_m100<=count_m100+'1';
  end if;
end if;
end process;
---------------------------------
process(clk2,en,clr)
begin
if(clr='1')then
  shift_r<=(others=>'0');
elsif(clk2'event and clk2='1')then
  if(en='1')then
   shift_r<=shift_r(1 downto 0)&data;
  end if;
end if;
end process;

---------------------------------------------
process(clk,clk2,count_m100,en,clr,mo,shift_r)
begin
if(clr='1')then
  mo<='1';
elsif(count_m100>="0000001" and count_m100<="0000010")then  --1-2
     mo<='0';
     elsif(count_m100>="0000011" and count_m100<="1100010")then --3-98
        mo<=shift_r(2) XOR clk2;
        else
        mo<='0';
     end if;
end process;
END code;
      问题:仿真时data数据如果是0时异或不起作用,一直保持前一个状态,请各位大侠帮帮忙,再次感谢!!!!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
janly229
1楼-- · 2019-07-16 05:48
人呢?来位大侠帮帮忙,ths
lstcspring
2楼-- · 2019-07-16 10:42
shift_r(1 downto 0)&data你这个执行的结果是什么,你看没,还有你可看一下综合出来的原理图,
janly229
3楼-- · 2019-07-16 12:45
我现在主要这样试的:1、我先是用一组010101---data数据,然后观察结果跟理论分析不一样,从结果看在data是1时按照异或分析是对的,;但是如果data是0,这时候出来的结果就不对,像是在data是0时异或运算没起作用;2、于是我就让data数据全为0和全为1分别仿真,结果发现全0时输出结果全0,当data全1时仿真结果跟分析是一样的,异或运算起作用。
janly229
4楼-- · 2019-07-16 15:29
大侠们快点来,很急的!!
longcomeon
5楼-- · 2019-07-16 20:59
看不懂啊

一周热门 更多>