2011年10月17日 星期一

Not gate注意事項

module top(
input a,
input b,
output [31:0] c
    );
wire a_wire;
assign a_wire=0;
assign c=!a_wire;


endmodule
結果造成只有c最後一位元改變0x0000->0x0001

另一種寫法

module top(
input a,
input b,
output [31:0] c
    );
wire a_wire;
assign a_wire=0;
assign c=~a_wire;


endmodule

則c=1111.....1111;

結論
       使用 ! 是一位元的反向,使用~則是全部位元的反向。一般使用使用pll/dcm 中的lock作為其他module採用~比較正統。!屬於邏輯位元子,用來判斷是或否,ex: if(a==!b)之類。

沒有留言:

張貼留言