Skip to content

Commit

Permalink
Sometimes, fiction was so powerful that it even had reverberations in…
Browse files Browse the repository at this point in the history
… the real world
  • Loading branch information
marcelwa committed Nov 22, 2019
1 parent 85421be commit a6206a7
Show file tree
Hide file tree
Showing 93 changed files with 8,191 additions and 56,616 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.directory
.idea/
cmake-build-*
build/
*.aux
*.log
*.pdf
*.synctex.gz
/.vs
*.json
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "libs/alice"]
path = libs/alice
url = https://github.com/marcelwa/alice.git
[submodule "libs/lorina"]
path = libs/lorina
url = https://github.com/marcelwa/lorina.git
[submodule "libs/cppitertools"]
path = libs/cppitertools
url = https://github.com/marcelwa/cppitertools.git
[submodule "libs/z3"]
path = libs/z3
url = https://github.com/marcelwa/z3.git
[submodule "libs/mockturtle"]
path = libs/mockturtle
url = https://github.com/marcelwa/mockturtle.git
46 changes: 36 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,60 @@
language: cpp

cache: # see https://docs.travis-ci.com/user/caching/
- directories:
- $HOME/.cache

before_install:
# fix linkage error with clang
- export LD_LIBRARY_PATH=/usr/local/clang/lib:$LD_LIBRARY_PATH

before_script:
# install boost libraries
- sudo apt install -qq libboost-all-dev
# activate all python versions
- pyenv global $(pyenv whence 2to3)
# hand-pick python3
- PY_CMD=python3

script:
# create build folder
- mkdir build
- cd build
# set compiler and python executable
- cmake -DCMAKE_CXX_COMPILER=$COMPILER -DPYTHON_EXECUTABLE=$(which $PY_CMD) ..
# build z3 (takes some time)
- travis_wait make -j2 z3
# restore cache if it exists
- ([ ! -f $HOME/.cache/z3 ] || mv $HOME/.cache/z3 ./)
# set compiler, python executable, and Z3 build verbosity
- cmake -DCMAKE_CXX_COMPILER=$COMPILER -DPYTHON_EXECUTABLE=$(which $PY_CMD) -DBUILD_Z3_VERBOSE=TRUE ..
# build Z3 (takes some time) and cache it
- make -j2 z3
- mkdir -p $HOME/.cache
- mv z3/ $HOME/.cache/
# build fiction
- make -j2 fiction
# run integration tests
- ./fiction -ef ../test/integration.fc -l log.json

matrix:
include:
# ubuntu 16.04 gcc/g++7
# ubuntu 18.04 gcc/g++7
- os: linux
dist: xenial
dist: bionic
sudo: required
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- boost-latest
packages:
- libboost-all-dev

# ubuntu 18.04 clang/clang++7
- os: linux
dist: bionic
sudo: required
compiler: clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- boost-latest
packages:
- g++-7
env: COMPILER=g++-7
- libboost-all-dev
65 changes: 61 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,78 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## v0.3.0 - 2019-11-22
*Sometimes, fiction was so powerful that it even had reverberations in the real world.* — Delphine de Vigan

