jiangxii 2021-12-05 23:51 采纳率: 100%
浏览 97
已结题

verilog中的定义端口问题

img


问题遇到的现象和发生背景 :
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp27", which holds its previous value in one or more paths through the always construct

问题相关代码,请勿粘贴截图 :module jt207jicunqi (sr9,sr8,sr7,sr6,sr5,sr4,sr3,sr2,sr1,sr0,zl,tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16,tmp17,tmp20,tmp21,tmp22,tmp23,tmp24,tmp25,tmp26,tmp27,tmp30,tmp31,tmp32,tmp33,tmp34,tmp35,tmp36,tmp37,tmp40,tmp41,tmp42,tmp43,tmp44,tmp45,tmp46,tmp47); //sr:输入,zl:置零,js:计数
input sr9,sr8,sr7,sr6,sr5,sr4,sr3,sr2,sr1,sr0;
input zl;
output tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16,tmp17,tmp20,tmp21,tmp22,tmp23,tmp24,tmp25,tmp26,tmp27;
output tmp30,tmp31,tmp32,tmp33,tmp34,tmp35,tmp36,tmp37,tmp40,tmp41,tmp42,tmp43,tmp44,tmp45,tmp46,tmp47;
reg tmp10,tmp11,tmp12,tmp13,tmp14,tmp15,tmp16,tmp17,tmp20,tmp21,tmp22,tmp23,tmp24,tmp25,tmp26,tmp27;
reg tmp30,tmp31,tmp32,tmp33,tmp34,tmp35,tmp36,tmp37,tmp40,tmp41,tmp42,tmp43,tmp44,tmp45,tmp46,tmp47;
always @(sr9 or sr8 or sr7 or sr6 or sr5 or sr4 or sr3 or sr2 or sr1 or sr0 or zl or tmp10 or tmp11 or tmp12 or tmp13 or tmp14 or tmp15 or tmp16 or tmp17 or tmp20 or tmp21 or tmp22 or tmp23 or tmp24 or tmp25 or tmp26 or tmp27 or tmp30 or tmp31 or tmp32 or tmp33 or tmp34 or tmp35 or tmp36 or tmp37 or tmp40 or tmp41 or tmp42 or tmp43 or tmp44 or tmp45 or tmp46 or tmp47)
begin
if(zl==1)begin
tmp10=0;tmp11=0;tmp12=0;tmp13=0;tmp14=0;tmp15=0;tmp16=0;tmp17=0;tmp20=0;tmp21=0;tmp22=0;tmp23=0;tmp24=0;tmp25=0;tmp26=0;tmp27=0;
tmp30=0;tmp31=0;tmp32=0;tmp33=0;tmp34=0;tmp35=0;tmp36=0;tmp37=0;tmp40=0;tmp41=0;tmp42=0;tmp43=0;tmp44=0;tmp45=0;tmp46=0;tmp47=0;
end
case({sr9,sr8,sr7,sr6,sr5,sr4,sr3,sr2,sr1,sr0})
10'b0000000001:
begin
tmp10 <= 1'b0;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0000000010:
begin
tmp10 <= 1'b1;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0000000100:
begin
tmp10 <= 1'b0;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b1;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0000001000:
begin
tmp10 <= 1'b1;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b1;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0000010000:
begin
tmp10 <= 1'b0;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b1;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0000100000:
begin
tmp10 <= 1'b1;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b1;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0001000000:
begin
tmp10 <= 1'b0;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b1;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b1;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0010000000:
begin
tmp10 <= 1'b1;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b1;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b1;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b0100000000:
begin
tmp10 <= 1'b0;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b1;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
10'b1000000000:
begin
tmp10 <= 1'b1;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b1;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
default:begin
tmp10 <= 1'b0;
tmp11 <= tmp10;
tmp12 <= tmp11;
tmp13 <= tmp12;
tmp14 <= tmp13;
tmp15 <= tmp14;
tmp16 <= tmp15;
tmp17 <= tmp16;
tmp20 <= 1'b0;
tmp21 <= tmp20;
tmp22 <= tmp21;
tmp23 <= tmp22;
tmp24 <= tmp23;
tmp25 <= tmp24;
tmp26 <= tmp25;
tmp27 <= tmp26;
tmp30 <= 1'b0;
tmp31 <= tmp30;
tmp32 <= tmp31;
tmp33 <= tmp32;
tmp34 <= tmp33;
tmp35 <= tmp34;
tmp36 <= tmp35;
tmp37 <= tmp36;
tmp40 <= 1'b0;
tmp41 <= tmp40;
tmp42 <= tmp41;
tmp43 <= tmp42;
tmp44 <= tmp43;
tmp45 <= tmp44;
tmp46 <= tmp45;
tmp47 <= tmp46;
end
endcase
end
endmodule

运行结果及报错内容 :Warning (12019): Can't analyze file -- file Verilog1.v is missing

Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp10", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp11", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp12", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp13", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp14", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp15", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp16", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp17", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp20", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp21", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp22", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp23", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp24", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp25", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp26", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp27", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp30", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp31", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp32", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp33", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp34", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp35", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp36", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp37", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp40", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp41", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp42", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp43", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp44", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp45", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp46", which holds its previous value in one or more paths through the always construct
Warning (10240): Verilog HDL Always Construct warning at jt207jicunqi.v(8): inferring latch(es) for variable "tmp47", which holds its previous value in one or more paths through the always construct

我的解答思路和尝试过的方法 :我有些看不懂报错的意思,有尝试修改,但越改越多。
我想要达到的结果:主要就是想实现一个0到9的十个按钮按下后,四条串行移位寄存器进行寄存。
  • 写回答

2条回答 默认 最新

  • 老皮芽子 2021-12-06 11:18
    关注

    case({sr9,sr8,sr7,sr6,sr5,sr4,sr3,sr2,sr1,sr0})
    在这条语句前加个 else 改成这样就没 latch 的警告了
    else case({sr9,sr8,sr7,sr6,sr5,sr4,sr3,sr2,sr1,sr0})
    这代码用数组多好,能少10倍代码

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月14日
  • 已采纳回答 12月6日
  • 创建了问题 12月5日

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。