tl; dr
先上图
卡了一天的bug,一直报错如下:
%Warning-LATCH: /home/ghhu/Desktop/study/lab3_nv/vsrc/top.v:35:1: Latch inferred for signal 'top.local_cin' (not all control paths of combinational always assign a value)
: ... Suggest use of always_latch for intentional latches
35 | always @(*) begin
| ^~~~~~
... For warning description see https://verilator.org/warn/LATCH?v=5.008
... Use "/* verilator lint_off LATCH */" and lint_on around source to disable this message.
%Error: Exiting due to 1 warning(s)
代码:
原因就是,虽然写了default,但是所有在case语句块中被赋值的变量(输出)都需要有缺省值,不然就会产生latch,(毕竟对应到电路来讲,就是输出悬空了)
所以,此处需要给out/local_cin都写入default
还有一些小笔记,也放在这儿吧:
- case 无优先级
- if-else 有优先级
always/initial 语句块中被赋值的变量一定是reg
assign 语句中被赋值的变量一定是wire
阻塞赋值用于组合逻辑
非阻塞赋值用于时序逻辑