aboutsummaryrefslogtreecommitdiffstats
path: root/mistral/pins.cc
blob: 120ccbb2f1f3c2741705b6c4b2d76897f913693f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *  nextpnr -- Next Generation Place and Route
 *
 *  Copyright (C) 2021  gatecat <gatecat@ds0.me>
 *
 *  Permission to use, copy, modify, and/or distribute this software for any
 *  purpose with or without fee is hereby granted, provided that the above
 *  copyright notice and this permission notice appear in all copies.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 *  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 *  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 *  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 *  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 *  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 */

#include "log.h"
#include "nextpnr.h"
#include "util.h"

NEXTPNR_NAMESPACE_BEGIN

const dict<IdString, Arch::CellPinsData> Arch::cell_pins_db = {
        // For combinational cells, inversion and tieing can be implemented by manipulating the LUT function
        {id_MISTRAL_ALUT2, {{{}, PINSTYLE_COMB}}},
        {id_MISTRAL_ALUT3, {{{}, PINSTYLE_COMB}}},
        {id_MISTRAL_ALUT4, {{{}, PINSTYLE_COMB}}},
        {id_MISTRAL_ALUT5, {{{}, PINSTYLE_COMB}}},
        {id_MISTRAL_ALUT6, {{{}, PINSTYLE_COMB}}},
        {id_MISTRAL_ALUT_ARITH,
         {// Leave carry chain alone, other than disconnecting a ground constant
          {id_CI, PINSTYLE_CARRY},
          {{}, PINSTYLE_COMB}}},
        {id_MISTRAL_FF,
         {
                 {id_CLK, PINSTYLE_CLK},
                 {id_ENA, PINSTYLE_CE},
                 {id_ACLR, PINSTYLE_RST},
                 {id_SCLR, PINSTYLE_RST},
                 {id_SLOAD, PINSTYLE_RST},
                 {id_SDATA, PINSTYLE_DEDI},
                 {id_DATAIN, PINSTYLE_INP},
         }},
        {id_MISTRAL_MLAB,
         {
                 {id_CLK1, PINSTYLE_CLK},
                 {id_A1EN, PINSTYLE_CE},
         }}};

CellPinStyle Arch::get_cell_pin_style(const CellInfo *cell, IdString port) const
{
    // Look up the pin style in the cell database
    auto fnd_cell = cell_pins_db.find(cell->type);
    if (fnd_cell == cell_pins_db.end())
        return PINSTYLE_NONE;
    auto fnd_port = fnd_cell->second.find(port);
    if (fnd_port != fnd_cell->second.end())
        return fnd_port->second;
    // If there isn't an exact port match, then the empty IdString
    // represents a wildcard default match
    auto fnd_default = fnd_cell->second.find({});
    if (fnd_default != fnd_cell->second.end())
        return fnd_default->second;

    return PINSTYLE_NONE;
}

NEXTPNR_NAMESPACE_END