分页: 2 / 2
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 12:47
由 wangjingchu
trigger 写了:你见过在for循环里面手动设置指针的?count已经迭代了,用不着那一行,删掉吧。
说实话,我根本没看懂你要干什么。
还有一个问题,原文件是这样的
想在
a: begin后面插入 //case 1
b: begin后面插入//case 2
...
一直到最后一个x:begin后插入//case n
这个应该怎么实现啊
原文如下
代码: 全选
case (stato)
a: begin
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=0;
end
e: begin
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=1;
end
b: begin
if (line1 && line2) stato=g;
else stato=c;
outp<=line1^line2;
overflw<=0;
end
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 13:05
由 wangjingchu
要插入//case n 的那些行的特点就是都有“: begin”
但是得按顺序来插入,不知道怎么弄哇
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 14:01
由 trigger
[bash]i=1
while read line ;do
((`echo $line|grep -c :`>0))&&echo $line "//case $i"&&let i++||echo $line
done<lines[/bash]
case (stato)
a: begin //case 1
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=0;
end
e: begin //case 2
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=1;
end
b: begin //case 3
if (line1 && line2) stato=g;
else stato=c;
outp<=line1^line2;
overflw<=0;
end
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 14:19
由 trigger
原格式输出
[bash]
#! /bin/bash
#sh018.sh
i=1
while IFS=# read "line" ;do
((`echo $line|grep -c :`>0))&&echo -e "$line" "//case $i"&&let i++||echo -e "$line"
done<lines
[/bash]
./sh018.sh
./sh018.sh
代码: 全选
case (stato)
a: begin //case 1
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=0;
end
e: begin //case 2
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=1;
end
b: begin //case 3
if (line1 && line2) stato=g;
else stato=c;
outp<=line1^line2;
overflw<=0;
end
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 14:28
由 wangjingchu
trigger 写了:原格式输出
[bash]
#! /bin/bash
#sh018.sh
i=1
while IFS=# read "line" ;do
((`echo $line|grep -c :`>0))&&echo -e "$line" "//case $i"&&let i++||echo -e "$line"
done<lines
[/bash]
./sh018.sh
./sh018.sh
代码: 全选
case (stato)
a: begin //case 1
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=0;
end
e: begin //case 2
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=1;
end
b: begin //case 3
if (line1 && line2) stato=g;
else stato=c;
outp<=line1^line2;
overflw<=0;
end
我这里输回不了有原文件里啊,这里只能在终端里显示这个
代码: 全选
always @(posedge clock)
begin
if (reset)
begin
stato=a;
outp<=0;
overflw<=0;
end
else
//------------------------------------------------
//Start of a state machine for (stato)
//Case 1: //case 2
//Case 2: //case 3
//Case 3: //case 4
//Case 4: //case 5
//Case 5: //case 6
//Case 6: //case 7
//Case 7: //case 8
//Case 8: //case 9
//Case 9: //case 10
case (stato)
//case 11in
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=0;
end
//case 12in
if (line1 && line2) stato=f;
else stato=b;
outp<=line1^line2;
overflw<=1;
end
//case 13in
if (line1 && line2) stato=g;
else stato=c;
outp<=line1^line2;
overflw<=0;
end
//case 14in
if (line1 || line2) stato=g;
else stato=c;
outp<=~(line1^line2);
overflw<=0;
end
//case 15in
if (line1 && line2) stato=wf1;
else stato=wf0;
outp<=line1^line2;
overflw<=0;
end
//case 16in
if (line1 || line2) stato=wf1;
else stato=wf0;
outp<=~(line1^line2);
overflw<=0;
end
//case 17egin
if (line1 && line2) stato=e;
else stato=a;
outp<=line1^line2;
overflw<=0;
end
//case 18egin
if (line1 || line2) stato=e;
else stato=a;
outp<=~(line1^line2);
overflw<=0;
end
endcase
end
endmodule
好像是把a:begin 那行给替换掉了
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 14:37
由 trigger
抄明白,别抄错
不可能在原处更改。
用>>重定向到新文件
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 14:53
由 wangjingchu
trigger 写了:抄明白,别抄错
不可能在原处更改。
用>>重定向到新文件

嘿嘿,我已经弄好了
是不是这样啊
代码: 全选
i=1
while IFS=# read "line"
do
((`echo $line|grep -c ': begin'`>0))&&echo -e "$line" "//case $i"&&let i++||echo -e "$line"
done<b01.v>>me.log
唯一有一点就是那些备注是被换行了的,怎么直接插到同一行的最后面啊?
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 15:31
由 trigger
wangjingchu 写了:trigger 写了:抄明白,别抄错
不可能在原处更改。
用>>重定向到新文件

嘿嘿,我已经弄好了
是不是这样啊
代码: 全选
i=1
while IFS=# read "line"
do
((`echo $line|grep -c ': begin'`>0))&&echo -e "$line" "//case $i"&&let i++||echo -e "$line"
done<b01.v>>me.log
唯一有一点就是那些备注是被换行了的,怎么直接插到同一行的最后面啊?
不可能换行啊
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 15:37
由 trigger
如果你不习惯&&||这种写法,自己改成if从句吧。
Re: 急!在线等shell编程一个小小问题
发表于 : 2010-12-25 15:51
由 wangjingchu
trigger 写了:如果你不习惯&&||这种写法,自己改成if从句吧。
总之还是谢谢了!!

作业可以完成了,多亏了你啊