### Added
- Support for iNML technology using [ToPoliNano](https://topolinano.polito.it/)'s gate library and clocking scheme. Thanks to Umberto Garlando for cooperating with me on this project!
- Support for vertically shifted `fcn_layout`s to emulate column-based clocking schemes
- Enhanced `logic_network` by incorporating [mockturtle](https://github.com/lsils/mockturtle) for logic representation
- Truth table store (mnemonic `-t`) and command `tt`. Thanks to Mathias Soeken for granting permission to use code from [CirKit](https://github.com/msoeken/cirkit)!
- Command `simulate` to compute `truth_table`s for `logic_network` and `fcn_gate_layout` objects. Thanks to Mathias Soeken for granting permission to use code from [CirKit](https://github.com/msoeken/cirkit)!
- Command `akers` to perform Akers' Majority synthesis to generate a `logic_network` from a `truth_table`
- Command `random` to generate random `logic_network` objects
- Command `check` to verify structural integrity of designed `fcn_gate_layout` objects
- Command `gates` to list gate counts for each vertex type in the current `logic_network`
- Command `fanouts` to substitute high-degree inputs into fan-out vertices in `logic_network`s using a given strategy
- Command `balance` to subdivide `logic_network` edges to equalize path lengths by inserting auxiliary wire vertices
- Command `qcc` to write `iNML` `cell_layout`s to component files readable by [ToPoliNano and MagCAD](https://topolinano.polito.it/)
- Capability to enforce straight inverter gates in `exact` with flag `-n`
- Capability to minimize the number of used crossing tiles in `exact` with flag `-m`
- Capability to parse AIGER (`*.aig`) files using `read`
- Parameter `-b` for `ortho`
- Progress bars for `exact` and `ortho`
- `show -n` to display `logic_network` objects
- Several convenience functions in the core data structures for easier access
- An overview [paper](./bib/paper.pdf) and a [poster](./bib/poster.pdf) about the features of *fiction*. Please find citation information in the [README](./README.md#references)

### Changed
- Moved to C++17
- Moved to version 1.0 of [cppitertools](https://github.com/ryanhaining/cppitertools)
- Included latest updates for [alice](https://github.com/msoeken/alice)
- Switched `logic_network`'s CLI mnemonic to `-n` as it is no longer reserved by `alice`
- Renamed `pi`/`po_count` to `num_pis`/`pos`
- `read` does no longer substitute fan-outs automatically, `exact` and `ortho` do it instead if the user did not call `fanouts`
- `exact --path_discrepancy/-p` has been renamed to `exact --desynchronize/-d` to express its use case better
- `exact --timeout/-t` expects its parameter in seconds instead of milliseconds now
- `exact --fixed_size/-f` expects its own parameter instead of using `--upper_bound`'s one
- Renamed `version.h` to `version_info.h`
- Renamed *Placement & Routing* to *Physical Design* where appropriate to match the documentation

### Fixed
- Segfault when using `ortho -i` with certain compilers in release mode
- Missing input ports for 3-output fan-out gates in QCA-ONE library
- Wire vertices not handled properly by QCA-ONE library
- Wrong clocking look-up for `BANCS` clocking in `fcn_cell_layout`
- Tile directions when assigning and dissociating multiple edges
- `fcn_layout::random_face`'s index to coordinate mapping (thanks to Till Schlechtweg!)
- Format issues with benchmark files
- Constant outputs of some benchmark files
- Additionally, there are several performance improvements in core data structures and algorithms

### Removed
- Submodule `lorina` as it is included in `mockturtle`
- `verilog_parser.h` as `mockturtle` comes with its own one
- `print -n` as it is replaced by `show -n`
- `operation::BUF`; use `operation::W` instead
- `operation::CONST0`, `operation::CONST1`, and `operation::XOR`
- `operator[x][y][z]` for `fcn_layout`s as it was slow and therefore not used; use `face/tile/cell{x,y,z}` instead

## v0.2.1 - 2019-05-02
*Fiction is art and art is the triumph over chaos.* — John Cheever

### Added
- Support for BANCS clocking and integration in `exact`
- Name strings for `fcn_clocking_scheme` objects and corresponding name-based look-up
- Version and build information accessible within the code by including `version.h`
- Version and build information accessible within the code by including `util/version.h`
- Parameter `-i` for command `ortho`
- `shortcuts.fs` with predefined flows
- `benchmarks/MAJ/` folder with some TOY benchmarks using MAJ gates

### Changed
- Calls to `exact -s` now need to name the desired clocking, e.g. `exact -s use` (case insensitive)
- `incoming`/`outgoing_information_flow_tiles` have been renamed to `incoming`/`outgoing_data_flow` and handle multi wires now
- Renamed diagonal clocking schemes to 2DDWAVE and gave proper credit.
- Renamed diagonal clocking schemes to 2DDWAVE and gave proper credit
- More verbose error messages

### Fixed
Expand Down Expand Up @@ -72,7 +129,7 @@ For more information, see <https://svn.boost.org/trac10/ticket/11735>
- *linguist* flags in `.gitattributes` to prevent benchmark files from being viewed as source code

### Changed
- Moved to version 0.4 of [Alice](https://github.com/msoeken/alice)
- Moved to version 0.4 of [alice](https://github.com/msoeken/alice)
- Moved to version 4.8.4 of [Z3](https://github.com/Z3Prover/z3)
- `fcn_gate_library` objects now have name strings
- `print -g` now displays incorrectly assigned directions by bidirectional arrows
Expand All @@ -89,4 +146,4 @@ For more information, see <https://svn.boost.org/trac10/ticket/11735>
## v0.1.0 - 2018-10-29
*Let there be a fiction*

This is the initial release. Please find a feature overview in the README.
This is the initial release. Please find a feature overview in the [README](README.md).
112 changes: 78 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,73 +1,117 @@
cmake_minimum_required(VERSION 3.2)
project(fiction
LANGUAGES CXX
VERSION 0.2.1)
VERSION 0.3.0)

# C++14
set(CMAKE_CXX_STANDARD 14)
# C++17
set(CMAKE_CXX_STANDARD 17)

# Set debug and release build options
if (MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /w /O2")
else ()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-mismatched-tags -Wno-gnu-anonymous-struct -Wno-nested-anon-types -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w -O3")
endif ()

# Set debug build options
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wpedantic")
# Set release build options
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w -O3")
# Set release mode to default
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
endif ()
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")

# Include header files
include_directories(src/algo/ src/io/ src/tech/ src/topo/ src/util/)
include_directories(src/algo/ src/io/ src/io/cmd/ src/tech/ src/topo/ src/util/)

# Find source files
file(GLOB_RECURSE SOURCES src/*.cpp src/*.h)
# Add configuration file
configure_file(src/util/version.h.in util/version.h)
configure_file(src/util/version_info.h.in util/version_info.h)
# Include configuration file
include_directories(${PROJECT_BINARY_DIR}/util/)

# Require Boost libraries
find_package(Boost COMPONENTS system filesystem REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif()
find_package(Boost COMPONENTS system filesystem)
if (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
else ()
message(STATUS "Please configure Boost_CUSTOM_INCLUDE_DIRS and Boost_CUSTOM_LIBRARY_DIRS manually.")
set(Boost_CUSTOM_INCLUDE_DIRS "" CACHE PATH "Boost include path")
set(Boost_CUSTOM_LIBRARY_DIRS "" CACHE PATH "Boost library path")
include_directories(${Boost_CUSTOM_INCLUDE_DIRS})
link_directories(${Boost_CUSTOM_LIBRARY_DIRS})
endif ()

# Custom install prefix for libraries
set(LIB_PREFIX ${CMAKE_SOURCE_DIR}/libs)

# Clone, build and locally install Z3
include(ExternalProject)
# Set up a directory for Z3 solver
set(Z3_DIR ${CMAKE_BINARY_DIR}/z3)
ExternalProject_Add(z3
SOURCE_DIR ${LIB_PREFIX}/z3/
BUILD_IN_SOURCE 1
INSTALL_DIR ${Z3_DIR}/
CONFIGURE_COMMAND env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
./configure -p <INSTALL_DIR> -b build --staticlib ${Z3_DEBUG}
BUILD_COMMAND make -j3 -C build
INSTALL_COMMAND make -C build install
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_LIST_FILE}
LOG_CONFIGURE 1
LOG_INSTALL 1
LOG_BUILD 1)

if (UNIX)
# Require Python interpreter
find_package(Python COMPONENTS Interpreter)
# Add option to compile Z3 with verbose output
option(BUILD_Z3_VERBOSE "Output status and warnings during Z3 build" OFF)
# Use /dev/null to silence Z3. Not elegant but efficient
if (NOT BUILD_Z3_VERBOSE)
set(Z3_OUTPUT_CHANNEL > /dev/null)
endif ()

# Add option to build Z3 as a static library
option(BUILD_Z3_STATIC_LIB "Build Z3 solver as a static library to link against fiction" OFF)
if (BUILD_Z3_STATIC_LIB)
set(Z3_LIB_FLAG --staticlib)
set(Z3_LINK_TARGET libz3.a)
else ()
set(Z3_LINK_TARGET libz3.so)
endif ()

# include and library paths
set(Z3_INCLUDE_DIR ${Z3_DIR}/include)
set(Z3_LIB_DIR ${Z3_DIR}/lib)

# Build and locally install Z3
add_custom_command(
OUTPUT ${Z3_LIB_DIR}/${Z3_LINK_TARGET}
PRE_BUILD
COMMAND ${Python_EXECUTABLE} scripts/mk_make.py -s --prefix=${Z3_DIR} ${Z3_LIB_FLAG} ${Z3_OUTPUT_CHANNEL}
COMMAND $(MAKE) -C build ${Z3_OUTPUT_CHANNEL}
COMMAND $(MAKE) -C build install ${Z3_OUTPUT_CHANNEL}
WORKING_DIRECTORY ${LIB_PREFIX}/z3/)

# Make sure Z3's custom build commands are actually being executed
add_custom_target(z3
ALL
DEPENDS ${Z3_LIB_DIR}/${Z3_LINK_TARGET})

elseif (WIN32)
set(Z3_LINK_TARGET libz3.lib)
set(Z3_INCLUDE_DIR "${LIB_PREFIX}/z3/src/api" CACHE PATH "Path to Z3's custom include directory")
set(Z3_LIB_DIR "${LIB_PREFIX}/z3/build" CACHE PATH "Path to Z3's custom library directory")
include_directories(${Z3_INCLUDE_DIR}/c++)
endif ()

# Include Z3
include_directories(${Z3_DIR}/include/)
include_directories(${Z3_INCLUDE_DIR}/)

# Include cppitertools
include_directories(${LIB_PREFIX}/cppitertools/)

# Include alice
add_subdirectory(${LIB_PREFIX}/alice/)

# Include lorina
add_subdirectory(${LIB_PREFIX}/lorina/)
# Include mockturtle
add_subdirectory(${LIB_PREFIX}/mockturtle/)

# Build executable
add_executable(fiction ${SOURCES})
add_dependencies(fiction z3)
if (UNIX)
add_dependencies(fiction z3)
endif ()

# Link against Boost, Z3, alice, and lorina
target_link_libraries(fiction ${Boost_LIBRARIES} ${Z3_DIR}/lib/libz3.so alice lorina)
target_link_libraries(fiction ${Boost_LIBRARIES} ${Z3_LIB_DIR}/${Z3_LINK_TARGET} alice mockturtle)
Loading

0 comments on commit a6206a7

Please sign in to comment.