2017-12-06 01:08:40 +01:00
|
|
|
#!/usr/bin/env python3
|
2020-04-16 10:06:01 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
#
|
|
|
|
|
# Copyright (C) 2017-2020 The Project X-Ray Authors.
|
|
|
|
|
#
|
|
|
|
|
# Use of this source code is governed by a ISC-style
|
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
|
# https://opensource.org/licenses/ISC
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: ISC
|
2017-12-06 01:08:40 +01:00
|
|
|
|
2018-10-18 04:03:16 +02:00
|
|
|
from prjxray.segmaker import Segmaker
|
2018-10-18 07:21:42 +02:00
|
|
|
from prjxray import util
|
2017-12-06 01:08:40 +01:00
|
|
|
|
2018-10-22 21:04:55 +02:00
|
|
|
segmk = Segmaker("design.bits")
|
2017-12-07 02:30:02 +01:00
|
|
|
cache = dict()
|
2017-12-06 01:08:40 +01:00
|
|
|
|
|
|
|
|
print("Loading tags")
|
|
|
|
|
'''
|
|
|
|
|
module,loc,n
|
|
|
|
|
clb_NFFMUX_O5,SLICE_X12Y100,3
|
|
|
|
|
clb_NFFMUX_AX,SLICE_X13Y100,2
|
|
|
|
|
clb_NFFMUX_O6,SLICE_X14Y100,3
|
|
|
|
|
'''
|
|
|
|
|
f = open('params.csv', 'r')
|
|
|
|
|
f.readline()
|
|
|
|
|
for l in f:
|
2018-01-09 23:45:26 +01:00
|
|
|
module, loc, n = l.split(',')
|
2017-12-06 01:08:40 +01:00
|
|
|
n = int(n)
|
|
|
|
|
which = chr(ord('A') + n)
|
|
|
|
|
# clb_NFFMUX_AX => AX
|
2017-12-09 00:58:14 +01:00
|
|
|
src = module.replace('clb_NOUTMUX_', '')
|
2017-12-06 01:08:40 +01:00
|
|
|
'''
|
|
|
|
|
BOUTMUX
|
|
|
|
|
30_20 30_21 30_22 30_23
|
|
|
|
|
O6 1
|
|
|
|
|
O5 1 1
|
|
|
|
|
XOR 1
|
|
|
|
|
CY 1 1
|
|
|
|
|
F8 1 1
|
|
|
|
|
B5Q 1
|
|
|
|
|
'''
|
2017-12-07 02:30:02 +01:00
|
|
|
|
2017-12-09 02:12:58 +01:00
|
|
|
# if location not included in cache yet: start with assuming all four MUXes are unused.
|
2017-12-07 02:30:02 +01:00
|
|
|
if loc not in cache:
|
|
|
|
|
cache[loc] = set("ABCD")
|
|
|
|
|
|
2017-12-09 02:12:58 +01:00
|
|
|
# rewrite name of F78 source net: MUXes A and C have an F7 input, MUX B has an F8 input
|
2017-12-07 02:30:02 +01:00
|
|
|
if src == "F78":
|
|
|
|
|
if which in "AC":
|
|
|
|
|
src = "F7"
|
|
|
|
|
elif which == "B":
|
|
|
|
|
src = "F8"
|
|
|
|
|
else:
|
|
|
|
|
assert 0
|
|
|
|
|
|
2017-12-09 02:12:58 +01:00
|
|
|
# rewrite name of B5Q source net: It's actually A5Q, B5Q, C5Q, or D5Q
|
2017-12-07 02:30:02 +01:00
|
|
|
if src == "B5Q":
|
|
|
|
|
src = which + "5Q"
|
|
|
|
|
|
2017-12-09 02:12:58 +01:00
|
|
|
# add the 1-tag for this connection
|
2018-02-06 01:41:10 +01:00
|
|
|
tag = "%sOUTMUX.%s" % (which, src)
|
2018-10-18 05:11:20 +02:00
|
|
|
segmk.add_site_tag(loc, tag, 1)
|
2017-12-09 02:12:58 +01:00
|
|
|
|
|
|
|
|
# remove this MUX from the cache, preventing generation of 0-tags for this MUX
|
2017-12-07 02:30:02 +01:00
|
|
|
cache[loc].remove(which)
|
|
|
|
|
|
2018-11-12 21:07:21 +01:00
|
|
|
# O6 hack per https://github.com/SymbiFlow/prjxray/issues/243
|
|
|
|
|
segmk.add_site_tag(loc, "%sOUTMUX.%s" % (which, "O6"), src == "O5")
|
|
|
|
|
|
2017-12-09 02:12:58 +01:00
|
|
|
# create 0-tags for all sources on the remaining (unused) MUXes
|
2017-12-07 02:30:02 +01:00
|
|
|
for loc, muxes in cache.items():
|
|
|
|
|
for which in muxes:
|
2019-07-10 14:59:46 +02:00
|
|
|
for src in "F7 F8 CY O5 XOR 5Q MC31".split():
|
|
|
|
|
if src == "MC31" and which is not "D": continue
|
2018-01-08 22:57:06 +01:00
|
|
|
if src == "F7" and which not in "AC": continue
|
|
|
|
|
if src == "F8" and which not in "B": continue
|
|
|
|
|
if src == "5Q": src = which + "5Q"
|
2018-02-06 01:41:10 +01:00
|
|
|
tag = "%sOUTMUX.%s" % (which, src)
|
2018-10-18 05:11:20 +02:00
|
|
|
segmk.add_site_tag(loc, tag, 0)
|
2017-12-07 02:30:02 +01:00
|
|
|
|
2018-01-09 23:45:26 +01:00
|
|
|
|
2017-12-07 02:30:02 +01:00
|
|
|
def bitfilter(frame_idx, bit_idx):
|
2017-12-09 02:12:58 +01:00
|
|
|
# locations of A5MA, B5MA, C5MA, D5MA bits. because of the way we generate specimens
|
|
|
|
|
# in this fuzzer we get some aliasing with those bits, so we have to manually exclude
|
|
|
|
|
# them. (Maybe FIXME: read the bit locations from the database files)
|
2019-07-08 15:39:06 +02:00
|
|
|
|
2019-07-10 14:59:46 +02:00
|
|
|
# Since the SRL32 is enabled along with DOUTMUX.MC31, bits related to
|
2019-07-08 15:39:06 +02:00
|
|
|
# SRL32 features are masked out.
|
|
|
|
|
|
2017-12-07 02:30:02 +01:00
|
|
|
if (frame_idx, bit_idx) in [
|
2018-01-09 23:45:26 +01:00
|
|
|
(30, 55),
|
|
|
|
|
(31, 55), # D5MA
|
|
|
|
|
(31, 44),
|
|
|
|
|
(31, 45), # C5MA
|
|
|
|
|
(30, 19),
|
|
|
|
|
(31, 19), # B5MA
|
|
|
|
|
(30, 9),
|
2019-07-10 16:15:28 +02:00
|
|
|
(31, 8), # A5MA
|
2019-07-08 15:39:06 +02:00
|
|
|
(30, 16), # ALUT.SRL
|
2019-07-10 16:15:28 +02:00
|
|
|
(1, 23), # WEMUX.CE
|
2018-01-09 23:45:26 +01:00
|
|
|
]:
|
|
|
|
|
return False
|
2017-12-07 02:30:02 +01:00
|
|
|
|
2018-10-18 07:21:42 +02:00
|
|
|
return util.bitfilter_clb_mux(frame_idx, bit_idx)
|
2017-12-07 02:30:02 +01:00
|
|
|
|
2018-01-09 23:45:26 +01:00
|
|
|
|
2017-12-07 02:30:02 +01:00
|
|
|
segmk.compile(bitfilter=bitfilter)
|
2017-12-06 01:08:40 +01:00
|
|
|
segmk.write()
|