@@ -325,17 +325,21 @@ def twire(w):
325
325
output_wire = twire (netio [2 ])
326
326
output_wire <<= twire (netio [0 ]) | twire (netio [1 ]) # or gate
327
327
elif command ['cover_list' ].asList () == ['0-' , '1' , '-0' , '1' ]:
328
+ # nand is not really a PyRTL primitive and so should only be added to a netlist
329
+ # via a call to nand_synth(). We instead convert it to ~(a & b) rather than
330
+ # (~a | ~b) as would be generated if handled by the else case below.
328
331
output_wire = twire (netio [2 ])
329
- output_wire <<= twire (netio [0 ]). nand ( twire (netio [1 ])) # nand gate
332
+ output_wire <<= ~ ( twire (netio [0 ]) & twire (netio [1 ])) # nand gate -> not+and gates
330
333
elif command ['cover_list' ].asList () == ['10' , '1' , '01' , '1' ]:
331
334
output_wire = twire (netio [2 ])
332
335
output_wire <<= twire (netio [0 ]) ^ twire (netio [1 ]) # xor gate
333
336
else :
334
337
# Although the following is fully generic and thus encompasses all of the
335
338
# special cases after the simple wire case above, we leave the above in because
336
339
# they are commonly found and lead to a slightly cleaner (though equivalent) netlist,
337
- # because we can use nand/xor primitives, or avoid the extra fluff of concat/select
338
- # wires that might be created implicitly as part of rtl_all/rtl_any.
340
+ # because we can use the xor primitive/save a gate when converting the nand, or avoid
341
+ # the extra fluff of concat/select wires that might be created implicitly as part of
342
+ # rtl_all/rtl_any.
339
343
def convert_val (ix , val ):
340
344
wire = twire (netio [ix ])
341
345
if val == '0' :
0 commit comments