11#! /bin/bash
22
3- # Copyright 2023 OpenHW Group
3+ # Copyright 2024 OpenHW Group and Dolphin Design
4+ # SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
45#
5- # Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
6- # you may not use this file except in compliance with the License.
6+ # Licensed under the Solderpad Hardware License v 2.1 (the “License”);
7+ # you may not use this file except in compliance with the License, or,
8+ # at your option, the Apache License version 2.0.
79# You may obtain a copy of the License at
810#
9- # https://solderpad.org/licenses/
11+ # https://solderpad.org/licenses/SHL-2.1 /
1012#
11- # Unless required by applicable law or agreed to in writing, software
12- # distributed under the License is distributed on an " AS IS" BASIS,
13+ # Unless required by applicable law or agreed to in writing, any work
14+ # distributed under the License is distributed on an “ AS IS” BASIS,
1315# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1416# See the License for the specific language governing permissions and
1517# limitations under the License.
1618
1719usage () { # Function: Print a help message.
18- echo " Usage: $0 [ -t {cadence,synopsys,siemens} -p {sec,lec} ]" 1>&2
20+ echo " Usage: $0 -t {cadence,synopsys,siemens} -p {sec,lec} [-v {v1,v2}] [-x {0,1}] [-f {0,1}] [-z {0,1}]]" 1>&2
21+ echo " For v2 : if f or z is 1 then p must be 1" 1>&2
22+ echo " if z is 1 then f must be 1" 1>&2
1923}
2024
2125exit_abnormal () { # Function: Exit with error.
@@ -32,7 +36,12 @@ print_log() {
3236 echo " [LOG] $1 "
3337}
3438
35- while getopts " t:p:" flag
39+ VERSION=v1
40+ PULP_CFG=0
41+ FPU_CFG=0
42+ ZFINX_CFG=0
43+
44+ while getopts " t:p:v:x:f:z:" flag
3645do
3746 case " ${flag} " in
3847 t)
4150 p)
4251 target_process=${OPTARG}
4352 ;;
53+ v)
54+ VERSION=${OPTARG}
55+ ;;
56+ x)
57+ PULP_CFG=${OPTARG}
58+ ;;
59+ f)
60+ FPU_CFG=${OPTARG}
61+ ;;
62+ z)
63+ ZFINX_CFG=${OPTARG}
64+ ;;
4465 :)
4566 exit_abnormal
4667 ;;
@@ -61,25 +82,63 @@ if [[ "${target_process}" != "sec" && "${target_process}" != "lec" ]]; then
6182 exit_abnormal
6283fi
6384
85+ if [[ " ${VERSION} " != " v1" && " ${VERSION} " != " v2" ]]; then
86+ exit_abnormal
87+ elif [[ " ${VERSION} " == " v1" && (" ${PULP_CFG} " ! = " 0" || " ${FPU_CFG} " ! = " 0" || " ${ZFINX_CFG} " ! = " 0" ) ]]; then
88+ exit_abnormal
89+ fi
90+
91+ if [[ " ${PULP_CFG} " != 0 && " ${PULP_CFG} " != 1 ]]; then
92+ exit_abnormal
93+ fi
94+
95+ if [[ " ${FPU_CFG} " != 0 && " ${FPU_CFG} " != 1 ]]; then
96+ exit_abnormal
97+ fi
98+
99+ if [[ " ${ZFINX_CFG} " != 0 && " ${ZFINX_CFG} " != 1 ]]; then
100+ exit_abnormal
101+ fi
102+
103+ if [[ (( "${PULP_CFG} " == 0 && ("${FPU_CFG} " == 1 || "${ZFINX_CFG} " == 1 )) || (" ${PULP_CFG} " == 1 && " ${FPU_CFG} " == 0 && " ${ZFINX_CFG} " == 1)) ]]; then
104+ exit_abnormal
105+ fi
106+
107+ if [[ " ${VERSION} " == " v1" ]]; then
108+ REF_BRANCH=cv32e40p_v1.0.0
109+ TOP_MODULE=cv32e40p_core
110+ else
111+ REF_BRANCH=dev
112+ TOP_MODULE=cv32e40p_top
113+ fi
114+
115+ export top_module=${TOP_MODULE}
116+ export version=${VERSION}
117+ export pulp_cfg=${PULP_CFG}
118+ export fpu_cfg=${FPU_CFG}
119+ export zfinx_cfg=${ZFINX_CFG}
120+
64121if [ -z " ${REF_REPO} " ]; then
65122 print_log " Empty REF_REPO env variable"
66123 REF_REPO=https://github.com/openhwgroup/cv32e40p.git
67124 REF_FOLDER=ref_design
68- REF_BRANCH=cv32e40p_v1.0.0
69125 print_log " * Setting REF_REPO ${REF_REPO} "
70126 print_log " * Setting REF_FOLDER ${REF_FOLDER} "
71127 print_log " * Setting REF_BRANCH ${REF_BRANCH} "
128+ print_log " * Setting TOP_MODULE ${TOP_MODULE} "
72129fi
73130
74131RTL_FOLDER=$( readlink -f ../..)
75132
76- FLIST=cv32e40p_manifest.flist
133+ if [[ " ${PULP_CFG} " == 0 && " ${ZFINX_CFG} " == 0 ]]; then
134+ FLIST=cv32e40p_manifest.flist
135+ else
136+ FLIST=cv32e40p_fpu_manifest.flist
137+ fi
77138
78139if [[ -z " ${TOP_MODULE} " ]]; then
79140 print_log " Empty TOP_MODULE env variable"
80- TOP_MODULE=cv32e40p_core
81141 print_log " * Setting TOP_MODULE ${TOP_MODULE} "
82- export top_module=${TOP_MODULE}
83142fi
84143
85144if [ ! -d ./reports/ ]; then
88147
89148if [[ -z " ${GOLDEN_RTL} " ]]; then
90149 print_log " The env variable GOLDEN_RTL is empty."
91- if [ ! -d " ./${REF_FOLDER} " ]; then
92- print_log " * Cloning Golden Design...."
93- git clone $REF_REPO --single-branch -b $REF_BRANCH $REF_FOLDER ;
94- git -C ${REF_FOLDER} checkout $REF_COMMIT
95- fi
150+ \r m -rf " ./${REF_FOLDER} "
151+ print_log " * Cloning Golden Design...."
152+ git clone $REF_REPO --single-branch -b $REF_BRANCH $REF_FOLDER ;
153+ git -C ${REF_FOLDER} checkout $REF_COMMIT
96154 export GOLDEN_RTL=$( pwd) /${REF_FOLDER} /rtl
97155else
98156 print_log " ${target_process^^} : Using ${GOLDEN_RTL} as reference design"
@@ -104,9 +162,13 @@ REVISED_FLIST=$(pwd)/revised.src
104162GOLDEN_DIR=$( readlink -f ./${REF_FOLDER} /)
105163GOLDEN_FLIST=$( pwd) /golden.src
106164
107- var_golden_rtl=$( awk ' { if ($0 ~ "{DESIGN_RTL_DIR}" && $0 !~ "#" && $0 !~ "tracer" && $0 !~ "wrapper ") print $0 }' ${GOLDEN_DIR} /$FLIST | sed ' s|${DESIGN_RTL_DIR}|' " ${GOLDEN_DIR} " ' /rtl/|' )
165+ var_golden_rtl=$( awk ' { if ($0 ~ "{DESIGN_RTL_DIR}" && $0 !~ "#" && $0 !~ "tracer" && $0 !~ "tb_wrapper" && $0 !~ "cv32e40p_wrapper ") print $0 }' ${GOLDEN_DIR} /$FLIST | sed ' s|${DESIGN_RTL_DIR}|' " ${GOLDEN_DIR} " ' /rtl/|' )
108166
109- var_revised_rtl=$( awk ' { if ($0 ~ "{DESIGN_RTL_DIR}" && $0 !~ "#" && $0 !~ "tracer" && $0 !~ "wrapper" && $0 !~ "_top") print $0 }' ${REVISED_DIR} /$FLIST | sed ' s|${DESIGN_RTL_DIR}|' " ${REVISED_DIR} " ' /rtl/|' )
167+ if [[ " ${VERSION} " == " v1" ]]; then
168+ var_revised_rtl=$( awk ' { if ($0 ~ "{DESIGN_RTL_DIR}" && $0 !~ "#" && $0 !~ "tracer" && $0 !~ "tb_wrapper" && $0 !~ "cv32e40p_wrapper" && $0 !~ "top") print $0 }' ${REVISED_DIR} /$FLIST | sed ' s|${DESIGN_RTL_DIR}|' " ${REVISED_DIR} " ' /rtl/|' )
169+ else
170+ var_revised_rtl=$( awk ' { if ($0 ~ "{DESIGN_RTL_DIR}" && $0 !~ "#" && $0 !~ "tracer" && $0 !~ "tb_wrapper") print $0 }' ${REVISED_DIR} /$FLIST | sed ' s|${DESIGN_RTL_DIR}|' " ${REVISED_DIR} " ' /rtl/|' )
171+ fi
110172
111173print_log " Generating GOLDEN flist in path: ${GOLDEN_FLIST} "
112174echo $var_golden_rtl > ${GOLDEN_FLIST}
0 commit comments