打印

求有经验者帮忙回答个问题

[复制链接]
1395|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wxfxwk1986|  楼主 | 2011-4-11 10:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我是看别人的代码中有这样一个进程,有点疑问:
process(TXCLK,reset,busy,SAMPLE)
  begin
  if(falling_edge(TXCLK)) then
   if(reset = '1') then
    i_counter <= (others => '0');
    start <= '1';
   elsif(busy = '0') then
    i_counter <= i_counter + '1';
    start <= '1';
    IF(SAMPLE = "110") THEN               -- 96K
     if(i_counter = "0011110") then     -- 30
      i_counter <= i_counter;
     elsif(i_counter = "0011101") then  -- 29
      i_ping_pong <= not i_ping_pong;
     end if;
    ELSE
     if(i_counter = "1000010") then     --66
      i_counter <= i_counter;
     elsif(i_counter = "1000001") then  --65
      i_ping_pong <= not i_ping_pong;
     end if;
    END IF;
   else
    start <= '0';
   end if;
  end if;
end process;
按这种写法的话,当i_counter=66时,前面的语句是执行+1操作,后面的是进行了保持的操作,请问这样有问题吗?求解释。谢谢!

相关帖子

沙发
wxfxwk1986|  楼主 | 2011-4-11 10:33 | 只看该作者
我自己改了下,大家帮我看看这样改可以吗?
process(txclk)
         begin
          if(falling_edge(txclk))  then
             if(reset='1')  then
               i_counter <= (others => '0');
               start <= '1';
             elsif(busy ='0')  then
               start <= '1';
               if(sample="110") then   --96k
                  if(i_counter ="0011110")  then  --30
                    i_counter <= i_counter;
                  else
                          i_counter <= i_counter + 1 ;
                          if(i_counter = "0011101") then  --29
                                                i_ping_pong <= not i_ping_pong;
                                        end if;
                                 end if;
                        else
                                if(i_counter = "1000010") then     --66
                                                i_counter <= i_counter;
                                else
                                        i_counter <= i_counter + 1 ;
                          if(i_counter = "1000001") then  --65
                                                i_ping_pong <= not i_ping_pong;
                                        end if;
                     end if;
                   end if;
                  else
                           start <='0';
                  end if;
                 end if;
                end process;

使用特权

评论回复
板凳
sxhhhjicbb| | 2011-4-11 19:40 | 只看该作者
当i_counter=66时,前面的语句是执行+1操作,后面的是进行了保持的操作,请问这样有问题吗?
这样没有问题,在二次复位,初始化外设的电路中经常要和到保持操作.
上电时对外设初始化,然后FPGA程序再也不会去初始化外设了.有这种应用的.

使用特权

评论回复
地板
wxfxwk1986|  楼主 | 2011-4-12 10:18 | 只看该作者
当i_counter=66时,前面的语句是执行+1操作,后面的是进行了保持的操作,请问这样有问题吗?
这样没有问题,在二次复位,初始化外设的电路中经常要和到保持操作.
上电时对外设初始化,然后FPGA程序再也不会去初始化外设 ...
sxhhhjicbb 发表于 2011-4-11 19:40

谢谢你的回答。我是这样觉得:语法上是没有问题,但我总感觉是不是别扭,是不是用下面的我改过的描述更合适呢?改的程序在2楼

使用特权

评论回复
5
sxhhhjicbb| | 2011-5-7 12:20 | 只看该作者
2楼的程序可读性更强。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

250

帖子

1

粉丝