作者Acme ( )
看板Electronics
標題Re: [問題] verilog的問題
時間Tue Mar 21 21:27:31 2006
※ 引述《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
1F:推 luckyBF:再建意~~!!!!!寫成 always @ (*) 超方便XD 03/21 21:58
2F:推 Jkson:建議在endcase再加上 default: result=3'b0;這樣合成比較好 03/22 01:09
3F:推 Acme:二樓的,因為2^3=8 , 八種case都用了,所以我不用default 03/22 16:45
※ 編輯: Acme 來自: 59.124.177.194 (06/21 19:39)