/* * nextpnr -- Next Generation Place and Route * * Copyright (C) 2021 Symbiflow Authors * * * 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. * */ #ifndef CHIPDB_H #define CHIPDB_H #include "archdefs.h" #include "nextpnr_namespaces.h" #include "relptr.h" NEXTPNR_NAMESPACE_BEGIN /* !!! Everything in this section must be kept in sync !!! * !!! with fpga_interchange/chip_info.py !!! * * When schema changes, bump version number in chip_info.py and * kExpectedChipInfoVersion */ static constexpr int32_t kExpectedChipInfoVersion = 13; // Flattened site indexing. // // To enable flat BelId.z spaces, every tile and sites within that tile are // flattened. // // This has implications on BelId's, WireId's and PipId's. // The flattened site space works as follows: // - Objects that belong to the tile are first. BELs are always part of Sites, // so no BEL objects are in this category. // - All site alternative modes are exposed as a "full" site. // - Each site appends it's BEL's, wires (site wires) and PIP's. // - Sites add two types of pips. Sites will add pip data first for site // pips, and then for site pin edges. // 1. The first type is site pips, which connect site wires to other site // wires. // 2. The second type is site pin edges, which connect site wires to tile // wires (or vise-versa). NPNR_PACKED_STRUCT(struct BelInfoPOD { int32_t name; // bel name (in site) constid int32_t type; // Type name constid int32_t bel_bucket; // BEL bucket constid. int32_t num_bel_wires; RelPtr ports; // port name constid RelPtr types; // port type (IN/OUT/BIDIR) RelPtr wires; // connected wire index in tile, or -1 if NA int16_t site; int16_t site_variant; // some sites have alternative types int16_t category; int8_t synthetic; int8_t lut_element; RelPtr pin_map; // Index into CellMapPOD::cell_bel_map // If this BEL is a site routing BEL with inverting pins, these values // will be [0, num_bel_wires). If this BEL is either not a site routing // BEL or this site routing has no inversion capabilities, then these will // both be -1. int8_t non_inverting_pin; int8_t inverting_pin; int16_t padding; }); enum BELCategory { // BEL is a logic element BEL_CATEGORY_LOGIC = 0, // BEL is a site routing mux BEL_CATEGORY_ROUTING = 1, // BEL is a site port, e.g. boundry between site and routing graph. BEL_CATEGORY_SITE_PORT = 2 }; NPNR_PACKED_STRUCT(struct BelPortPOD { int32_t bel_index; int32_t port; }); NPNR_PACKED_STRUCT(struct TileWireInfoPOD { int32_t name; // wire name constid // Pip index inside tile RelSlice pips_uphill; // Pip index inside tile RelSlice pips_downhill; // Bel index inside tile RelSlice bel_pins; int16_t site; // site index in tile int16_t site_variant; // site variant index in tile }); NPNR_PACKED_STRUCT(struct PipInfoPOD { int32_t src_index, dst_index; int16_t site; // site index in tile int16_t site_variant; // site variant index in tile int16_t bel; // BEL this pip belongs to if site pip. int16_t extra_data; RelSlice pseudo_cell_wires; }); NPNR_PACKED_STRUCT(struct ConstraintTagPOD { int32_t tag_prefix; // constid int32_t default_state; // constid RelSlice states; // constid }); NPNR_PACKED_STRUCT(struct LutBelPOD { uint32_t name; // constid RelSlice pins; // constid uint32_t low_bit; uint32_t high_bit; int32_t out_pin; // constid }); NPNR_PACKED_STRUCT(struct LutElementPOD { int32_t width; RelSlice lut_bels; }); NPNR_PACKED_STRUCT(struct TileTypeInfoPOD { int32_t name; // Tile type constid RelSlice bel_data; RelSlice wire_data; RelSlice pip_data; RelSlice tags; RelSlice lut_elements; RelSlice site_types; // constid }); NPNR_PACKED_STRUCT(struct SiteInstInfoPOD { RelPtr name; RelPtr site_name; // Which site type is this site instance? // constid int32_t site_type; }); NPNR_PACKED_STRUCT(struct TileInstInfoPOD { // Name of this tile. RelPtr name; // Index into root.tile_types. int32_t type; // This array is root.tile_types[type].site_types.size() long. // Index into root.sites RelSlice sites; // Number of tile wires; excluding any site-internal wires // which come after general wires and are not stored here // as they will never be nodal // -1 if a tile-local wire; node index if nodal wire RelSlice tile_wire_to_node; // Index into wire_types RelSlice tile_wire_to_type; }); NPNR_PACKED_STRUCT(struct TileWireRefPOD { int32_t tile; int32_t index; }); NPNR_PACKED_STRUCT(struct NodeInfoPOD { RelSlice tile_wires; }); NPNR_PACKED_STRUCT(struct CellBelPinPOD { int32_t cell_pin; // constid int32_t bel_pin; // constid }); NPNR_PACKED_STRUCT(struct ParameterPinsPOD { int32_t key; // constid int32_t value; // constid RelSlice pins; }); NPNR_PACKED_STRUCT(struct CellConstraintPOD { int32_t tag; // Tag index int32_t constraint_type; // Constraint::ConstraintType RelSlice states; // State indicies }); // Cell parameters metadata NPNR_PACKED_STRUCT(struct CellParameterPOD { int32_t cell_type; // constid int32_t parameter; // constid int32_t format; // ParameterFormat enum int32_t default_value; // constid }); NPNR_PACKED_STRUCT(struct CellBelMapPOD { RelSlice common_pins; RelSlice parameter_pins; RelSlice constraints; }); NPNR_PACKED_STRUCT(struct LutCellPOD { int32_t cell; // constid RelSlice input_pins; // constids int32_t parameter; }); NPNR_PACKED_STRUCT(struct CellMapPOD { // Cell names supported in this arch. RelSlice cell_names; // constids // BEL names that are global buffers. RelSlice global_buffers; // constids // Name of BelBuckets. RelSlice cell_bel_buckets; // constids RelSlice cell_bel_map; RelSlice lut_cells; RelSlice cell_parameters; }); NPNR_PACKED_STRUCT(struct PackagePinPOD { int32_t package_pin; // constid int32_t site; // constid int32_t bel; // constid }); NPNR_PACKED_STRUCT(struct PackagePOD { int32_t package; // constid RelSlice pins; }); enum CellPinValue { // leave floating PIN_VALUE_FLOAT = 0, // connect to ground PIN_VALUE_GND = 1, // connect to vcc PIN_VALUE_VCC = 2, }; NPNR_PACKED_STRUCT(struct DefaultCellConnPOD { int32_t pin_name; // constid int32_t value; // CellPinValue }); NPNR_PACKED_STRUCT(struct DefaultCellConnsPOD { int32_t cell_type; // constid RelSlice pins; }); NPNR_PACKED_STRUCT(struct ConstantsPOD { // Cell type and port for the GND and VCC global source. int32_t gnd_cell_name; // constid int32_t gnd_cell_port; // constid int32_t vcc_cell_name; // constid int32_t vcc_cell_port; // constid int32_t gnd_bel_tile; int32_t gnd_bel_index; int32_t gnd_bel_pin; // constid int32_t vcc_bel_tile; int32_t vcc_bel_index; int32_t vcc_bel_pin; // constid // Name to use for the global GND constant net int32_t gnd_net_name; // constid // Name to use for the global VCC constant net int32_t vcc_net_name; // constid // If a choice is available, which constant net should be used?
/* Copyright 2018 Jack Humbert
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once

/*              RGB COLORS             */
#define RGB_WHITE 0xFF, 0xFF, 0xFF
#define RGB_RED 0xFF, 0x00, 0x00
#define RGB_CORAL 0xFF, 0x7C, 0x4D
#define RGB_ORANGE 0xFF, 0x80, 0x00
#define RGB_GOLDENROD 0xD9, 0xA5, 0x21
#define RGB_GOLD 0xFF, 0xD9, 0x00
#define RGB_YELLOW 0xFF, 0xFF, 0x00
#define RGB_CHARTREUSE 0x80, 0xFF, 0x00
#define RGB_GREEN 0x00, 0xFF, 0x00
#define RGB_SPRINGGREEN 0x00, 0xFF, 0x80
#define RGB_TURQUOISE 0x47, 0x6E, 0x6A
#define RGB_TEAL 0x00, 0x80, 0x80
#define RGB_CYAN 0x00, 0xFF, 0xFF
#define RGB_AZURE 0x99, 0xf5, 0xFF
#define RGB_BLUE 0x00, 0x00, 0xFF
#define RGB_PURPLE 0x7A, 0x00, 0xFF
#define RGB_MAGENTA 0xFF, 0x00, 0xFF
#define RGB_PINK 0xFF, 0x80, 0xBF

