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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 7552|回复: 18

[求助] 新人问代码问题

[复制链接]
发表于 2017-5-21 10:55:14 | 显示全部楼层 |阅读模式

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

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

x
请问这段代码的问题在哪,为什么会引入flipflop? DEFAULT branch of CASE statement cannot be reached是怎么造成的?


Inferred memory devices in process

in routine accum line 153 in file


'/home/IC/project/cpu_test/risc_cpu_new.v'.

===============================================================================
|    Register Name    |   Type    | Width | Bus | MB | AR | AS | SR | SS | ST |
===============================================================================
|      accum_reg      | Flip-flop |   8   |  Y  | N  | N  | N  | N  | N  | N  |
===============================================================================
Presto compilation completed successfully.
Information: Building the design 'alu'. (hdl-193)
Warning:  /home/IC/project/cpu_test/risc_cpu_new.v:188: DEFAULT branch of CASE statement cannot be reached. (ELAB-311)








  1. module alu(
  2.        input wire alu_clk,
  3.        input wire [7:0] data,
  4.        input wire [7:0] accum,
  5.        input wire [2:0] opcode,
  6.        output reg [7:0] alu_out,
  7.        output wire zero );
  8.       
  9.        parameter HLT  = 3'b000,
  10.                                 SKZ  = 3'b001,
  11.                                 ADD  = 3'b010,
  12.                                 ANDD = 3'b011,
  13.                                 XORR = 3'b100,
  14.                                 LDA  = 3'b101,
  15.                                 STO  = 3'b110,
  16.                                 JMP  = 3'b111;
  17.       
  18.        assign zero = !accum;
  19.       
  20.        always @( posedge alu_clk ) begin
  21.                casex( opcode )
  22.                        HLT:
  23.                                alu_out <= accum;
  24.                        SKZ:
  25.                                alu_out <= accum;
  26.                        ADD:
  27.                                alu_out <= data + accum;
  28.                        ANDD:
  29.                                alu_out <= data & accum;
  30.                        XORR:
  31.                                alu_out <= data ^ accum;
  32.                        LDA:
  33.                                alu_out <= data;
  34.                        STO:
  35.                                alu_out <= accum;
  36.                        JMP:
  37.                                alu_out <= accum;
  38.                        default:
  39.                                alu_out <= 8'hxx;
  40.                endcase
  41.         end


复制代码



endmodule
发表于 2017-5-21 12:06:07 | 显示全部楼层
1. 为什么会引入flipflop?
答:flipflop就是触发器。时序逻辑的基本单元。 always @( posedge alu_clk ),可不就是描述时序逻辑吗?

2. DEFAULT branch of CASE statement cannot be reached是怎么造成的?
答:default分支,永远跳转不到。因为case的状态信号opcode ,本身是3位,所以有8种情况,在case语句里都已经描述清楚,所以default分支的代码,是可以删减的。

不过,default分支,还是建议写。
一是因为难免以后代码维护的时候,把某个状态给删减了。如果组合逻辑的case,出现这样的情况,就会发生latch,是综合不允许的。至于为什么综合产生latch,是因为组合逻辑分支不全,导致综合工具误认为设计者要保存之前的结果。
二是因为default分支,赋值x不定态,可以起到仿真阶段,波形上及早发现错误。
 楼主| 发表于 2017-5-21 12:41:41 | 显示全部楼层
回复 2# 001qilei001

谢谢。所以在DC elaborate的时候弹出这个warning  “DEFAULT branch of CASE statement cannot be reached”是可以忽略的吧。
 楼主| 发表于 2017-5-21 12:59:56 | 显示全部楼层
还有如下信息,这段代表什么意思?

Statistics for case statements in always block at line 187 in file
        '/home/IC/project/cpu_test/risc_cpu_new.v'
===============================================
|           Line           |  full/ parallel  |
===============================================
|           188            |    auto/auto     |
===============================================
 楼主| 发表于 2017-5-21 13:01:25 | 显示全部楼层
还有这段“full/ parallel,auto/auto”代表什么意思?

Statistics for case statements in always block at line 187 in file
        '/home/IC/project/cpu_test/risc_cpu_new.v'
===============================================
|           Line           |  full/ parallel  |
===============================================
|           188            |    auto/auto     |
===============================================
 楼主| 发表于 2017-5-21 13:03:48 | 显示全部楼层
回复 2# 001qilei001

还有这段信息代表什么意思呢?





  1. Statistics for case statements in always block at line 187 in file
  2.         '/home/IC/project/cpu_test/risc_cpu_new.v'
  3. ===============================================
  4. |           Line           |  full/ parallel  |
  5. ===============================================
  6. |           188            |    auto/auto     |
  7. ===============================================


复制代码
发表于 2017-5-21 13:42:57 | 显示全部楼层
warning,不同与error和info。
error必须要解决,
warning必须要解释。

关于warning  “DEFAULT branch of CASE statement cannot be reached”,作为综合负责人的话,我个人是建议忽略。功能验证方面的问题,由验证人员去负责。

再次强调,warning需要有合理的解释;有些可以忽略,有些会引发问题(比如latch产生、组合loop等,默认是warning,但是要看待成error)。
发表于 2017-5-22 10:15:33 | 显示全部楼层
casex改成case
发表于 2017-5-22 10:16:24 | 显示全部楼层
casex改成case
发表于 2017-5-22 11:41:17 | 显示全部楼层
回复 5# wangyangcha
full/ parallel 是  synthesis directives.目的是告斯synthesizer 如何implement "case"
RTL code 裡面沒寫,就由synthesizer  base on timing/area  "auto" 選擇
這篇是非常有名的SUNG paper,裡面對full_case, parallel_case 有非常精采的解釋
非常值得一看
full_case_parallel_case_the_evil_twins_of_verilog.pdf (72.37 KB, 下载次数: 87 )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

×

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

GMT+8, 2024-3-29 05:41 , Processed in 0.029111 second(s), 7 queries , Gzip On, Redis On.

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