集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 3255|回复: 6

MAXPLUS II编译时LOOP语句的使用

[复制链接]
CHAN 发表于 2010-6-28 00:36:20 | 显示全部楼层 |阅读模式
本帖最后由 fpgaw 于 2010-7-6 05:23 编辑

在PROCESS中使用EXIT语句可以吗?如下例
lp1: FOR i IN 0 TO 7 LOOP
    IF inp(i)='1' THEN inp(i )<='0';
    ELSE inp(i)<='1';EXIT lp;
   END IF;
END LOOP;
可使用MAXPLUS II编译时为什么总出错?
HDL 发表于 2010-6-28 00:54:44 | 显示全部楼层
好像exit只能跳出本循环语句lp1
HDL 发表于 2010-6-28 02:34:05 | 显示全部楼层
谢谢!<br>
我是想退出LP1,但问题是编译时给出如下的错误信息:<br>
&nbsp;&nbsp;Unsupported feature error:a next or an exit statement is supported only in an uncomditional loop.<br>
我不明白是MAXPLUS本来就不支持这种写法,还是我的MAXPLUSII有问题?
CCIE 发表于 2010-6-28 03:42:52 | 显示全部楼层
lp1: FOR i IN 0 TO 7 LOOP<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; IF inp(i)='1' THEN inp(i )&lt;='0';<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; ELSE inp(i)&lt;='1';&nbsp;&nbsp;EXIT lp1;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;END IF;<br>
&nbsp;&nbsp;END LOOP;<br>
不是你的防真器出错你的exit后面应该是lp1,那样你只执行一次循环,你想执行什么功能啊<br>
如果想跳出本次循环那就用关键字next。
inter 发表于 2010-6-28 04:44:47 | 显示全部楼层
想实现补码的转换,实际上主要是想看看LOOP语句的用法。源代码全文如下:<br>
LIBRARY IEEE;<br>
USE IEEE.Std_logic_1164.ALL;<br>
ENTITY inve IS<br>
&nbsp; &nbsp; &nbsp; &nbsp; PORT(inp:IN Std_logic_vector(7 DOWNTO 0);<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qout:OUT Std_logic_vector(7 DOWNTO 0));<br>
END inve;<br>
ARCHITECTURE str OF inve IS<br>
BEGIN<br>
<br>
PROCESS(inp)<br>
&nbsp; &nbsp; VARIABLE&nbsp;&nbsp;n_inp:std_logic_vector(7 DOWNTO 0);<br>
BEGIN<br>
&nbsp; &nbsp;&nbsp;&nbsp;n_inp:=inp;<br>
&nbsp; &nbsp; IF (inp(7)='1') THEN <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; FOR I IN 7 DOWNTO 0 LOOP<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n_inp(I):=NOT n_inp(I);<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; END LOOP;&nbsp; &nbsp; &nbsp; &nbsp; --最高位为&lsquo;1&rsquo;,取反<br>
Loop1:FOR I IN 0 TO 7 LOOP<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF (n_inp(I)='1' )THEN n_inp(I):='0';<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ELSE n_inp(I):='1';&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;EXIT loop1;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; END IF;<br>
&nbsp; &nbsp;&nbsp; &nbsp;END LOOP;&nbsp; &nbsp; &nbsp; &nbsp; --末位加&lsquo;1&rsquo;<br>
&nbsp; &nbsp;END IF;<br>
&nbsp; &nbsp; &nbsp; &nbsp; qout&lt;=n_inp;<br>
END PROCESS;<br>
END str;<br>
<br>
谢谢指教!!!
usb 发表于 2010-6-28 06:04:45 | 显示全部楼层
EXIT loop1;你的循环标志号要和前面的一样<br>
<br>
LIBRARY IEEE;<br>
USE IEEE.Std_logic_1164.ALL;<br>
ENTITY inve IS<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbspORT(inp:IN Std_logic_vector(7 DOWNTO 0);<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; qout:OUT Std_logic_vector(7 DOWNTO 0));<br>
END inve;<br>
ARCHITECTURE str OF inve IS<br>
BEGIN<br>
<br>
PROCESS(inp)<br>
&nbsp; &nbsp; VARIABLE&nbsp;&nbsp;n_inp:std_logic_vector(7 DOWNTO 0);<br>
BEGIN<br>
&nbsp; &nbsp;&nbsp;&nbsp;n_inp:=inp;<br>
&nbsp; &nbsp; IF (inp(7)='1') THEN <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; FOR I IN 7 DOWNTO 0 LOOP<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;n_inp(I):=NOT n_inp(I);<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; END LOOP;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;--最高位为&lsquo;1&rsquo;,取反<br>
Loop1:FOR I IN 0 TO 7 LOOP<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; IF (n_inp(I)='1' )THEN n_inp(I):='0';<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; ELSE n_inp(I):='1'; EXIT Loop1;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;END IF;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>
&nbsp; &nbsp;&nbsp; &nbsp;END LOOP;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;--末位加&lsquo;1&rsquo;<br>
&nbsp; &nbsp;END IF;<br>
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;qout&lt;=n_inp;<br>
END PROCESS;<br>
END str;<br>
这样就可以了
encounter 发表于 2010-6-28 06:46:47 | 显示全部楼层
不过你这个补码程序有错误!!完成不了补码功能,自己找找呵呵<br>
对你有好处!!
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2024-12-24 03:16 , Processed in 0.064389 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表