/*            HSV COLORS            */
#define HSV_WHITE 0, 0, 255
#define HSV_RED 0, 255, 255
#define HSV_CORAL 11, 176, 255
#define HSV_ORANGE 28, 255, 255
#define HSV_GOLDENROD 30, 218, 218
#define HSV_GOLD 36, 255, 255
#define HSV_YELLOW 43, 255, 255
#define HSV_CHARTREUSE 64, 255, 255
#define HSV_GREEN 85, 255, 255
#define HSV_SPRINGGREEN 106, 255, 255
#define HSV_TURQUOISE 123, 90, 112
#define HSV_TEAL 128, 255, 128
#define HSV_CYAN 128, 255, 255
#define HSV_AZURE 132, 102, 255
#define HSV_BLUE 170, 255, 255
#define HSV_PURPLE 191, 255, 255
#define HSV_MAGENTA 213, 255, 255
#define HSV_PINK 234, 128, 255

/*
########################################################################################
##                                                                                    ##
##                                                                                    ##
##                                                                                    ##
##  The functions below have been deprecated and may be removed in a future release.  ##
##                                                                                    ##
##                Please use the values above with the RGB functions.                 ##
##                                                                                    ##
##                                                                                    ##
##                                                                                    ##
########################################################################################
*/

/*                            SET RGB List                            */
#define rgblight_setrgb_white() rgblight_setrgb(RGB_WHITE)
#define rgblight_setrgb_red() rgblight_setrgb(RGB_RED)
#define rgblight_setrgb_coral() rgblight_setrgb(RGB_CORAL)
#define rgblight_setrgb_orange() rgblight_setrgb(RGB_ORANGE)
#define rgblight_setrgb_goldenrod() rgblight_setrgb(RGB_GOLDENROD)
#define rgblight_setrgb_gold() rgblight_setrgb(RGB_GOLD)
#define rgblight_setrgb_yellow() rgblight_setrgb(RGB_YELLOW)
#define rgblight_setrgb_chartreuse() rgblight_setrgb(RGB_CHARTREUSE)
#define rgblight_setrgb_green() rgblight_setrgb(RGB_GREEN)
#define rgblight_setrgb_springgreen() rgblight_setrgb(RGB_SPRINGGREEN)
#define rgblight_setrgb_turquoise() rgblight_setrgb(RGB_TURQUOISE)
#define rgblight_setrgb_teal() rgblight_setrgb(RGB_TEAL)
#define rgblight_setrgb_cyan() rgblight_setrgb(RGB_CYAN)
#define rgblight_setrgb_azure() rgblight_setrgb(RGB_AZURE)
#define rgblight_setrgb_blue() rgblight_setrgb(RGB_BLUE)
#define rgblight_setrgb_purple() rgblight_setrgb(RGB_PURPLE)
#define rgblight_setrgb_magenta() rgblight_setrgb(RGB_MAGENTA)
#define rgblight_setrgb_pink() rgblight_setrgb(RGB_PINK)

