Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parmys (Partial Mapper for Yosys) plugin #421

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
93e53d5
libargparse pugixml
poname Dec 14, 2022
38e19bd
`parmys` plugin
poname Dec 14, 2022
d43f15c
ISC license
poname Dec 14, 2022
d043671
vtr licensing
poname Dec 14, 2022
e7cc4b8
ci
poname Dec 14, 2022
c2fbe0d
Revert "ci"
poname Dec 14, 2022
a900beb
all together
poname Dec 14, 2022
2ec748d
visualization
poname Dec 14, 2022
9cbd08f
block mem bug
poname Dec 14, 2022
b390300
warning
poname Dec 14, 2022
2c0ef3d
ci
poname Dec 14, 2022
1c35cd5
eltwiselayer rm
poname Dec 14, 2022
1751c43
eltwise_layer.v symlink
poname Dec 14, 2022
dd4e2fe
ci
poname Dec 14, 2022
cb5432a
rm files
poname Dec 14, 2022
26d3372
files symlink
poname Dec 14, 2022
4503b03
primitives symlink
poname Dec 14, 2022
ddd1cc2
ci
poname Dec 14, 2022
736593c
VexRiscv_Lite test
poname Dec 14, 2022
38d0795
ci
poname Dec 14, 2022
ba3bc5c
finalized
poname Dec 14, 2022
2d03233
mips32r1_core submodule added
poname Dec 14, 2022
c24e691
mips32r1_core test added
poname Dec 14, 2022
8277a06
all together
poname Dec 14, 2022
4fe1f8f
no libargparse
poname Dec 20, 2022
03b7b79
licensing resolved
poname Dec 20, 2022
30cc0de
Pr issues (#1)
poname Dec 20, 2022
608b352
Vtr dir (#2)
poname Dec 26, 2022
f46b99c
Merge branch 'chipsalliance:main' into parmys-plugin
poname Dec 27, 2022
cfd6c83
g++-11
poname Dec 29, 2022
714e583
g++ v
poname Dec 29, 2022
2b4bfa1
try vtr-optimized
poname Jan 2, 2023
c3c9372
vtr
poname Jan 2, 2023
6310dfe
vtr-libs test
poname Jan 3, 2023
4197e32
typo
poname Jan 3, 2023
5beb999
ci
poname Jan 3, 2023
a237d28
ci 2
poname Jan 3, 2023
3226dce
no vtr
poname Jan 3, 2023
2a908e4
vtr-gui
poname Jan 3, 2023
7b36c74
vtr
poname Jan 3, 2023
54f5f0f
yosys
poname Jan 3, 2023
ef6aaa6
retry
poname Jan 4, 2023
1692770
#2
poname Jan 4, 2023
9d14767
Merge branch 'chipsalliance:main' into lto-issue
poname Jan 4, 2023
5ef45cd
dash
poname Jan 4, 2023
ab0c502
check#3
poname Jan 4, 2023
405d737
Merge remote-tracking branch 'origin/lto-issue' into lto-issue
poname Jan 4, 2023
55bacdc
-lrtlnumber
poname Jan 4, 2023
0a3130a
symlink fixed
poname Jan 4, 2023
7da8d01
smoke test
poname Jan 4, 2023
b9739df
no smoke
poname Jan 4, 2023
7dd1c1a
cas-atlantic::vtr-libs
poname Jan 4, 2023
9d3662a
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jan 4, 2023
6d94ece
cleaned
poname Jan 4, 2023
f1ff515
Merge branch 'lto-issue' into parmys-plugin
poname Jan 4, 2023
4ea5bde
all together
poname Jan 4, 2023
b1617f1
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jan 10, 2023
37f9b11
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jan 13, 2023
528d631
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jan 17, 2023
7c983b7
Merge branch 'main' into parmys-plugin
poname Jan 24, 2023
c9f1f6c
parmys added to ci
poname Jan 24, 2023
1f934cb
Merge branch 'chipsalliance:main' into parmys-plugin
poname Feb 1, 2023
d9c6653
Merge branch 'chipsalliance:main' into parmys-plugin
poname Feb 10, 2023
f2d60ba
code re-order
poname Feb 10, 2023
c697777
done!
poname Feb 10, 2023
8352c5d
format check
poname Feb 10, 2023
504ef2e
all
poname Feb 10, 2023
80befb9
Merge branch 'chipsalliance:main' into parmys-plugin
poname Feb 16, 2023
6d74e34
Merge branch 'chipsalliance:main' into parmys-plugin
poname Feb 22, 2023
ec38226
Merge branch 'chipsalliance:main' into parmys-plugin
poname Mar 2, 2023
2e0ac37
Merge branch 'chipsalliance:main' into parmys-plugin
poname Mar 12, 2023
9507665
Merge branch 'chipsalliance:main' into parmys-plugin
poname Mar 16, 2023
130ac1d
Merge branch 'chipsalliance:main' into parmys-plugin
poname Mar 31, 2023
ed564a5
Merge branch 'chipsalliance:main' into parmys-plugin
poname Apr 13, 2023
0e33db1
Merge branch 'chipsalliance:main' into parmys-plugin
poname Apr 19, 2023
000cdf8
Merge branch 'main' into parmys-plugin
poname May 2, 2023
cc380b0
Merge branch 'chipsalliance:main' into parmys-plugin
poname May 11, 2023
d59c839
Merge branch 'chipsalliance:main' into parmys-plugin
poname May 19, 2023
619d00b
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jun 1, 2023
e1ca934
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jun 13, 2023
e71088c
Merge branch 'chipsalliance:main' into parmys-plugin
poname Jun 23, 2023
87fb759
Merge branch 'chipsalliance:main' into parmys-plugin
poname Aug 14, 2023
8d5cfaf
Merge branch 'chipsalliance:main' into parmys-plugin
poname Sep 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/licensing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,15 @@ jobs:
./design_introspection-plugin/tests/selection_to_tcl_list/selection_to_tcl_list.v
./third_party/minilitex_ddr_arty/minilitex_ddr_arty.v
./third_party/VexRiscv_Lite/VexRiscv_Lite.v
./third_party/vtr/verilog/eltwise_layer.v
./third_party/vtr/verilog/raygentop.v
./third_party/vtr/verilog/hard_block_include.v
./third_party/vtr/arch/k6FracN10LB_mem20K_complexDSP_customSB_22nm.xml
./third_party/vtr/arch/k6_frac_N10_frac_chain_mem32K_40nm.xml
./third_party/vtr/primitives.v
third_party: |
./third_party/googletest/
./third_party/libargparse/
./third_party/pugixml/
./third_party/vtr/
.third_party/mips32r1_core/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@
[submodule "third_party/make-env"]
path = third_party/make-env
url = https://github.com/SymbiFlow/make-env.git
[submodule "third_party/pugixml"]
path = third_party/pugixml
url = https://github.com/zeux/pugixml.git
[submodule "third_party/libargparse"]
path = third_party/libargparse
url = https://github.com/kmurray/libargparse.git
[submodule "third_party/mips32r1_core"]
path = third_party/mips32r1_core
url = https://github.com/grantae/mips32r1_core.git
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# SPDX-License-Identifier: Apache-2.0

PLUGIN_LIST := fasm xdc params sdc ql-iob design_introspection integrateinv ql-qlf systemverilog uhdm dsp-ff
PLUGIN_LIST := fasm xdc params sdc ql-iob design_introspection integrateinv ql-qlf systemverilog uhdm dsp-ff parmys
PLUGINS := $(foreach plugin,$(PLUGIN_LIST),$(plugin).so)
PLUGINS_INSTALL := $(foreach plugin,$(PLUGIN_LIST),install_$(plugin))
PLUGINS_CLEAN := $(foreach plugin,$(PLUGIN_LIST),clean_$(plugin))
Expand Down
112 changes: 112 additions & 0 deletions parmys-plugin/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright 2022 Daniel Khadivi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

PLUGIN_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))

