|
13 | 13 | from .pyrtlexceptions import PyrtlError, PyrtlInternalError
|
14 | 14 | from .core import working_block, _NameSanitizer
|
15 | 15 | from .wire import WireVector, Input, Output, Const, Register, next_tempvar_name
|
16 |
| -from .corecircuits import concat_list |
| 16 | +from .corecircuits import concat_list, rtl_all, rtl_any |
17 | 17 | from .memory import RomBlock
|
18 | 18 | from .passes import two_way_concat, one_bit_selects
|
19 | 19 |
|
@@ -315,26 +315,42 @@ def twire(w):
|
315 | 315 | elif command['cover_list'].asList() == ['11', '1']:
|
316 | 316 | output_wire = twire(netio[2])
|
317 | 317 | output_wire <<= twire(netio[0]) & twire(netio[1]) # and gate
|
318 |
| - elif command['cover_list'].asList() == ['00', '1']: |
319 |
| - output_wire = twire(netio[2]) |
320 |
| - output_wire <<= ~ (twire(netio[0]) | twire(netio[1])) # nor gate |
321 | 318 | elif command['cover_list'].asList() == ['1-', '1', '-1', '1']:
|
322 | 319 | output_wire = twire(netio[2])
|
323 | 320 | output_wire <<= twire(netio[0]) | twire(netio[1]) # or gate
|
| 321 | + elif command['cover_list'].asList() == ['0-', '1', '-0', '1']: |
| 322 | + output_wire = twire(netio[2]) |
| 323 | + output_wire <<= twire(netio[0]).nand(twire(netio[1])) # nand gate |
324 | 324 | elif command['cover_list'].asList() == ['10', '1', '01', '1']:
|
325 | 325 | output_wire = twire(netio[2])
|
326 | 326 | output_wire <<= twire(netio[0]) ^ twire(netio[1]) # xor gate
|
327 |
| - elif command['cover_list'].asList() == ['1-0', '1', '-11', '1']: |
328 |
| - output_wire = twire(netio[3]) |
329 |
| - output_wire <<= (twire(netio[0]) & ~ twire(netio[2])) \ |
330 |
| - | (twire(netio[1]) & twire(netio[2])) # mux |
331 |
| - elif command['cover_list'].asList() == ['-00', '1', '0-0', '1']: |
332 |
| - output_wire = twire(netio[3]) |
333 |
| - output_wire <<= (~twire(netio[1]) & ~twire(netio[2])) \ |
334 |
| - | (~twire(netio[0]) & ~twire(netio[2])) |
335 | 327 | else:
|
336 |
| - raise PyrtlError('Blif file with unknown logic cover set "%s" ' |
337 |
| - '(currently gates are hard coded)' % command['cover_list']) |
| 328 | + # Although the following is fully generic and thus encompasses all of the |
| 329 | + # special cases after the simple wire case above, we leave the above in because |
| 330 | + # they are commonly found and lead to a slightly cleaner (though equivalent) netlist, |
| 331 | + # because we can use nand/xor primitives, or avoid the extra fluff of concat/select |
| 332 | + # wires that might be created implicitly as part of rtl_all/rtl_any. |
| 333 | + def convert_val(ix, val): |
| 334 | + wire = twire(netio[ix]) |
| 335 | + if val == '0': |
| 336 | + wire = ~wire |
| 337 | + return wire |
| 338 | + |
| 339 | + cover = command['cover_list'].asList() |
| 340 | + output_wire = twire(netio[-1]) |
| 341 | + conjunctions = [] |
| 342 | + while cover: |
| 343 | + if len(cover) < 2: |
| 344 | + raise PyrtlError('BLIF file with malformed cover set "%s" ' |
| 345 | + % command['cover_list']) |
| 346 | + input_plane, output_plane, cover = cover[0], cover[1], cover[2:] |
| 347 | + if output_plane != '1': |
| 348 | + raise PyrtlError('Off-set found in the output plane of BLIF cover set "%s" ' |
| 349 | + '(only on-sets are supported)' % command['cover_list']) |
| 350 | + conj = rtl_all(*[convert_val(ix, val) for ix, val |
| 351 | + in enumerate(input_plane) if val != '-']) |
| 352 | + conjunctions.append(conj) |
| 353 | + output_wire <<= rtl_any(*conjunctions) |
338 | 354 |
|
339 | 355 | def extract_flop(subckt, command):
|
340 | 356 |
|
|
0 commit comments