Initial code for GateMate
This commit is contained in:
parent
d810aac867
commit
6cf832e9b0
@ -1,4 +1,4 @@
|
|||||||
set(HIMBAECHEL_UARCHES "example;gowin;xilinx;ng-ultra")
|
set(HIMBAECHEL_UARCHES "example;gowin;xilinx;ng-ultra;gatemate")
|
||||||
foreach(uarch ${HIMBAECHEL_UARCHES})
|
foreach(uarch ${HIMBAECHEL_UARCHES})
|
||||||
add_subdirectory(${family}/uarch/${uarch})
|
add_subdirectory(${family}/uarch/${uarch})
|
||||||
aux_source_directory(${family}/uarch/${uarch} HM_UARCH_FILES)
|
aux_source_directory(${family}/uarch/${uarch} HM_UARCH_FILES)
|
||||||
|
38
himbaechel/uarch/gatemate/CMakeLists.txt
Normal file
38
himbaechel/uarch/gatemate/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
message(STATUS "Configuring Himbaechel-GateMate uarch")
|
||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
project(himbaechel-gatemate-chipdb NONE)
|
||||||
|
|
||||||
|
set(HIMBAECHEL_PEPPERCORN_PATH "" CACHE STRING
|
||||||
|
"Path to a Project Peppercorn database scripts")
|
||||||
|
|
||||||
|
set(ALL_HIMBAECHE_GATEMATE_DEVICES CCGM1A1 CCGM1A2 CCGM1A4 CCGM1A9 CCGM1A16 CCGM1A25)
|
||||||
|
set(HIMBAECHEL_GATEMATE_DEVICES "" CACHE STRING
|
||||||
|
"Include support for these GateMate devices (available: ${ALL_HIMBAECHE_GATEMATE_DEVICES})")
|
||||||
|
message(STATUS "Enabled Himbaechel-GateMate devices: ${HIMBAECHEL_GATEMATE_DEVICES}")
|
||||||
|
|
||||||
|
set(chipdb_binaries)
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate)
|
||||||
|
foreach(device ${HIMBAECHEL_GATEMATE_DEVICES})
|
||||||
|
set(device_bba ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate/chipdb-${device}.bba)
|
||||||
|
set(device_bin ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate/chipdb-${device}.bin)
|
||||||
|
if("${HIMBAECHEL_PEPPERCORN_PATH}" STREQUAL "")
|
||||||
|
message(SEND_ERROR "HIMBAECHEL_PEPPERCORN_PATH must be set to a Project Peppercorn checkout")
|
||||||
|
endif()
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${device_bin}
|
||||||
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py --device ${device} --bba ${device_bba} --lib ${HIMBAECHEL_PEPPERCORN_PATH}/gatemate
|
||||||
|
COMMAND bbasm ${BBASM_ENDIAN_FLAG} ${device_bba} ${device_bin}.new
|
||||||
|
# atomically update
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E rename ${device_bin}.new ${device_bin}
|
||||||
|
DEPENDS
|
||||||
|
bbasm
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/gen/arch_gen.py
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/constids.inc
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/gfxids.inc
|
||||||
|
VERBATIM)
|
||||||
|
list(APPEND chipdb_binaries ${device_bin})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(chipdb-himbaechel-gatemate ALL DEPENDS ${chipdb_binaries})
|
||||||
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/share/himbaechel/gatemate/ DESTINATION share/nextpnr/himbaechel/gatemate
|
||||||
|
PATTERN "*.bba" EXCLUDE)
|
36
himbaechel/uarch/gatemate/constids.inc
Normal file
36
himbaechel/uarch/gatemate/constids.inc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
X(CPE)
|
||||||
|
X(CPE_BIG)
|
||||||
|
X(CPE_SML)
|
||||||
|
|
||||||
|
X(RAM_I1)
|
||||||
|
X(RAM_I2)
|
||||||
|
X(IN1)
|
||||||
|
X(IN2)
|
||||||
|
X(IN3)
|
||||||
|
X(IN4)
|
||||||
|
X(IN5)
|
||||||
|
X(IN6)
|
||||||
|
X(IN7)
|
||||||
|
X(IN8)
|
||||||
|
X(CLK)
|
||||||
|
X(EN)
|
||||||
|
X(SR)
|
||||||
|
X(CINX)
|
||||||
|
X(PINX)
|
||||||
|
X(CINY1)
|
||||||
|
X(PINY1)
|
||||||
|
X(CINY2)
|
||||||
|
X(PINY2)
|
||||||
|
X(OUT1)
|
||||||
|
X(OUT2)
|
||||||
|
X(RAM_O1)
|
||||||
|
X(RAM_O2)
|
||||||
|
X(COUTX)
|
||||||
|
X(POUTX)
|
||||||
|
X(COUTY1)
|
||||||
|
X(POUTY1)
|
||||||
|
X(COUTY2)
|
||||||
|
X(POUTY2)
|
||||||
|
|
||||||
|
X(GPIO)
|
||||||
|
|
35
himbaechel/uarch/gatemate/extra_data.h
Normal file
35
himbaechel/uarch/gatemate/extra_data.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 The Project Peppercorn 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 GATEMATE_EXTRA_DATA_H
|
||||||
|
#define GATEMATE_EXTRA_DATA_H
|
||||||
|
|
||||||
|
#include "nextpnr.h"
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
NPNR_PACKED_STRUCT(struct GateMatePipExtraDataPOD {
|
||||||
|
int32_t name;
|
||||||
|
uint16_t bits;
|
||||||
|
uint16_t value;
|
||||||
|
});
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif
|
92
himbaechel/uarch/gatemate/gatemate.cc
Normal file
92
himbaechel/uarch/gatemate/gatemate.cc
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 The Project Peppercorn 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "extra_data.h"
|
||||||
|
#include "himbaechel_api.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "nextpnr.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "himbaechel_helpers.h"
|
||||||
|
|
||||||
|
#include "gatemate.h"
|
||||||
|
|
||||||
|
#define GEN_INIT_CONSTIDS
|
||||||
|
#define HIMBAECHEL_CONSTIDS "uarch/gatemate/constids.inc"
|
||||||
|
#define HIMBAECHEL_GFXIDS "uarch/gatemate/gfxids.inc"
|
||||||
|
#define HIMBAECHEL_UARCH gatemate
|
||||||
|
|
||||||
|
#include "himbaechel_constids.h"
|
||||||
|
#include "himbaechel_gfxids.h"
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
GateMateImpl::~GateMateImpl() {};
|
||||||
|
|
||||||
|
void GateMateImpl::init_database(Arch *arch)
|
||||||
|
{
|
||||||
|
const ArchArgs &args = arch->args;
|
||||||
|
init_uarch_constids(arch);
|
||||||
|
arch->load_chipdb(stringf("gatemate/chipdb-%s.bin", args.device.c_str()));
|
||||||
|
arch->set_speed_grade("DEFAULT");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GateMateImpl::init(Context *ctx)
|
||||||
|
{
|
||||||
|
h.init(ctx);
|
||||||
|
HimbaechelAPI::init(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GateMateImpl::drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc)
|
||||||
|
{
|
||||||
|
GraphicElement el;
|
||||||
|
el.type = GraphicElement::TYPE_BOX;
|
||||||
|
el.style = style;
|
||||||
|
switch (bel_type.index) {
|
||||||
|
case id_CPE.index:
|
||||||
|
el.x1 = loc.x + 0.70;
|
||||||
|
el.x2 = el.x1 + 0.20;
|
||||||
|
el.y1 = loc.y + 0.55;
|
||||||
|
el.y2 = el.y1 + 0.40;
|
||||||
|
g.push_back(el);
|
||||||
|
break;
|
||||||
|
case id_GPIO.index:
|
||||||
|
el.x1 = loc.x + 0.20;
|
||||||
|
el.x2 = el.x1 + 0.60;
|
||||||
|
el.y1 = loc.y + 0.20;
|
||||||
|
el.y2 = el.y1 + 0.60;
|
||||||
|
g.push_back(el);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct GateMateArch : HimbaechelArch
|
||||||
|
{
|
||||||
|
GateMateArch() : HimbaechelArch("gatemate") {};
|
||||||
|
bool match_device(const std::string &device) override
|
||||||
|
{
|
||||||
|
return device.size() > 6 && device.substr(0, 6) == "CCGM1A";
|
||||||
|
}
|
||||||
|
std::unique_ptr<HimbaechelAPI> create(const std::string &device, const dict<std::string, std::string> &args)
|
||||||
|
{
|
||||||
|
return std::make_unique<GateMateImpl>();
|
||||||
|
}
|
||||||
|
} gateMateArch;
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
47
himbaechel/uarch/gatemate/gatemate.h
Normal file
47
himbaechel/uarch/gatemate/gatemate.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 The Project Peppercorn 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 HIMBAECHEL_GATEMATE_H
|
||||||
|
#define HIMBAECHEL_GATEMATE_H
|
||||||
|
|
||||||
|
#include "extra_data.h"
|
||||||
|
#include "himbaechel_api.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "nextpnr.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "himbaechel_helpers.h"
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
struct GateMateImpl : HimbaechelAPI
|
||||||
|
{
|
||||||
|
~GateMateImpl();
|
||||||
|
void init_database(Arch *arch) override;
|
||||||
|
|
||||||
|
void init(Context *ctx) override;
|
||||||
|
|
||||||
|
void drawBel(std::vector<GraphicElement> &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
HimbaechelHelpers h;
|
||||||
|
};
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
||||||
|
#endif
|
91
himbaechel/uarch/gatemate/gen/arch_gen.py
Normal file
91
himbaechel/uarch/gatemate/gen/arch_gen.py
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
#
|
||||||
|
# nextpnr -- Next Generation Place and Route
|
||||||
|
#
|
||||||
|
# Copyright (C) 2024 The Project Peppercorn 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
from os import path
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
sys.path.append(path.join(path.dirname(__file__), "../../.."))
|
||||||
|
from himbaechel_dbgen.chip import *
|
||||||
|
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--lib", help="Project Peppercorn python database script path", type=str, required=True)
|
||||||
|
parser.add_argument("--device", help="name of device to export", type=str, required=True)
|
||||||
|
parser.add_argument("--bba", help="bba file to write", type=str, required=True)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
sys.path.append(os.path.expanduser(args.lib))
|
||||||
|
sys.path += args.lib
|
||||||
|
import die
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PipExtraData(BBAStruct):
|
||||||
|
name: IdString
|
||||||
|
bits: int = 0
|
||||||
|
value: int = 0
|
||||||
|
|
||||||
|
def serialise_lists(self, context: str, bba: BBAWriter):
|
||||||
|
pass
|
||||||
|
def serialise(self, context: str, bba: BBAWriter):
|
||||||
|
bba.u32(self.name.index)
|
||||||
|
bba.u16(self.bits)
|
||||||
|
bba.u16(self.value)
|
||||||
|
|
||||||
|
def set_timings(ch):
|
||||||
|
speed = "DEFAULT"
|
||||||
|
tmg = ch.set_speed_grades([speed])
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Range needs to be +1, but we are adding +2 more to coordinates, since
|
||||||
|
# they are starting from -2 instead of zero required for nextpnr
|
||||||
|
ch = Chip("gatemate", args.device, die.max_col() + 3, die.max_row() + 3)
|
||||||
|
# Init constant ids
|
||||||
|
ch.strs.read_constids(path.join(path.dirname(__file__), "..", "constids.inc"))
|
||||||
|
ch.read_gfxids(path.join(path.dirname(__file__), "..", "gfxids.inc"))
|
||||||
|
|
||||||
|
for type_name in die.get_tile_type_list():
|
||||||
|
tt = ch.create_tile_type(type_name)
|
||||||
|
for group in die.get_groups_for_type(type_name):
|
||||||
|
tt.create_group(group.name, group.type)
|
||||||
|
for wire in die.get_endpoints_for_type(type_name):
|
||||||
|
tt.create_wire(wire.name, wire.type)
|
||||||
|
for prim in die.get_primitives_for_type(type_name):
|
||||||
|
bel = tt.create_bel(prim.name, prim.type, prim.z)
|
||||||
|
for pin in die.get_primitive_pins(prim.name):
|
||||||
|
tt.add_bel_pin(bel, pin.name, f"{prim.name}.{pin.name}", pin.dir)
|
||||||
|
for mux in die.get_mux_connections_for_type(type_name):
|
||||||
|
pp = tt.create_pip(mux.src, mux.dst)
|
||||||
|
pp.extra_data = PipExtraData(ch.strs.id(mux.name), mux.bits, mux.value)
|
||||||
|
|
||||||
|
# Setup tile grid
|
||||||
|
for x in range(die.max_col() + 3):
|
||||||
|
for y in range(die.max_row() + 3):
|
||||||
|
ch.set_tile_type(x, y, die.get_tile_type(x - 2,y - 2))
|
||||||
|
# Create nodes between tiles
|
||||||
|
for _,nodes in die.get_connections():
|
||||||
|
node = []
|
||||||
|
for conn in nodes:
|
||||||
|
node.append(NodeWire(conn.x + 2, conn.y + 2, conn.name))
|
||||||
|
ch.add_node(node)
|
||||||
|
set_timings(ch)
|
||||||
|
ch.write_bba(args.bba)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
0
himbaechel/uarch/gatemate/gfxids.inc
Normal file
0
himbaechel/uarch/gatemate/gfxids.inc
Normal file
Loading…
Reference in New Issue
Block a user