NAME = parmys
SOURCES = parmys.cc \
parmys_arch.cc \
parmys_update.cc \
parmys_utils.cc \
parmys_resolve.cc \
src/adders.cc \
src/enum_str.cc \
src/MixingOptimization.cc \
src/read_xml_config_file.cc \
src/odin_error.cc \
src/odin_util.cc \
src/netlist_statistic.cc \
src/netlist_utils.cc \
src/netlist_check.cc \
src/netlist_cleanup.cc \
src/node_creation_library.cc \
src/multipliers.cc \
src/subtractions.cc \
src/HardSoftLogicMixer.cc \
src/odin_ii.cc \
src/string_cache.cc \
src/partial_map.cc \
src/hard_blocks.cc \
src/BlockMemories.cc \
src/memories.cc \
src/netlist_visualizer.cc \
src/Hashtable.cc \
src/ast_util.cc \
../third_party/vtr/libs/vtrutil/src/vtr_util.cc \
../third_party/vtr/libs/vtrutil/src/vtr_token.cc \
../third_party/vtr/libs/vtrutil/src/vtr_memory.cc \
../third_party/vtr/libs/vtrutil/src/vtr_list.cc \
../third_party/vtr/libs/vtrutil/src/vtr_log.cc \
../third_party/vtr/libs/vtrutil/src/vtr_expr_eval.cc \
../third_party/vtr/libs/vtrutil/src/vtr_digest.cc \
../third_party/vtr/libs/vtrutil/src/vtr_math.cc \
../third_party/vtr/libs/vtrutil/src/vtr_path.cc \
../third_party/vtr/libs/vtrutil/src/vtr_assert.cc \
../third_party/vtr/libs/log/src/log.cc \
../third_party/pugixml/src/pugixml.cpp \
../third_party/libargparse/src/argparse.cpp \
../third_party/libargparse/src/argparse_formatter.cpp \
../third_party/libargparse/src/argparse_util.cpp \
../third_party/vtr/libs/rtlnumber/src/rtl_int.cc \
../third_party/vtr/libs/rtlnumber/src/rtl_utils.cc \
../third_party/vtr/libs/pugiutil/src/pugixml_loc.cc \
../third_party/vtr/libs/pugiutil/src/pugixml_util.cc \
../third_party/vtr/libs/archfpga/src/physical_types.cc \
../third_party/vtr/libs/archfpga/src/read_xml_util.cc \
../third_party/vtr/libs/archfpga/src/arch_error.cc \
../third_party/vtr/libs/archfpga/src/physical_types_util.cc \
../third_party/vtr/libs/archfpga/src/arch_check.cc \
../third_party/vtr/libs/archfpga/src/arch_util.cc \
../third_party/vtr/libs/archfpga/src/read_xml_arch_file.cc \
../third_party/vtr/libs/archfpga/src/parse_switchblocks.cc \
../third_party/vtr/libs/archfpga/src/echo_arch.cc

