27 martie 2012

Porti elementare si implementarea lor in Icarus Verilog

1. Inversorul CMOS

module inversor(intrare, iesire);

    input intrare;
    output iesire;

    supply1 vdd;
    supply0 gnd;

    pmos p1(iesire, vdd, intrare);
    nmos n1(iesire, gnd, intrare);

endmodule

module test_inv;

    reg in1;
    wire out1;

    inversor inst1(in1, out1);

    initial begin
        in1 = 1'b0;
        #5   in1 = 1'b1;
        #10  in1  = 1'b0;
    end

    initial $monitor ($time, " out1=%b in1=%b",  out1, in1);

endmodule




2. CMOS AND gate

module and_cmos (in1, in2, out);

    input in1;
    input in2;
    output out;

    supply1 vdd;
    supply0 gnd;

    wire w1, w2;
   
    // stanga sus, au output in acelasi loc
    pmos pmos1(w1, vdd, in1);
    pmos pmos2(w1, vdd, in2);
   
    // stanga jos
    nmos nmos1(w2, gnd, in2);
    nmos nmos2(w1, w2, in1);
   
    // rezulta output
    pmos pmos3(out, vdd, w1);
    nmos nmos3(out, gnd, w1);
   
endmodule


module test_and;

    reg in1 = 0;
    reg in2 = 0;
    wire out;
   
    initial begin
        #5  in1 = 1'b1;
        #5 in2 = 1'b1;
        #5 in1 = 1'b0;
        #5 in2 = 1'b0;
    end
   
    and_cmos and1(in1, in2, out);
   
    initial
    $monitor($time," AND(in1, in2, out) = (%b, %b, %b)", in1, in2, out);

endmodule




3. CMOS OR gate

module or_cmos (in1, in2, out);

    input in1;
    input in2;
    output out;

    supply1 vdd;
    supply0 gnd;

    wire w1, w2;

    // stg sus
    pmos pmos1(w1, vdd, in1);
    pmos pmos2(w2, w1, in2);

    // stg jos
    nmos nmos1(w2, gnd, in1);
    nmos nmos2(w2, gnd, in2);

    // output
    pmos pmos3(out, vdd, w2);
    nmos nmos3(out, gnd, w2);

endmodule

module test_or;

    reg in1 = 0;
    reg in2 = 0;
    wire out;
   
    initial begin
        #5 in1 = 1'b1;
        #5 in2 = 1'b1;
        #5 in1 = 1'b0;
        #5 in2 = 1'b0;
    end
   
    or_cmos or1(in1, in2, out);
   
    initial
    $monitor($time," OR(in1, in2, out) = (%b, %b, %b)", in1, in2, out);

endmodule




4. CMOS XOR gate



module xor_cmos (in1, in2, out);

    input in1;
    input in2;
    output out;

    supply1 vdd;
    supply0 gnd;

    wire w1, w2;

    // dreapta
    pmos pmos1 (w1, vdd, in1);
    nmos nmos1 (w1, gnd, in1);

    // stanga
    pmos pmos3 (out, in1, in2);
    nmos nmos3 (out, w1, in2);

    // centru
    pmos pmos2 (out, in2, in1);
    nmos nmos2 (out, in2, w1);

endmodule

module test_xor;

    reg in1 = 0;
    reg in2 = 0;
    wire out;
  
    initial begin
        #5 in1 = 1'b1;
        #5 in2 = 1'b1;
        #5 in1 = 1'b0;
        #5 in2 = 1'b0;
    end
  
    xor_cmos xor1(in1, in2, out);
  
    initial
    $monitor($time," XOR(in1, in2, out) = (%b, %b, %b)", in1, in2, out);

endmodule


5. Poarta T-gate (Transmission Gate)

module tgate_cmos (in, A, out);

    input in;
    input A;
    output out;

    pmos pmos1 (out, in, ~A);
    nmos nmos1 (out, in, A);

endmodule

module test_tgate;

    reg in = 0;
    reg A = 0;
    wire out;
   
    initial begin
        #5 in = 1'b1;
        #5 A = 1'b1;
        #5 in = 1'b0;
    end
   
    tgate_cmos tgate(in, A, out);
   
    initial
    $monitor($time," TGATE(in, A, out) = (%b, %b, %b)", in, A, out);

endmodule


Semnificatie T-gate: compus dintr-un un tranzistor nmos si unul pmos,  cu A semnal de enable, aceasta poarta lasa sa treaca mai departe valoarea lui In, numai atunci cand A este activat, si blocheaza iesirea, in caz contrar.
  Cand A este 1, in pmos intra ~A adica 0, deci pmos-ul este inchis (conduce pe 0). La fel, in nmos intra 1 si acesta conduce. La In = 1, conduce pmos si out = 1, iar la In = 0, conduce nmos si out = 0.
  Cand A este 0, in pmos intra 1 si se deschide (nu mai conduce), iar in nmos intra 0 - idem. Rezulta ca la out va fi impedanta marita = z oricare ar fi intrarea In.

surse foto: http://www.allaboutcircuits.com/vol_4/chpt_3/7.html

Niciun comentariu: