2021-02-11 19:10:32 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 David Shah <david@symbioticeda.com>
|
2021-01-31 07:06:55 +08:00
|
|
|
* Copyright (C) 2021 William D. Jones <wjones@wdj-consulting.com>
|
2021-02-11 19:10:32 +08:00
|
|
|
*
|
|
|
|
* 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 "nextpnr.h"
|
|
|
|
|
2020-06-28 09:59:30 +08:00
|
|
|
#ifndef MACHXO2_CELLS_H
|
|
|
|
#define MACHXO2_CELLS_H
|
2021-02-11 19:10:32 +08:00
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2020-11-26 18:01:14 +08:00
|
|
|
// Create a MachXO2 arch cell and return it
|
2021-02-11 19:10:32 +08:00
|
|
|
// Name will be automatically assigned if not specified
|
2020-06-28 09:59:30 +08:00
|
|
|
std::unique_ptr<CellInfo> create_machxo2_cell(Context *ctx, IdString type, std::string name = "");
|
2021-02-11 19:10:32 +08:00
|
|
|
|
|
|
|
// Return true if a cell is a LUT
|
2020-11-26 18:01:14 +08:00
|
|
|
inline bool is_lut(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("LUT4"); }
|
2021-02-11 19:10:32 +08:00
|
|
|
|
|
|
|
// Return true if a cell is a flipflop
|
2020-11-26 18:01:14 +08:00
|
|
|
inline bool is_ff(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("FACADE_FF"); }
|
2021-02-11 19:10:32 +08:00
|
|
|
|
2020-11-26 18:01:14 +08:00
|
|
|
inline bool is_lc(const BaseCtx *ctx, const CellInfo *cell) { return cell->type == ctx->id("FACADE_SLICE"); }
|
2021-02-11 19:10:32 +08:00
|
|
|
|
|
|
|
// Convert a LUT primitive to (part of) an GENERIC_SLICE, swapping ports
|
|
|
|
// as needed. Set no_dff if a DFF is not being used, so that the output
|
|
|
|
// can be reconnected
|
|
|
|
void lut_to_lc(const Context *ctx, CellInfo *lut, CellInfo *lc, bool no_dff = true);
|
|
|
|
|
|
|
|
// Convert a DFF primitive to (part of) an GENERIC_SLICE, setting parameters
|
|
|
|
// and reconnecting signals as necessary. If pass_thru_lut is True, the LUT will
|
|
|
|
// be configured as pass through and D connected to I0, otherwise D will be
|
|
|
|
// ignored
|
2021-02-02 22:55:42 +08:00
|
|
|
void dff_to_lc(Context *ctx, CellInfo *dff, CellInfo *lc, bool pass_thru_lut = false);
|
2021-02-11 19:10:32 +08:00
|
|
|
|
|
|
|
// Convert a nextpnr IO buffer to a GENERIC_IOB
|
2021-06-02 17:01:36 +08:00
|
|
|
void nxio_to_iob(Context *ctx, CellInfo *nxio, CellInfo *sbio, pool<IdString> &todelete_cells);
|
2021-02-11 19:10:32 +08:00
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|