-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
340 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 gr in die.get_groups_for_type(type_name): | ||
tt.create_group(gr["name"], gr["type"]) | ||
for ep in die.get_endpoints_for_type(type_name): | ||
tt.create_wire(ep["name"], ep["type"]) | ||
for bl in die.get_bels_for_type(type_name): | ||
bel = tt.create_bel(bl["name"], bl["type"], bl["z"]) | ||
for pin_name,pin_val in die.get_bel_pins(bl["name"]): | ||
tt.add_bel_pin(bel, pin_name, f"{bl["name"]}.{pin_name}", pin_val[0]) | ||
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["mux"]), 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 n in nodes: | ||
node.append(NodeWire(n["x"]+2, n["y"]+2, n["w"])) | ||
ch.add_node(node) | ||
set_timings(ch) | ||
ch.write_bba(args.bba) | ||
|
||
if __name__ == '__main__': | ||
main() |
Empty file.