-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updating to new flow * Update README
- Loading branch information
Showing
12 changed files
with
245 additions
and
71 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bsg_cadenv/ | ||
install/ |
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 |
---|---|---|
@@ -1,36 +1,45 @@ | ||
TOP ?= $(shell git rev-parse --show-toplevel) | ||
include $(TOP)/Makefile.common | ||
include $(TOP)/Makefile.env | ||
|
||
export BP_RTL_DIR := $(TOP)/black-parrot | ||
export BP_TOOLS_DIR := $(TOP)/black-parrot-tools | ||
export BP_SDK_DIR := $(TOP)/black-parrot-sdk | ||
include $(BP_SIM_MK_DIR)/Makefile.docker | ||
|
||
checkout: | ||
git fetch --all | ||
git submodule update --init | ||
$(MAKE) -C $(BP_RTL_DIR) checkout | ||
$(MAKE) -C $(BP_TOOLS_DIR) checkout | ||
$(MAKE) -C $(BP_SDK_DIR) checkout | ||
checkout: ## checkout submodules, but not recursively | ||
@$(MKDIR) -p $(BP_SIM_TOUCH_DIR) | ||
@$(GIT) fetch --all | ||
@$(GIT) submodule sync | ||
@$(GIT) submodule update --init | ||
@$(MAKE) -C $(BP_SIM_RTL_DIR) checkout BP_RTL_DIR=$(BP_SIM_RTL_DIR) | ||
@$(MAKE) -C $(BP_SIM_TOOLS_DIR) checkout BP_TOOLS_DIR=$(BP_SIM_TOOLS_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) checkout BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
|
||
prep_lite: checkout | ||
$(MAKE) -C $(BP_RTL_DIR) libs_lite | ||
$(MAKE) -C $(BP_TOOLS_DIR) tools_lite | ||
$(MAKE) -C $(BP_SDK_DIR) sdk_lite | ||
$(MAKE) -C $(BP_SDK_DIR) prog_lite | ||
apply_patches: ## applies patches to submodules | ||
apply_patches: build.patch | ||
$(eval $(call bsg_fn_build_if_new,patch,$(CURDIR),$(BP_SIM_TOUCH_DIR))) | ||
%/.patch_build: checkout | ||
@$(MAKE) -C $(BP_SIM_RTL_DIR) apply_patches BP_RTL_DIR=$(BP_SIM_RTL_DIR) | ||
@$(MAKE) -C $(BP_SIM_TOOLS_DIR) apply_patches BP_TOOLS_DIR=$(BP_SIM_TOOLS_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) apply_patches BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
@echo "Patching successful, ignore errors" | ||
|
||
prep_lite: ## Minimal preparation for simulation | ||
prep_lite: apply_patches | ||
@$(MAKE) -C $(BP_SIM_RTL_DIR) libs_lite BP_RTL_DIR=$(BP_SIM_RTL_DIR) | ||
@$(MAKE) -C $(BP_SIM_TOOLS_DIR) tools_lite BP_TOOLS_DIR=$(BP_SIM_TOOLS_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) sdk_lite BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) prog_lite BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
|
||
prep: ## Standard preparation for simulation | ||
prep: prep_lite | ||
$(MAKE) -C $(BP_RTL_DIR) libs | ||
$(MAKE) -C $(BP_TOOLS_DIR) tools | ||
$(MAKE) -C $(BP_SDK_DIR) sdk | ||
$(MAKE) -C $(BP_SDK_DIR) prog | ||
@$(MAKE) -C $(BP_SIM_RTL_DIR) libs BP_RTL_DIR=$(BP_SIM_RTL_DIR) | ||
@$(MAKE) -C $(BP_SIM_TOOLS_DIR) tools BP_TOOLS_DIR=$(BP_SIM_TOOLS_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) sdk BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) prog BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
|
||
prep_bsg: ## Extra preparation for BSG users | ||
prep_bsg: prep | ||
$(MAKE) -C $(BP_RTL_DIR) libs_bsg | ||
$(MAKE) -C $(BP_TOOLS_DIR) tools_bsg | ||
$(MAKE) -C $(BP_SDK_DIR) sdk_bsg | ||
$(MAKE) -C $(BP_SDK_DIR) prog_bsg | ||
|
||
## This target just wipes the whole repo clean. | ||
# Use with caution. | ||
bleach_all: | ||
cd $(TOP); git clean -fdx; git submodule deinit -f . | ||
@$(MAKE) -C $(BP_SIM_RTL_DIR) libs_bsg BP_RTL_DIR=$(BP_SIM_RTL_DIR) | ||
@$(MAKE) -C $(BP_SIM_TOOLS_DIR) tools_bsg BP_TOOLS_DIR=$(BP_SIM_TOOLS_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) sdk_bsg BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
@$(MAKE) -C $(BP_SIM_SDK_DIR) prog_bsg BP_SDK_DIR=$(BP_SIM_SDK_DIR) | ||
|
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,129 @@ | ||
############################# | ||
# Makefile functions | ||
############################# | ||
# Saves initial values so that we can filter them later | ||
VARS_OLD := $(.VARIABLES) | ||
|
||
define bsg_fn_upper | ||
$(shell echo $(1) | tr a-z A-Z) | ||
endef | ||
define bsg_fn_lower | ||
$(shell echo $(1) | tr A-Z a-z) | ||
endef | ||
bsg_var_blank := | ||
define bsg_var_newline | ||
|
||
$(bsg_var_blank) | ||
endef | ||
|
||
bsg_var_percent := % | ||
|
||
define bsg_fn_patch_if_new | ||
$(eval apply_stage_patch := git apply --ignore-whitespace --ignore-space-change) | ||
$(eval apply_commit_patch := git am --ignore-whitespace --ignore-space-change) | ||
$(eval check_patch := $(apply_stage_patch) --check --reverse) | ||
$(eval src_root := $(1)) | ||
$(eval patch_root := $(2)) | ||
$(eval patch_list := $(wildcard $(patch_root)/*.patch)) | ||
$(eval patch_is_top := $(findstring patches,$(lastword $(subst /, ,$(dir $(patch_root)))))) | ||
for p in $(patch_list); \ | ||
do \ | ||
echo "Checking if patch $$p is applicable"; \ | ||
cd $(src_root); $(check_patch) $$p && continue; \ | ||
echo "Patch is unapplied..."; \ | ||
if [ ! -z "$$patch_is_top" ]; then \ | ||
echo "Applying patch to sub-directory $(src_root);" \ | ||
cd $(src_root); $(apply_commit_patch) $$p; \ | ||
echo "Patch applied!"; \ | ||
else \ | ||
echo "Applying patch to top-level $(src_root);" \ | ||
cd $(src_root); $(apply_stage_patch) $$p; \ | ||
echo "Patch applied!"; \ | ||
fi \ | ||
done | ||
endef | ||
|
||
define bsg_fn_build_tag | ||
$(eval name := $(1)) | ||
$(eval src_dir := $(2)) | ||
$(eval touch_dir := $(3)) | ||
$(eval tag := $(4)) | ||
$(eval internal_target := $(src_dir)/.$(name)_build) | ||
$(eval external_target := build.$(name)) | ||
$(eval rebuild_target := rebuild.$(name)) | ||
$(external_target): | $(tag) | ||
$(rebuild_target): | ||
rm -f $(touch_dir)/$(name).* | ||
+$(MAKE) $(tag) | ||
$(tag): | ||
+$(MAKE) $(internal_target) | ||
touch $(tag) | ||
endef | ||
|
||
define bsg_fn_build_if_missing | ||
$(eval name := $(1)) | ||
$(eval src_dir := $(2)) | ||
$(eval touch_dir := $(3)) | ||
$(eval tag := $(addprefix $(touch_dir)/$(name).,any)) | ||
$(call bsg_fn_build_tag,$(name),$(src_dir),$(touch_dir),$(tag)) | ||
endef | ||
|
||
define bsg_fn_build_if_new | ||
$(eval name := $(1)) | ||
$(eval src_dir := $(2)) | ||
$(eval touch_dir := $(3)) | ||
$(eval hash := $(shell cd $(src_dir); git rev-parse HEAD)) | ||
$(eval tag := $(addprefix $(touch_dir)/$(name).,$(hash))) | ||
$(call bsg_fn_build_tag,$(name),$(src_dir),$(touch_dir),$(tag)) | ||
endef | ||
|
||
|
||
define bsg_fn_info | ||
$(eval $@_msg = $(1)) | ||
$(eval $@_prefix = "BSG-INFO: ") | ||
echo "${$@_prefix} ${$@_msg}"; | ||
endef | ||
|
||
define bsg_fn_warn | ||
$(eval $@_msg = $(1)) | ||
$(eval $@_prefix = "BSG-WARN: ") | ||
echo "${$@_prefix} ${$@_msg}"; | ||
endef | ||
|
||
define bsg_fn_error | ||
$(eval $@_msg = $(1)) | ||
$(eval $@_prefix = "BSG-ERROR: ") | ||
echo "${$@_prefix} ${$@_msg}"; \ | ||
exit -1; | ||
endef | ||
|
||
# Global Makefile settings | ||
SHELL := /bin/bash | ||
MAKEFLAGS += --warn-undefined-variables | ||
|
||
# Global help target | ||
.DEFAULT_GOAL: help | ||
.PHONY: help | ||
help: ## prints this message | ||
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort \ | ||
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
# Global reset | ||
.PHONY: bleach_all | ||
bleach_all: ## wipes the whole repo clean. Use with caution | ||
@cd $(TOP); git clean -ffdx; git submodule deinit -f . | ||
|
||
############################# | ||
# Paths | ||
############################# | ||
BP_SIM_DIR ?= $(TOP) | ||
BP_SIM_MK_DIR ?= $(BP_SIM_DIR)/mk | ||
BP_SIM_RTL_DIR ?= $(BP_SIM_DIR)/black-parrot | ||
BP_SIM_TOOLS_DIR ?= $(BP_SIM_DIR)/black-parrot-tools | ||
BP_SIM_SDK_DIR ?= $(BP_SIM_DIR)/black-parrot-sdk | ||
BP_SIM_DOCKER_DIR ?= $(BP_SIM_DIR)/docker | ||
BP_SIM_INSTALL_DIR ?= $(BP_SIM_DIR)/install | ||
BP_SIM_TOUCH_DIR ?= $(BP_SIM_INSTALL_DIR)/touchfiles | ||
|
||
BSG_CADENV_DIR ?= $(BP_SIM_DIR)/install/bsg_cadenv | ||
|
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,48 @@ | ||
|
||
########################################################## | ||
## User configuration | ||
########################################################## | ||
# Available platforms: ubuntu20.04 | ||
DOCKER_PLATFORM ?= ubuntu20.04 | ||
|
||
########################################################## | ||
## Cad environment | ||
########################################################## | ||
ifneq ($(MAKECMDGOALS),help) | ||
include $(BSG_CADENV_DIR)/cadenv.mk | ||
%/cadenv.mk: | ||
# BSG users leverage a machine-specific cadenv | ||
# Here, we add sourcing to get these variables as well | ||
@$(eval CADENV_URL := [email protected]:bespoke-silicon-group/bsg_cadenv) | ||
@$(eval CADENV_EXISTS := $(shell git ls-remote --exit-code $(CADENV_URL) HEAD 2> /dev/null)) | ||
# Recursive make to include the new fragment | ||
if [ -f "$(BSG_CADENV_DIR)/cadenv.mk" ]; then \ | ||
echo "bsg_cadenv already exists"; \ | ||
elif [[ ! -z "$(CADENV_EXISTS)" ]]; then \ | ||
echo "Cloning bsg_cadenv from $(CADENV_URL)"; \ | ||
git clone --recurse-submodules $(CADENV_URL) $(@D); \ | ||
else \ | ||
echo "bsg_cadenv not found"; \ | ||
mkdir -p $(@D); \ | ||
touch $@; \ | ||
fi | ||
@echo "Successfully built $@!" | ||
endif | ||
|
||
############################# | ||
# Cad settings | ||
############################# | ||
|
||
############################# | ||
# Environment detection | ||
############################# | ||
CENTOS7 := $(if $(findstring CentOS Linux release 7,$(shell cat /etc/centos-release 2>/dev/null)),1,0) | ||
|
||
############################## | ||
# Executables | ||
############################## | ||
DOCKER ?= docker | ||
GIT ?= git | ||
CD ?= cd | ||
MKDIR ?= mkdir | ||
|
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
Submodule black-parrot
updated
146 files
Submodule black-parrot-sdk
updated
20 files
+8 −0 | .gitmodules | |
+73 −86 | Makefile | |
+156 −82 | Makefile.common | |
+85 −0 | Makefile.env | |
+0 −7 | Makefile.linker | |
+0 −13 | Makefile.platform | |
+0 −60 | Makefile.prereq | |
+0 −152 | Makefile.prog | |
+0 −81 | Makefile.tools | |
+35 −12 | README.md | |
+1 −0 | bsg_newlib_dramfs | |
+49 −0 | mk/Makefile.prereq | |
+156 −0 | mk/Makefile.prog | |
+49 −0 | mk/Makefile.sdk | |
+0 −24 | patches/riscv-gnu-toolchain/0001-submodules.patch | |
+0 −19 | patches/riscv-gnu-toolchain/0003-Changing-newlib-commit.patch | |
+1 −1 | riscv-arch-test | |
+1 −0 | riscv-isa-sim | |
+1 −1 | yocto | |
+1 −1 | zephyr |
Submodule black-parrot-tools
updated
9 files
+10 −3 | .gitmodules | |
+42 −46 | Makefile | |
+139 −102 | Makefile.common | |
+88 −0 | Makefile.env | |
+0 −73 | Makefile.tools | |
+82 −0 | mk/Makefile.tools | |
+1 −1 | verilator | |
+1 −1 | yosys | |
+1 −0 | yosys-slang |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
|
||
docker-image: ## creates a black-parrot-sim docker image | ||
@$(eval USER_ID := $(shell id -u)) | ||
@$(eval GROUP_ID := $(shell id -g)) | ||
@$(eval CONTAINER_NAME := black-parrot-sim) | ||
@$(CD) $(BP_SIM_DOCKER_DIR); \ | ||
$(DOCKER) build . -f Dockerfile.$(DOCKER_PLATFORM) \ | ||
--build-arg USER_ID=$(USER_ID) \ | ||
--build-arg GROUP_ID=$(GROUP_ID) \ | ||
-t $(CONTAINER_NAME) | ||
|
||
docker-run: ## mounts black-parrot-sim as a docker image | ||
@$(eval USER_ID := $(shell id -u)) | ||
@$(eval GROUP_ID := $(shell id -g)) | ||
@$(eval CONTAINER_NAME := black-parrot-sim) | ||
$(CD) $(BP_SIM_DIR); \ | ||
$(DOCKER) run \ | ||
--volume=$(BP_SIM_DIR):/home/build/black-parrot-sim \ | ||
--user $(USER_ID):$(GROUP_ID) \ | ||
-it $(CONTAINER_NAME) | ||
|