刚学VHDL的新手求教一段程序

2019-03-25 10:20发布

有a,b,c,d四个输入数据,首先让A0=0,A1=0时输出y<=a,然后使WR置0(写输入有效,送出y), 接着再进行计数延时(计数十次,确保数据接收完整),延时完成后使WR置0(关闭通道);再接着让A0=0,A1=1,输出y<=b,用上述流程完成四个数据的依次接收(完成四次即可,不用循环接收)。( 一个四选一选择器连接  一个计十次的计数器  再与一个四通道芯片连接  A0,A1为选择器和芯片的功用片选端)
entity control is
  port(a,b,c,d:in std_logic_vector(7 downto 0);
           A0,A1:in std_logic;
                clk:in std_logic;
            out_y:out std_logic_vector(7 downto 0);
                   y:buffer std_logic_vector(7 downto 0));
end control;
architecture behave of control is
     signal Aaa:std_logic_vector(1 downto 0);
begin
                  Aaa<=A1&A0;
process(a,b,c,d,A,clk)
  variable temp:std_logic_vector(3 downto 0);
  variable en:std_logic:='0';
begin

if  clk'event and clk='1' then
    if Aaa="00" then
         y<=a;  
          if en='0' then
                  if  temp<10 then
                         temp:=temp+1;
                else temp:=(others=>'0');
                end if;
                    en:='1';
           end if;
      end if;
    if Aaa="01" then
        y<=b;
          if en='0' then
                  if  temp<10 then
                         temp:=temp+1;
                else temp:=(others=>'0');
                end if;
                    en:='1';
           end if;
      end if;
    if Aaa="10" then
        y<=c;
          if en='0' then
                  if  temp<10 then
                         temp:=temp+1;
                else temp:=(others=>'0');
                end if;
                    en:='1';
           end if;
       end if;
    if Aaa="11" then
           y<=d;
          if en='0' then
                  if  temp<10 then
                         temp:=temp+1;
                else temp:=(others=>'0');
                end if;
                    en:='1';
           end if;
      end if;
end if;
      out_y<=y;
   end process;
end behave;

上面是自己编的一段部分功能(验证能否延时)的程序,结果好像延时不了,请问是不是计数部分出问题了???还有如何使A1,A0依次为00,01,10,11?? 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
5条回答
zimao1988
1楼-- · 2019-03-25 18:27
< / 程序中的out_y是用来观察时序图中有无延时效果的!!
eeleader
2楼-- · 2019-03-25 19:43
新手建议用状态机搞,这样看起来更简洁!
eeleader
3楼-- · 2019-03-25 21:09
从你的程序看,是没有达到你所说的设计效果的。 所有的状态触发都由条件控制if(Aaa="00")
zimao1988
4楼-- · 2019-03-26 01:45
 精彩回答 2  元偷偷看……
eeleader
5楼-- · 2019-03-26 04:34
我不是说了吗,你的延时语句没作用,是因为所有的状态触发都由条件控制if(Aaa="00")这个语句的问题,知道了吗?

一周热门 更多>