Skip to content

Commit

Permalink
himbächel: Initial implementation
Browse files Browse the repository at this point in the history
Signed-off-by: gatecat <[email protected]>
  • Loading branch information
gatecat committed May 13, 2023
1 parent e3529d3 commit 57b923a
Show file tree
Hide file tree
Showing 28 changed files with 3,176 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/ci/build_himbaechel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

function get_dependencies {
:
}

function build_nextpnr {
mkdir build
pushd build
cmake .. -DARCH=himbaechel
make nextpnr-himbaechel bbasm -j`nproc`
# We'd ideally use pypy3 for speed (as works locally), but the version
# our CI Ubuntu provides doesn't like some of the typing stuff
python3 ../himbaechel/uarch/example/example_arch_gen.py ./example.bba
./bba/bbasm --l ./example.bba ./example.bin
popd
}

function run_tests {
:
}

function run_archcheck {
pushd build
./nextpnr-himbaechel --uarch example --chipdb ./example.bin --test
popd
}
4 changes: 2 additions & 2 deletions .github/workflows/arch_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
arch: [mistral, ice40, ecp5, generic, nexus, machxo2, gowin]
arch: [mistral, ice40, ecp5, generic, nexus, machxo2, gowin, himbaechel]
runs-on: ubuntu-latest
env:
DEPS_PATH: ${{ github.workspace }}/deps
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Install
run: |
sudo apt-get update
sudo apt-get install git make cmake libboost-all-dev python3-dev libeigen3-dev tcl-dev lzma-dev libftdi-dev clang bison flex swig qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools iverilog
sudo apt-get install git make cmake libboost-all-dev python3-dev pypy3 libeigen3-dev tcl-dev lzma-dev libftdi-dev clang bison flex swig qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools iverilog
- name: Cache yosys installation
uses: actions/cache@v3
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ endif()
set(PROGRAM_PREFIX "" CACHE STRING "Name prefix for executables")

# List of families to build
set(FAMILIES generic ice40 ecp5 nexus gowin fpga_interchange machxo2 mistral)
set(FAMILIES generic ice40 ecp5 nexus gowin fpga_interchange machxo2 mistral himbaechel)
set(STABLE_FAMILIES generic ice40 ecp5)
set(EXPERIMENTAL_FAMILIES nexus gowin fpga_interchange machxo2 mistral)
set(EXPERIMENTAL_FAMILIES nexus gowin fpga_interchange machxo2 mistral himbaechel)

set(ARCH "" CACHE STRING "Architecture family for nextpnr build")
set_property(CACHE ARCH PROPERTY STRINGS ${FAMILIES})
Expand Down
26 changes: 26 additions & 0 deletions docs/himbaechel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Himbächel - a series of bigger arches

[Viaduct](./viaduct.md) enables custom architectures to be easily prototyped using a C++ API to build in-memory databases; with most of the flexibility of nextpnr's validity checking capabilities to hand. This is the recommended way to get started quickly with FPGAs up to about 20k logic elements, where no other particularly unusal requirements exist.

However, building the routing graph in-memory at every startup and storing it flat doesn't scale at all well with larger FPGAs (say, 100k LEs or bigger).
So, we take advantage of nextpnr's support for complex, non-flat routing graph structures and define a deduplication approach that's designed to work better even for very large fabrics - the database size is unlikely to exceed about 100MB even for million-LUT scale devices, compared to multiple gigabytes for a flat database.

Python scripting is defined that allows the user to describe a semi-flattened routing graph and build the deduplicated database binary _at compile time_. Pips - routing switches - are described per tile type rather than flat; however, the connectivity between tiles ("nodes") are described flat and automatically deduplicated during database build.

## Getting Started

Most of what's written in the [viaduct docs](./viaduct.md) also applies to bootstrapping a Himbächel arch - this also provides a migration path for an existing Viaduct architecture. Just replace `viaduct` with `himbaechel` and `ViaductAPI` with `HimbaechelAPI` - the set of validity checking and custom flow "hooks" that you have access to is designed to be otherwise as close as possible.

However, the key difference is that you will need to generate a "binary blob" chip database. `himbaechel_dbgen/bba.py` provides a framework for this. The typical steps for using this API would be as follows:
- Create a `Chip` instance
- For each unique "tile type" in the design (e.g. logic, BRAM, IO - in some cases multiple variants of these may be multiple tile types):
- Create it using `Chip.create_tile_type`
- Add local wires (connectivity between tiles is dealt with later) using `TileType.create_wire`
- Add bels (like LUTs and FFs) using `TileType.create_bel`, and pins to those bels using `TileType.add_bel_pin`
- Add pips using `TileType.create_pip`
- For each grid location, use `Chip.set_tile_type` to set its tile type. Every location must have a tile type set, even if it's just an empty "NULL" tile
- Whenever wires span multiple tiles (i.e. all wires with a length greater than zero), combine the per-tile local wires into a single node using `Chip.add_node` for each case.
- Write out the `.bba` file using `Chip.write_bba`
- Compile it into a binary that nextpnr can load using `./bba/bbasm --l my_chipdb.bba my_chipdb.bin`

An example Python generator to copy from is located in `uarch/example/example_arch_gen.py`.
Empty file added gui/himbaechel/family.cmake
Empty file.
52 changes: 52 additions & 0 deletions gui/himbaechel/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Miodrag Milanovic <[email protected]>
*
* 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 "mainwindow.h"

#include <QMessageBox>
#include <cstdlib>

static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }

NEXTPNR_NAMESPACE_BEGIN

MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
: BaseMainWindow(std::move(context), handler, parent)
{
initMainResource();
}

MainWindow::~MainWindow() {}

void MainWindow::newContext(Context *ctx)
{
std::string title = "nextpnr-himbächel - " + ctx->getChipName();
setWindowTitle(title.c_str());
}

void MainWindow::createMenu() {}

void MainWindow::new_proj()
{
QMessageBox::critical(0, "Error",
"Creating a new project not supported in himbächel mode, please re-start from command line.");
std::exit(1);
}

NEXTPNR_NAMESPACE_END
45 changes: 45 additions & 0 deletions gui/himbaechel/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* nextpnr -- Next Generation Place and Route
*
* Copyright (C) 2018 Miodrag Milanovic <[email protected]>
*
* 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 MAINWINDOW_H
#define MAINWINDOW_H

#include "../basewindow.h"

NEXTPNR_NAMESPACE_BEGIN

class MainWindow : public BaseMainWindow
{
Q_OBJECT

public:
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
virtual ~MainWindow();

public:
void createMenu();

protected Q_SLOTS:
void new_proj() override;
void newContext(Context *ctx);
};

NEXTPNR_NAMESPACE_END

#endif // MAINWINDOW_H
2 changes: 2 additions & 0 deletions gui/himbaechel/nextpnr.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<RCC>
</RCC>
1 change: 1 addition & 0 deletions himbaechel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
Loading

0 comments on commit 57b923a

Please sign in to comment.