-2

schematic attached HERE

I need to create a verilog code from this schematic. So far I have:

module example1 (X, Y, Z, F);
input X, Y, Z;
output F;
wire w1, w2, w3;

nand
    g0 (X, Y);
    g1 (X, g0);
    g2 (Y, g0);
    g3 (Z, g1, g2);
    g4 (Z, g2, g3);
    g5 (g3, g4);

endmodule 

This is pretty much my first verilog code. I'm not sure how to add the wires or if I even have the correct number of wire. I see that there are many wires in the schematic, but I don't really know which wire to choose. Please help me improve my code.

dferenc
  • 7,918
  • 12
  • 41
  • 49
Jane
  • 1

1 Answers1

1

g0 is an instances names of the nand gates; not the name of the output wires. For a nand gate, the first port is always the output and all others are considered inputs.

  • g0 (X, Y); should be changed to g0 (w0, X, Y);
  • g3 (Z, g1, g2); should be changed to g3 (w3, Z, w1, w2);
  • etc.
  • g5's output should be F

FYI: Even with the above corrections, your logic is not correct. Double check your connections.

Greg
  • 18,111
  • 5
  • 46
  • 68