/*                            SET RGB List                            */
#define rgblight_setrgb_white_at(at) rgblight_setrgb_at(RGB_WHITE, at)
#define rgblight_setrgb_red_at(at) rgblight_setrgb_at(RGB_RED, at)
#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at(RGB_CORAL, at)
#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at(RGB_ORANGE at)
#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at(RGB_GOLDENROD, at)
#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at(RGB_GOLD, at)
#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at(RGB_YELLOW, at)
#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at(RGB_CHARTREUSE, at)
#define rgblight_setrgb_green_at(at) rgblight_setrgb_at(RGB_GREEN, at)
#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at(RGB_SPRINGGREEN, at)
#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at(RGB_TURQUOISE, at)
#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at(RGB_TEAL, at)
#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at(RGB_CYAN, at)
#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at(RGB_AZURE, at)
#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at(RGB_BLUE, at)
#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at(RGB_PURPLE, at)
#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at(RGB_MAGENTA, at)
#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at(RGB_PINK, at)

/*                            SET HSV List                            */
#define rgblight_sethsv_white() rgblight_sethsv(HSV_WHITE)
#define rgblight_sethsv_red() rgblight_sethsv(HSV_RED)
#define rgblight_sethsv_coral() rgblight_sethsv(HSV_CORAL)
#define rgblight_sethsv_orange() rgblight_sethsv(HSV_ORANGE)
#define rgblight_sethsv_goldenrod() rgblight_sethsv(HSV_GOLDENROD)
#define rgblight_sethsv_gold() rgblight_sethsv(HSV_GOLD)
#define rgblight_sethsv_yellow() rgblight_sethsv(HSV_YELLOW)
#define rgblight_sethsv_chartreuse() rgblight_sethsv(HSV_CHARTREUSE)
#define rgblight_sethsv_green() rgblight_sethsv(HSV_GREEN)
#define rgblight_sethsv_springgreen() rgblight_sethsv(HSV_SPRINGGREEN)
#define rgblight_sethsv_turquoise() rgblight_sethsv(HSV_TURQUOISE)
#define rgblight_sethsv_teal() rgblight_sethsv(HSV_TEAL)
#define rgblight_sethsv_cyan() rgblight_sethsv(HSV_CYAN)
#define rgblight_sethsv_azure() rgblight_sethsv(HSV_AZURE)
#define rgblight_sethsv_blue() rgblight_sethsv(HSV_BLUE)
#define rgblight_sethsv_purple() rgblight_sethsv(HSV_PURPLE)
#define rgblight_sethsv_magenta() rgblight_sethsv(HSV_MAGENTA)
#define rgblight_sethsv_pink() rgblight_sethsv(HSV_PINK)

