Re: [問題] verilog的問題
※ 引述《stevenf3 (Life)》之銘言:
: 下面是我寫的多工器部分code..
: 不知道哪裡錯了..
: 一直出現Error: Lval 'result' cannot be a net
: 麻煩幫幫忙~_~...跟他非常不熟orz
: input[3:0] a,b,c,d,e,f,g,h;
: input[2:0] select;
: output[3:0] result;
: case(select[2])
: 1'b0: begin
: result = (select[1]==0)?(select[0]==0?a:b):(select[0]==0?c:d);
: end
: 1'b1: begin
: result = (select[1]==0)?(select[0]==0?e:f):(select[0]==0?g:h);
: end
: endcase
建議寫這樣,可讀性會比較高
reg [3:0] result;
always @(select or a or b or c or d or e or f or g or h) begin
case(select[2:0])
3'b000 : result = a;
3'b001 : result = b;
3'b010 : result = c;
3'b011 : result = d;
3'b100 : result = e;
3'b101 : result = f;
3'b110 : result = g;
3'b111 : result = h;
endcase
end
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.124.177.194
推
03/21 21:58, , 1F
03/21 21:58, 1F
推
03/22 01:09, , 2F
03/22 01:09, 2F
推
03/22 16:45, , 3F
03/22 16:45, 3F
※ 編輯: Acme 來自: 59.124.177.194 (06/21 19:39)
討論串 (同標題文章)