From 884e7d9a9820a5eaff000a3ee8a5d56d1e15d50b Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Sun, 31 Jan 2021 00:36:19 -0500 Subject: machxo2: Add basic bitstream generation for PIC tiles and I/O. --- machxo2/bitstream.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'machxo2') diff --git a/machxo2/bitstream.cc b/machxo2/bitstream.cc index 1502166a..450ab140 100644 --- a/machxo2/bitstream.cc +++ b/machxo2/bitstream.cc @@ -116,6 +116,26 @@ std::string intstr_or_default(const std::unordered_map &ct, } }; +// Get the PIC tile corresponding to a PIO bel +static std::string get_pic_tile(Context *ctx, BelId bel) +{ + static const std::set pio_l = {"PIC_L0", "PIC_LS0", "PIC_L0_VREF3"}; + static const std::set pio_r = {"PIC_R0", "PIC_RS0"}; + + std::string pio_name = ctx->tileInfo(bel)->bel_data[bel.index].name.get(); + if (bel.location.y == 0) { + return ctx->getTileByTypeAndLocation(0, bel.location.x, "PIC_T0"); + } else if (bel.location.y == ctx->chip_info->height - 1) { + return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, "PIC_B0"); + } else if (bel.location.x == 0) { + return ctx->getTileByTypeAndLocation(bel.location.y, 0, pio_l); + } else if (bel.location.x == ctx->chip_info->width - 1) { + return ctx->getTileByTypeAndLocation(bel.location.y, bel.location.x, pio_r); + } else { + NPNR_ASSERT_FALSE("bad PIO location"); + } +} + void write_bitstream(Context *ctx, std::string text_config_file) { ChipConfig cc; @@ -174,6 +194,12 @@ void write_bitstream(Context *ctx, std::string text_config_file) str_or_default(ci->params, ctx->id("REG0_REGSET"), "RESET")); cc.tiles[tname].add_enum(slice + ".REG1.REGSET", str_or_default(ci->params, ctx->id("REG1_REGSET"), "RESET")); + } else if (ci->type == ctx->id("FACADE_IO")) { + std::string pio = ctx->tileInfo(bel)->bel_data[bel.index].name.get(); + std::string iotype = str_or_default(ci->attrs, ctx->id("IO_TYPE"), "LVCMOS33"); + std::string dir = str_or_default(ci->params, ctx->id("DIR"), "INPUT"); + std::string pic_tile = get_pic_tile(ctx, bel); + cc.tiles[pic_tile].add_enum(pio + ".BASE_TYPE", dir + "_" + iotype); } } -- cgit v1.2.3