/*                            SET HSV List                            */
/*   If you're doing layer indication, this is best, as it won't      */
/*   write to the eeprom, since it's limited (very high value).       */
/*   If you want to use modes with this (since you can), then you     */
/*   want to use rgblight_mode_noeeprom(x) instead.                   */
#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom(HSV_WHITE)
#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom(HSV_RED)
#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom(HSV_CORAL)
#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom(HSV_ORANGE)
#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom(HSV_GOLDENROD)
#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom(HSV_GOLD)
#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom(HSV_YELLOW)
#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom(HSV_CHARTREUSE)
#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom(HSV_GREEN)
#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom(HSV_SPRINGGREEN)
#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom(HSV_TURQUOISE)
#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom(HSV_TEAL)
#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom(HSV_CYAN)
#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom(HSV_AZURE)
#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom(HSV_BLUE)
#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom(HSV_PURPLE)
#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom(HSV_MAGENTA)
#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom(HSV_PINK)

/*                            SET HSV List                            */
#define rgblight_sethsv_white_at(at) rgblight_sethsv_at(HSV_WHITE, at)
#define rgblight_sethsv_red_at(at) rgblight_sethsv_at(HSV_RED, at)
#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at(HSV_CORAL, at)
#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at(HSV_ORANGE, at)
#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at(HSV_GOLDENROD, at)
#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at(HSV_GOLD, at)
#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at(HSV_YELLOW, at)
#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at(HSV_CHARTREUSE, at)
#define rgblight_sethsv_green_at(at) rgblight_sethsv_at(HSV_GREEN, at)
#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at(HSV_SPRINGGREEN, at)
#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at(HSV_TURQUOISE, at)
#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at(HSV_TEAL, at)
#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at(HSV_CYAN, at)
#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at(HSV_AZURE, at)
#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at(HSV_BLUE, at)
#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at(HSV_PURPLE, at)
#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at(HSV_MAGENTA, at)
#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at(HSV_PINK, at)