[問題] Verilog syntax error

看板Electronics作者 (gecer)時間6年前 (2019/11/02 09:18), 6年前編輯推噓4(403)
留言7則, 4人參與, 6年前最新討論串1/1
小弟目前 verilog 語法問題 題目如下 Create 16 D flip-flops. It's sometimes useful to only modify parts of a group of flip-flops. The byte-enable inputs control whether each byte of the 16 registers should be written to on that cycle. byteena[1] controls the upper byte d[15:8], while byteena[0] controls the lower byte d[7:0]. resetn is a synchronous, active-low reset. All DFFs should be triggered by the positive edge of clk. module top_module ( input clk, input resetn, input [1:0] byteena, input [15:0] d, output [15:0] q ); always@(posedge clk) begin if (~resetn) begin q=8'b00000000; end else begin case (byteena) 2'b1X: assign q[15:8] = d[15:8]; 2'bX1: assign q[7:0] = d[7:0]; endcase end end endmodule 問題在case 的部分 compile error -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.121.17.136 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Electronics/M.1572657537.A.3B4.html ※ 編輯: gecer (122.121.17.136 臺灣), 11/02/2019 09:21:37

11/02 09:21, 6年前 , 1F
這不是C嗎?
11/02 09:21, 1F

11/02 09:42, 6年前 , 2F
assign不能加在always內..
11/02 09:42, 2F

11/02 09:47, 6年前 , 3F
如果case想要用don't care的話,請善用casez + ?
11/02 09:47, 3F

11/02 09:54, 6年前 , 4F
DFF的assignment最好用nonblocking (<=)
11/02 09:54, 4F

11/02 09:55, 6年前 , 5F
這題使用part-select會更簡潔
11/02 09:55, 5F

11/02 12:09, 6年前 , 6F
don’t care應該用 casex 且blocking 改成 non-blocking
11/02 12:09, 6F

11/03 14:31, 6年前 , 7F
發現還有resetn是16’b0~~
11/03 14:31, 7F
文章代碼(AID): #1TlDc1Eq (Electronics)