作者zmudd (Zmud)
看板Electronics
标题[问题] Verilog Counter waveform请教
时间Wed Aug 26 23:06:56 2015
初学想请教verilog 模拟结果的waveform
我写了这段:
reg [1:0] cnt;
always @ (posedge clk or negedge rstn)
if (!rst_n) cnt <=2'b00;
else if (EN) cnt <= cnt+1;
else cnt <= cnt;
ncverilog跑出来的dump结果应该是A ? 还是 B?
http://imgur.com/7h2lK29
如果是B, 什麽情况会跑出 A?
如果是A, 什麽情况会跑出 B?
恳请大大指教,谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 42.72.156.159
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Electronics/M.1440601618.A.B8E.html
1F:→ ViewMoon: 预期是A; cnt<=cnt+1最好改写成cnt<=#1cnt+1,同理EN的 08/27 00:16
2F:→ ViewMoon: 来源也是;race condition才会是B;如果 design 是 single 08/27 00:17
3F:→ ViewMoon: clock,那麽 ncverilog 可以跑出A; 否则,不同 simulator 08/27 00:18
4F:→ ViewMoon: 可能会有不同 simulation result; 所以加 #1 是好习惯 08/27 00:19
5F:→ ViewMoon: 另一个加 #1 的好处是 waveform 可以分辨 clock phase和 08/27 00:20
6F:→ ViewMoon: data phase; 唯一不要加 #1 的情况是 generated clock 08/27 00:20
7F:→ ViewMoon: 不过这类 generated clock on FF/Q 我会故意写 #0 去 08/27 00:21
8F:→ ViewMoon: highlight generated clock 这事实 08/27 00:21
9F:→ ViewMoon: 若 single clock 且 clock tree 上手放 gating cell 08/27 00:23
10F:→ ViewMoon: 不同的 simulator 一样有可能有不同 simulation result 08/27 00:23
11F:推 wait: setup time.... 08/28 16:41
12F:推 kamia: 基本上应该要A 会有B代表en 不是同一个clock domain 08/28 22:33
13F:→ kamia: CDC会叫 primetime也可能过不了 不该会出现B 除非是故意 08/28 22:34