2023-06-30 15:18:14 +08:00
|
|
|
#ifndef GOWIN_H
|
|
|
|
#define GOWIN_H
|
|
|
|
|
|
|
|
#include "nextpnr.h"
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
namespace {
|
2023-07-05 10:49:25 +08:00
|
|
|
// Return true if a cell is a LUT
|
|
|
|
inline bool type_is_lut(IdString cell_type) { return cell_type.in(id_LUT1, id_LUT2, id_LUT3, id_LUT4); }
|
|
|
|
inline bool is_lut(const CellInfo *cell) { return type_is_lut(cell->type); }
|
|
|
|
// Return true if a cell is a DFF
|
|
|
|
inline bool type_is_dff(IdString cell_type)
|
2023-06-30 15:18:14 +08:00
|
|
|
{
|
2023-07-05 10:49:25 +08:00
|
|
|
return cell_type.in(id_DFF, id_DFFE, id_DFFN, id_DFFNE, id_DFFS, id_DFFSE, id_DFFNS, id_DFFNSE, id_DFFR, id_DFFRE,
|
|
|
|
id_DFFNR, id_DFFNRE, id_DFFP, id_DFFPE, id_DFFNP, id_DFFNPE, id_DFFC, id_DFFCE, id_DFFNC,
|
|
|
|
id_DFFNCE);
|
|
|
|
}
|
|
|
|
inline bool is_dff(const CellInfo *cell) { return type_is_dff(cell->type); }
|
|
|
|
// Return true if a cell is a ALU
|
|
|
|
inline bool type_is_alu(IdString cell_type) { return cell_type == id_ALU; }
|
|
|
|
inline bool is_alu(const CellInfo *cell) { return type_is_alu(cell->type); }
|
2023-07-06 12:48:44 +08:00
|
|
|
|
2023-08-06 18:56:08 +08:00
|
|
|
inline bool type_is_diffio(IdString cell_type)
|
|
|
|
{
|
|
|
|
return cell_type.in(id_ELVDS_IOBUF, id_ELVDS_IBUF, id_ELVDS_TBUF, id_ELVDS_OBUF, id_TLVDS_IOBUF, id_TLVDS_IBUF,
|
|
|
|
id_TLVDS_TBUF, id_TLVDS_OBUF);
|
|
|
|
}
|
|
|
|
inline bool is_diffio(const CellInfo *cell) { return type_is_diffio(cell->type); }
|
|
|
|
|
2024-02-09 15:44:57 +08:00
|
|
|
// IOLOGIC input and output separately
|
|
|
|
|
|
|
|
inline bool type_is_iologico(IdString cell_type)
|
|
|
|
{
|
|
|
|
return cell_type.in(id_ODDR, id_ODDRC, id_OSER4, id_OSER8, id_OSER10, id_OVIDEO);
|
|
|
|
}
|
|
|
|
inline bool is_iologico(const CellInfo *cell) { return type_is_iologico(cell->type); }
|
|
|
|
|
|
|
|
inline bool type_is_iologici(IdString cell_type)
|
2023-08-08 08:57:45 +08:00
|
|
|
{
|
2024-11-27 16:57:34 +08:00
|
|
|
return cell_type.in(id_IDDR, id_IDDRC, id_IDES4, id_IDES8, id_IDES10, id_IVIDEO, id_IOLOGICI_EMPTY);
|
2023-08-08 08:57:45 +08:00
|
|
|
}
|
2024-02-09 15:44:57 +08:00
|
|
|
inline bool is_iologici(const CellInfo *cell) { return type_is_iologici(cell->type); }
|
2023-08-06 18:56:08 +08:00
|
|
|
|
2023-07-06 12:48:44 +08:00
|
|
|
// Return true if a cell is a SSRAM
|
|
|
|
inline bool type_is_ssram(IdString cell_type) { return cell_type.in(id_RAM16SDP1, id_RAM16SDP2, id_RAM16SDP4); }
|
|
|
|
inline bool is_ssram(const CellInfo *cell) { return type_is_ssram(cell->type); }
|
2023-07-23 14:46:04 +08:00
|
|
|
|
gowin: Himbaechel. Add BSRAM for all chips.
The following primitives are implemented for the GW1N-1, GW2A-18,
GW2AR-18C, GW1NSR-4C, GW1NR-9C, GW1NR-9 and GW1N-4 chips:
* pROM - read only memory - (bitwidth: 1, 2, 4, 8, 16, 32).
* pROMX9 - read only memory - (bitwidth: 9, 18, 36).
* SDPB - semidual port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SDPX9B - semidual port - (bitwidth: 9, 18, 36).
* DPB - dual port - (bitwidth: 16).
* DPX9B - dual port - (bitwidth: 18).
* SP - single port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SPX9 - single port - (bitwidth: 9, 18, 36).
For GW1NSR-4C and GW1NR-9 chips, SP/SPX9 primitives with data widths
of 32/36 bits are implemented using a pair of 16-bit wide
primitives.
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
2023-11-26 18:51:16 +08:00
|
|
|
// Return true if a cell is a BSRAM
|
gowin: Himbaechel. Add GW1NZ-1 BSRAM.
The following primitives are implemented for the GW1NZ-1 chip:
* pROM - read only memory - (bitwidth: 1, 2, 4, 8, 16, 32).
* pROMX9 - read only memory - (bitwidth: 9, 18, 36).
* SDPB - semidual port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SDPX9B - semidual port - (bitwidth: 9, 18, 36).
* DPB - dual port - (bitwidth: 16).
* DPX9B - dual port - (bitwidth: 18).
* SP - single port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SPX9 - single port - (bitwidth: 9, 18, 36).
Also:
- The creation of databases for GW1NS-2 has been removed - this was not
planned to be supported in Himbaechel from the very beginning and
even examples were not created in apicula for this chip due to the
lack of boards with it on sale.
- It is temporarily prohibited to connect DFFs and LUTs into clusters
because for some reason this prevents the creation of images on lower
chips (placer cannot find the placement), although without these
clusters the images are quite working. Requires further research.
- Added creation of ALU with mode 0 - addition. Such an element is not
generated by Yosys, but it is a favorite vendor element and its
support here greatly simplifies the compilation of vendor netlists.
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
2023-11-20 10:27:56 +08:00
|
|
|
inline bool type_is_bsram(IdString cell_type)
|
|
|
|
{
|
|
|
|
return cell_type.in(id_SP, id_SPX9, id_pROM, id_pROMX9, id_ROM, id_SDP, id_SDPB, id_SDPX9B, id_DP, id_DPB,
|
|
|
|
id_DPX9B);
|
|
|
|
}
|
2023-10-03 19:11:40 +08:00
|
|
|
inline bool is_bsram(const CellInfo *cell) { return type_is_bsram(cell->type); }
|
|
|
|
|
2024-03-18 20:08:52 +08:00
|
|
|
// Return true if a cell is a DSP
|
|
|
|
inline bool type_is_dsp(IdString cell_type)
|
|
|
|
{
|
|
|
|
return cell_type.in(id_PADD9, id_PADD18, id_MULT9X9, id_MULT18X18, id_MULT36X36, id_ALU54D, id_MULTALU18X18,
|
|
|
|
id_MULTALU36X18, id_MULTADDALU18X18);
|
|
|
|
}
|
|
|
|
inline bool is_dsp(const CellInfo *cell) { return type_is_dsp(cell->type); }
|
|
|
|
|
2024-08-03 21:57:22 +08:00
|
|
|
// Return true if a cell is CLKDIV
|
|
|
|
inline bool type_is_clkdiv(IdString cell_type) { return cell_type == id_CLKDIV; }
|
|
|
|
inline bool is_clkdiv(const CellInfo *cell) { return type_is_clkdiv(cell->type); }
|
|
|
|
|
|
|
|
// Return true if a cell is CLKDIV2
|
|
|
|
inline bool type_is_clkdiv2(IdString cell_type) { return cell_type == id_CLKDIV2; }
|
|
|
|
inline bool is_clkdiv2(const CellInfo *cell) { return type_is_clkdiv2(cell->type); }
|
|
|
|
|
|
|
|
// Return true for HCLK Cells
|
|
|
|
inline bool is_hclk(const CellInfo *cell) { return type_is_clkdiv2(cell->type) || type_is_clkdiv(cell->type); }
|
|
|
|
|
2024-09-04 18:55:35 +08:00
|
|
|
// Return true if a cell is a UserFlash
|
|
|
|
inline bool type_is_userflash(IdString cell_type)
|
|
|
|
{
|
|
|
|
return cell_type.in(id_FLASH96K, id_FLASH256K, id_FLASH608K, id_FLASH128K, id_FLASH64K, id_FLASH64K, id_FLASH64KZ,
|
|
|
|
id_FLASH96KA);
|
|
|
|
}
|
|
|
|
inline bool is_userflash(const CellInfo *cell) { return type_is_userflash(cell->type); }
|
|
|
|
|
2024-09-12 15:53:39 +08:00
|
|
|
// Return true if a cell is a EMCU
|
|
|
|
inline bool type_is_emcu(IdString cell_type) { return cell_type == id_EMCU; }
|
|
|
|
inline bool is_emcu(const CellInfo *cell) { return type_is_emcu(cell->type); }
|
|
|
|
|
2023-08-13 20:05:18 +08:00
|
|
|
// ==========================================
|
2023-07-23 14:46:04 +08:00
|
|
|
// extra data in the chip db
|
2023-08-13 20:05:18 +08:00
|
|
|
// ==========================================
|
2024-04-07 19:47:23 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Pad_extra_data_POD {
|
|
|
|
int32_t pll_tile;
|
|
|
|
int32_t pll_bel;
|
|
|
|
int32_t pll_type;
|
|
|
|
});
|
|
|
|
|
2023-08-13 20:05:18 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Tile_extra_data_POD {
|
|
|
|
int32_t class_id;
|
|
|
|
int16_t io16_x_off;
|
|
|
|
int16_t io16_y_off;
|
|
|
|
});
|
|
|
|
|
2023-07-23 14:46:04 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Bottom_io_cnd_POD {
|
|
|
|
int32_t wire_a_net;
|
|
|
|
int32_t wire_b_net;
|
|
|
|
});
|
|
|
|
|
|
|
|
NPNR_PACKED_STRUCT(struct Bottom_io_POD {
|
|
|
|
// simple OBUF
|
|
|
|
static constexpr int8_t NORMAL = 0;
|
2023-08-06 18:56:08 +08:00
|
|
|
// DDR
|
|
|
|
static constexpr int8_t DDR = 1;
|
2023-07-23 14:46:04 +08:00
|
|
|
RelSlice<Bottom_io_cnd_POD> conditions;
|
|
|
|
});
|
|
|
|
|
2024-07-14 14:53:26 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Spine_bel_POD {
|
|
|
|
int32_t spine;
|
|
|
|
int32_t bel_x;
|
|
|
|
int32_t bel_y;
|
|
|
|
int32_t bel_z;
|
|
|
|
});
|
|
|
|
|
2024-09-11 17:18:26 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Wire_bel_POD {
|
|
|
|
int32_t pip_xy;
|
|
|
|
int32_t pip_dst;
|
|
|
|
int32_t pip_src;
|
|
|
|
int32_t bel_x;
|
|
|
|
int32_t bel_y;
|
|
|
|
int32_t bel_z;
|
|
|
|
int32_t side;
|
|
|
|
});
|
|
|
|
|
2024-10-09 21:16:36 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Constraint_POD {
|
|
|
|
int32_t net;
|
|
|
|
int32_t row;
|
|
|
|
int32_t col;
|
|
|
|
int32_t bel;
|
|
|
|
int32_t iostd;
|
|
|
|
});
|
|
|
|
|
2024-11-27 16:57:34 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Extra_package_data_POD { RelSlice<Constraint_POD> cst; });
|
2024-10-09 21:16:36 +08:00
|
|
|
|
2023-08-06 18:56:08 +08:00
|
|
|
NPNR_PACKED_STRUCT(struct Extra_chip_data_POD {
|
gowin: Himbaechel. Add BSRAM for all chips.
The following primitives are implemented for the GW1N-1, GW2A-18,
GW2AR-18C, GW1NSR-4C, GW1NR-9C, GW1NR-9 and GW1N-4 chips:
* pROM - read only memory - (bitwidth: 1, 2, 4, 8, 16, 32).
* pROMX9 - read only memory - (bitwidth: 9, 18, 36).
* SDPB - semidual port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SDPX9B - semidual port - (bitwidth: 9, 18, 36).
* DPB - dual port - (bitwidth: 16).
* DPX9B - dual port - (bitwidth: 18).
* SP - single port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SPX9 - single port - (bitwidth: 9, 18, 36).
For GW1NSR-4C and GW1NR-9 chips, SP/SPX9 primitives with data widths
of 32/36 bits are implemented using a pair of 16-bit wide
primitives.
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
2023-11-26 18:51:16 +08:00
|
|
|
int32_t chip_flags;
|
2023-08-06 18:56:08 +08:00
|
|
|
Bottom_io_POD bottom_io;
|
|
|
|
RelSlice<IdString> diff_io_types;
|
2024-07-14 14:53:26 +08:00
|
|
|
RelSlice<Spine_bel_POD> dqce_bels;
|
|
|
|
RelSlice<Spine_bel_POD> dcs_bels;
|
2024-09-11 17:18:26 +08:00
|
|
|
RelSlice<Wire_bel_POD> dhcen_bels;
|
gowin: Himbaechel. Add BSRAM for all chips.
The following primitives are implemented for the GW1N-1, GW2A-18,
GW2AR-18C, GW1NSR-4C, GW1NR-9C, GW1NR-9 and GW1N-4 chips:
* pROM - read only memory - (bitwidth: 1, 2, 4, 8, 16, 32).
* pROMX9 - read only memory - (bitwidth: 9, 18, 36).
* SDPB - semidual port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SDPX9B - semidual port - (bitwidth: 9, 18, 36).
* DPB - dual port - (bitwidth: 16).
* DPX9B - dual port - (bitwidth: 18).
* SP - single port - (bitwidth: 1, 2, 4, 8, 16, 32).
* SPX9 - single port - (bitwidth: 9, 18, 36).
For GW1NSR-4C and GW1NR-9 chips, SP/SPX9 primitives with data widths
of 32/36 bits are implemented using a pair of 16-bit wide
primitives.
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
2023-11-26 18:51:16 +08:00
|
|
|
// chip flags
|
2024-06-23 18:26:50 +08:00
|
|
|
static constexpr int32_t HAS_SP32 = 1;
|
|
|
|
static constexpr int32_t NEED_SP_FIX = 2;
|
2024-06-25 16:27:00 +08:00
|
|
|
static constexpr int32_t NEED_BSRAM_OUTREG_FIX = 4;
|
2024-06-28 06:15:50 +08:00
|
|
|
static constexpr int32_t NEED_BLKSEL_FIX = 8;
|
2024-07-06 17:14:43 +08:00
|
|
|
static constexpr int32_t HAS_BANDGAP = 16;
|
2023-08-06 18:56:08 +08:00
|
|
|
});
|
|
|
|
|
2023-08-08 08:57:45 +08:00
|
|
|
} // namespace
|
2023-07-25 11:25:33 +08:00
|
|
|
|
2023-08-08 08:57:45 +08:00
|
|
|
// Bels Z ranges. It is desirable that these numbers be synchronized with the chipdb generator
|
|
|
|
namespace BelZ {
|
|
|
|
enum
|
2023-07-23 14:46:04 +08:00
|
|
|
{
|
2023-08-08 08:57:45 +08:00
|
|
|
LUT0_Z = 0,
|
|
|
|
LUT7_Z = 14,
|
|
|
|
MUX20_Z = 16,
|
|
|
|
MUX21_Z = 18,
|
|
|
|
MUX23_Z = 22,
|
|
|
|
MUX27_Z = 29,
|
|
|
|
ALU0_Z = 30, // :35, 6 ALU
|
|
|
|
RAMW_Z = 36, // RAM16SDP4
|
2023-07-23 14:46:04 +08:00
|
|
|
|
2023-08-08 08:57:45 +08:00
|
|
|
IOBA_Z = 50,
|
|
|
|
IOBB_Z = 51, // +IOBC...IOBL
|
2023-07-23 14:46:04 +08:00
|
|
|
|
2023-08-08 08:57:45 +08:00
|
|
|
IOLOGICA_Z = 70,
|
2024-02-09 15:44:57 +08:00
|
|
|
IDES16_Z = 74,
|
|
|
|
OSER16_Z = 75,
|
2023-08-06 18:56:08 +08:00
|
|
|
|
2024-02-09 15:44:57 +08:00
|
|
|
BUFG_Z = 76, // : 81 reserve just in case
|
2023-10-03 19:11:40 +08:00
|
|
|
BSRAM_Z = 100,
|
2023-09-04 20:20:08 +08:00
|
|
|
|
2023-08-10 19:24:30 +08:00
|
|
|
OSC_Z = 274,
|
2023-08-08 08:57:45 +08:00
|
|
|
PLL_Z = 275,
|
|
|
|
GSR_Z = 276,
|
|
|
|
VCC_Z = 277,
|
2024-03-18 20:08:52 +08:00
|
|
|
VSS_Z = 278,
|
2024-07-06 17:14:43 +08:00
|
|
|
BANDGAP_Z = 279,
|
2024-03-18 20:08:52 +08:00
|
|
|
|
2024-09-11 17:18:26 +08:00
|
|
|
DQCE_Z = 280, // : 286 reserve for 6 DQCEs
|
|
|
|
DCS_Z = 286, // : 288 reserve for 2 DCSs
|
|
|
|
DHCEN_Z = 288, // : 298
|
|
|
|
|
|
|
|
USERFLASH_Z = 298,
|
2024-07-14 14:53:26 +08:00
|
|
|
|
2024-09-12 15:53:39 +08:00
|
|
|
EMCU_Z = 300,
|
|
|
|
|
2024-03-18 20:08:52 +08:00
|
|
|
// The two least significant bits encode Z for 9-bit adders and
|
|
|
|
// multipliers, if they are equal to 0, then we get Z of their common
|
|
|
|
// 18-bit equivalent.
|
|
|
|
DSP_Z = 509, // DSP
|
|
|
|
|
|
|
|
DSP_0_Z = 511, // DSP macro 0
|
|
|
|
PADD18_0_0_Z = 512,
|
|
|
|
PADD9_0_0_Z = 512 + 1,
|
|
|
|
PADD9_0_1_Z = 512 + 2,
|
|
|
|
PADD18_0_1_Z = 516,
|
|
|
|
PADD9_0_2_Z = 516 + 1,
|
|
|
|
PADD9_0_3_Z = 516 + 2,
|
|
|
|
|
|
|
|
MULT18X18_0_0_Z = 520,
|
|
|
|
MULT9X9_0_0_Z = 520 + 1,
|
|
|
|
MULT9X9_0_1_Z = 520 + 2,
|
|
|
|
MULT18X18_0_1_Z = 524,
|
|
|
|
MULT9X9_0_2_Z = 524 + 1,
|
|
|
|
MULT9X9_0_3_Z = 524 + 2,
|
|
|
|
|
|
|
|
ALU54D_0_Z = 524 + 3,
|
|
|
|
MULTALU18X18_0_Z = 528,
|
|
|
|
MULTALU36X18_0_Z = 528 + 1,
|
|
|
|
MULTADDALU18X18_0_Z = 528 + 2,
|
|
|
|
|
|
|
|
MULT36X36_Z = 528 + 3,
|
|
|
|
|
|
|
|
DSP_1_Z = 543, // DSP macro 1
|
|
|
|
PADD18_1_0_Z = 544,
|
|
|
|
PADD9_1_0_Z = 544 + 1,
|
|
|
|
PADD9_1_1_Z = 544 + 2,
|
|
|
|
PADD18_1_1_Z = 548,
|
|
|
|
PADD9_1_2_Z = 548 + 1,
|
|
|
|
PADD9_1_3_Z = 548 + 2,
|
|
|
|
|
|
|
|
MULT18X18_1_0_Z = 552,
|
|
|
|
MULT9X9_1_0_Z = 552 + 1,
|
|
|
|
MULT9X9_1_1_Z = 552 + 2,
|
|
|
|
MULT18X18_1_1_Z = 556,
|
|
|
|
MULT9X9_1_2_Z = 556 + 1,
|
|
|
|
MULT9X9_1_3_Z = 556 + 2,
|
|
|
|
|
|
|
|
ALU54D_1_Z = 556 + 3,
|
|
|
|
MULTALU18X18_1_Z = 560,
|
|
|
|
MULTALU36X18_1_Z = 560 + 1,
|
2024-08-03 21:57:22 +08:00
|
|
|
MULTADDALU18X18_1_Z = 560 + 2,
|
|
|
|
|
|
|
|
// HCLK Bels
|
|
|
|
CLKDIV2_0_Z = 610,
|
|
|
|
CLKDIV2_1_Z = 611,
|
|
|
|
CLKDIV2_2_Z = 612,
|
|
|
|
CLKDIV2_3_Z = 613,
|
|
|
|
|
|
|
|
CLKDIV_0_Z = 620,
|
|
|
|
CLKDIV_1_Z = 621,
|
|
|
|
CLKDIV_2_Z = 622,
|
|
|
|
CLKDIV_3_Z = 623
|
2023-08-08 08:57:45 +08:00
|
|
|
};
|
2023-07-02 14:09:39 +08:00
|
|
|
}
|
|
|
|
|
2023-06-30 15:18:14 +08:00
|
|
|
NEXTPNR_NAMESPACE_END
|
|
|
|
#endif
|