include ../Makefile_plugin.common

CXXFLAGS += -I./include
CXXFLAGS += -I../third_party/pugixml/src
CXXFLAGS += -I../third_party/libargparse/src
CXXFLAGS += -I../third_party/vtr/libs/archfpga/src
CXXFLAGS += -I../third_party/vtr/libs/log/src
CXXFLAGS += -I../third_party/vtr/libs/pugiutil/src
CXXFLAGS += -I../third_party/vtr/libs/rtlnumber/src/include
CXXFLAGS += -I../third_party/vtr/libs/rtlnumber/src
CXXFLAGS += -I../third_party/vtr/libs/vtrutil/src
CXXFLAGS += -I../third_party/vtr/libs/vpr/src/draw

CXXSTD := c++14
CXXFLAGS += -std=$(CXXSTD) -Os

LDLIBS += -lpthread

TECHLIBS_DIR = techlibs
VERILOG_MODULES = adff2dff.v \
adffe2dff.v \
aldff2dff.v \
aldffe2dff.v \
vtr_primitives.v

# install_modules: $(VERILOG_MODULES)
# install -D $< $(YOSYS_PLUGINS_DIR)/parmys/$<
install_modules:
$(foreach f, $(wildcard $(TECHLIBS_DIR)/*), install -D $(f) $(YOSYS_DATA_DIR)/parmys/$(notdir $(f));)

install: install_modules

clean_modules:
rm -rf ./third_party

clean: clean_modules
100 changes: 100 additions & 0 deletions parmys-plugin/include/BlockMemories.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* Copyright (c) 2021 Seyed Alireza Damghani ([email protected])
*
* Permission is hereby granted, free of charge, to any person
poname marked this conversation as resolved.
Show resolved Hide resolved
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* @file This file includes the definition of the basic structure
* used in Odin-II Block Memory resolving process. Moreover, it
* provides the declaration of the related public routines.
*/
#ifndef _BLOCK_MEMORIES_H_
#define _BLOCK_MEMORIES_H_

#include <unordered_map>

// Max number of bits for register of array inference
const int LUTRAM_INFERENCE_THRESHOLD_MIN = 80; // Max number of bits for LUTRAM inference
const int LUTRAM_INFERENCE_THRESHOLD_MAX = 640; // Min number of bits for LUTRAM inference

/*
* Contains a pointer to the block memory node as well as other
* information which is used in creating the block memory.
*/
struct block_memory_t {
loc_t loc;
nnode_t *node;

signal_list_t *read_addr;
signal_list_t *read_data;
signal_list_t *read_en;

signal_list_t *write_addr;
signal_list_t *write_data;
signal_list_t *write_en;

signal_list_t *clk;

char *name;
char *memory_id;
};

typedef std::unordered_map<std::string, block_memory_t *> block_memory_hashtable;

/**
* block memories information. variable will be invalid
* after iterations happen before partial mapping
*/
struct block_memory_information_t {
/**
* block_memory_list and read-only_memory_list linked lists
* include the corresponding memory instances. Each instance
* comprises memory signal lists, location, memory id and the
* corresponding netlist node. These linked lists are used in
* optimization iteration, including signal pruning, REG/LUTRAM
* threshold checking and mapping to VTR memory blocks. Once the
* optimization iteration is done, these linked lists are not
* valid anymore.
*
* [NOTE] Block memories and read-only memory both use the same
* structure (block_memory_t*). They only differ in terms of
* their member variables initialization. The naming convention
* is only due to the ease of the coding process.
*/
vtr::t_linked_vptr *block_memory_list;
vtr::t_linked_vptr *read_only_memory_list;
/* hashtable to look up block memories faster */
block_memory_hashtable block_memories;
block_memory_hashtable read_only_memories;
};
extern block_memory_information_t block_memories_info;

extern void init_block_memory_index();
extern void free_block_memories();

extern void resolve_ymem_node(nnode_t *node, uintptr_t traverse_mark_number, netlist_t *netlist);
extern void resolve_ymem2_node(nnode_t *node, uintptr_t traverse_mark_number, netlist_t *netlist);
extern void resolve_bram_node(nnode_t *node, uintptr_t traverse_mark_number, netlist_t *netlist);
extern void resolve_rom_node(nnode_t *node, uintptr_t traverse_mark_number, netlist_t *netlist);

extern void iterate_block_memories(netlist_t *netlist);

#endif // _BLOCK_MEMORIES_H_
97 changes: 97 additions & 0 deletions parmys-plugin/include/HardSoftLogicMixer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef HARD_SOFT_LOGIC_MIXER_HPP
#define HARD_SOFT_LOGIC_MIXER_HPP

#include "MixingOptimization.hpp"
#include "odin_types.h" // netlist_t, config_t

class HardSoftLogicMixer
{
public:
HardSoftLogicMixer();
~HardSoftLogicMixer();
/*----------------------------------------------------------------------
* Returns whether the specific node is a candidate for implementing
* in hard block
*---------------------------------------------------------------------
*/
bool hardenable(nnode_t *node);

/*----------------------------------------------------------------------
* Function: map_deferred_blocksQueries if mixing optimization is enabled for this kind of
* of hard blocks
*---------------------------------------------------------------------
*/
bool enabled(nnode_t *node);

/*----------------------------------------------------------------------
* Function: perform_optimizations
* For all noted nodes, that were noted as candidates to be implemented
* on the hard blocks, launches corresponding procedure of chosing the
* corresponding blocks
* Parameters: netlist_t *
*---------------------------------------------------------------------
*/
void perform_optimizations(netlist_t *netlist);

/*----------------------------------------------------------------------
* Function: partial_map_node
* High-level call to provide support for partial mapping layer
* Parameters:
* node_t * : pointer to node needs to perform mapping
* netlist_t : pointer to netlist
*---------------------------------------------------------------------
*/
void partial_map_node(nnode_t *node, short traverse_number, netlist_t *);

/*----------------------------------------------------------------------
* Function: note_candidate_node
* Calculates number of available hard blocks by issuing a call,
* traverses the netlist and statistics to figure out
* which operation should be implemented on the hard block
* Parameters:
* node_t * : pointer to candidate node
*---------------------------------------------------------------------
*/
void note_candidate_node(nnode_t *node);

// This is a container containing all optimization passes
MixingOpt *_opts[operation_list_END];

private:
/*----------------------------------------------------------------------
* Function: hard_blocks_needed
* Returns cached value calculated from netlist, for a specific optimiza
* tion kind
*---------------------------------------------------------------------
*/
int hard_blocks_needed(operation_list);

// This array is composed of vectors, that store nodes that
// are potential candidates for performing mixing optimization
std::vector<nnode_t *> _nodes_by_opt[operation_list_END];
};

#endif
Loading