在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 4895|回复: 3

[求助] tcl 脚本运行错误请教

[复制链接]
发表于 2012-12-3 16:06:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
我写了个tcl脚本,目的是想把某个文件的一行中的关键字替换一下,脚本如下:
set change_hmac_netlist 1
set change_file "hmac_top_syn.v"
set new_file_0 "./output/hmac_top_0_syn.v"
set new_file_1 "./output/hmac_top_1_syn.v"
if {${change_hmac_netlist}} {
   echo "" > ${new_file_0}
   echo "" > ${new_file_1}
   set fp [open ${change_file} r]
   set write_enable 0
   while {[gets ${fp} line] >= 0} {
      set print_line_0 ${line}
      set print_line_1 ${line}
      if {[string first "module hmac_top" ${line}] >= 0} {
         set write_enable 1
         set print_line_0 [string map "hmac_top hmac_top_0" ${line}]
         set print_line_1 [string map "hmac_top hmac_top_1" ${line}]
      }
      echo ${print_line_0} >> ${new_file_0}
      if {${write_enable}} {
             echo ${print_line_1} >> ${new_file_1}
             echo ${print_line_2} >> ${new_file_2}
         }
   close ${fp}
   }
}

可是执行时出现如下错误信息:
Error: can not find channel named "file11"
Use error_info for more info. (CMD-013)
error_info
Extended error info:
can not find channel named "file11"
    while executing
"gets ${fp} line"
    invoked from within
"if {${change_hmac_netlist}} {
   echo "" > ${new_file_0}
   echo "" > ${new_file_1}
   set fp [open ${change_file} r]
   set write_enable 0
   while {..."
-- End Extended Error Info
不知道是哪里有问题,请大侠们指教!!!多谢!
发表于 2012-12-3 23:01:05 | 显示全部楼层
为什么你要这么写:${change_hmac_netlist}, ${new_file_0},${fp}。。。
直接写成$change_hmac_netlist, $new_file_0,$fp 不就行了,把所有的这些大括号去掉再试试看,有错误再把错误信息贴出来。
发表于 2012-12-4 14:12:36 | 显示全部楼层
顶楼上的,精简点,看着头晕
发表于 2012-12-6 15:06:23 | 显示全部楼层
学习,观赏!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-9 00:26 , Processed in 0.023372 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表