2016-12-01 35 views
0

cmd它顯示我y = z如何解決它。什麼是我的代碼worng? 我想得到a = 1 b = 1 y =什麼?不是z。Verilog CMOS或門錯誤

見下圖:

screen

這是我的代碼

module or2(input a, b, output y); 

    nmos(wire1,a,b); 
    pmos(wire1,0,b); 
    pmos(y,a,b); 

endmodule 

module OR_tb(); 
    reg a,b; 
    wire y; 

    or2 dut(a, b, y); 

    initial 
    begin 
     $monitor("a = %b b = %b y = %b",a,b,y); 
     a=0; 
     b=0; 
     #1; b=1; 
     #1; a=1; b=0; 
     #1; b=1; 
     #1; 
     $finish; 
    end 

endmodule 
+0

Google'OR gate cmos',你會發現你的'or2'模塊是錯誤的:它應該有6個晶體管。 –

+0

那麼,我需要增加pmods和nmods? –

+0

我這麼認爲。我對晶體管級設計知之甚少,但我知道輸入最簡單的2輸入門是一個與非門,並且需要4個晶體管,並且,正如我所說,一點點谷歌搜索顯示了一個CMOS或門的需求6. –

回答

0

or2模塊是錯誤的。這裏是or2模塊。

module or2(input a, b, output y); 
    wire wire1, temp_out; 

    // 2 Bit NOR Gate 
    nmos(temp_out, 1'b0, a); 
    nmos(temp_out, 1'b0, b); 

    pmos(wire1, 1'b1, a); 
    pmos(temp_out, wire1, b); 

    // 1 Bit Inverter 
    nmos(out, 1'b0, temp_out); 
    pmos(out, 1'b1, temp_out); 
endmodule