Skip to content

Commit

Permalink
Make the CI slightly happer (#18)
Browse files Browse the repository at this point in the history
* CI: Fix linting errors
  • Loading branch information
Scheremo authored Jul 29, 2024
1 parent eb5b61b commit 979b6ca
Show file tree
Hide file tree
Showing 22 changed files with 1,111 additions and 960 deletions.
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
IndentWidth: 4
ColumnLimit: 100
AlignEscapedNewlines: DontAlign
SortIncludes: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
6 changes: 4 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
SPDX-License-Identifier: (SHL-0.51|Apache-2.0)
exclude_paths: |
utils/*
# sw/include/regs/*.h
sw/include/regs/*
scripts/run_clang_format.py
lint-sv:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -55,7 +57,7 @@ jobs:
uses: DoozyX/clang-format-lint-action@v0.14
with:
extensions: 'c,h,cpp'
clangFormatVersion: 14
clangFormatVersion: 12
style: >
{
IndentWidth: 4,
Expand Down
25 changes: 3 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
# ----------------------------------------------------------------------
#
# File: Makefile
#
# Created: 25.06.2024
#
# Copyright (C) 2024, ETH Zurich and University of Bologna.
#
# Author: Moritz Scherer, ETH Zurich
#
# ----------------------------------------------------------------------
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# 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
#
# 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.
# Moritz Scherer <scheremo@iis.ee.ethz.ch>

CHIM_ROOT ?= $(shell pwd)
BENDER ?= bender -d $(CHIM_ROOT)
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,19 @@ source setup.chimera_soc.tcl
source compile.tcl
source start.chimera_soc.tcl
```

## CXX Formatting

To format all files within the `sw` directory, run
```
python scripts/run_clang_format.py -ir sw/
```

Our CI uses llvm-12 for clang-format, so on IIS machines you may run
```
python scripts/run_clang_format.py -ir sw/ --clang-format-executable=/usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin/clang-format
python scripts/run_clang_format.py -ir hw/ --clang-format-executable=/usr/pack/riscv-1.0-kgf/pulp-llvm-0.12.0/bin/clang-format
```

otherwise you should specify a valid clang-format-12 binary instead.
25 changes: 3 additions & 22 deletions bender.mk
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
# ----------------------------------------------------------------------
#
# File: bender.mk
#
# Created: 25.06.2024
#
# Copyright (C) 2024, ETH Zurich and University of Bologna.
#
# Author: Moritz Scherer, ETH Zurich
#
# ----------------------------------------------------------------------
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# 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
#
# 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.
# Moritz Scherer <scheremo@iis.ee.ethz.ch>

COMMON_TARGS ?=
COMMON_TARGS += -t snitch_cluster -t cv32a6_convolve -t cva6 -t rtl
Expand Down
27 changes: 3 additions & 24 deletions chimera.mk
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
# ----------------------------------------------------------------------
#
# File: chimera.mk
#
# Created: 26.06.2024
#
# Copyright (C) 2024, ETH Zurich and University of Bologna.
#
# Author: Moritz Scherer, ETH Zurich
#
# ----------------------------------------------------------------------
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# 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
#
# 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.

# SCHEREMO: This is a test config; change to something reasonable!
# Moritz Scherer <scheremo@iis.ee.ethz.ch>

CLINTCORES = 46
PLICCORES = 92
Expand Down
20 changes: 11 additions & 9 deletions hw/bootrom/snitch/snitch_bootrom.S
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Copyright 2020 ETH Zurich and University of Bologna.
# Solderpad Hardware License, Version 0.51, see LICENSE for details.
# SPDX-License-Identifier: SHL-0.51
// Copyright 2024 ETH Zurich and University of Bologna.
// Solderpad Hardware License, Version 0.51, see LICENSE for details.
// SPDX-License-Identifier: SHL-0.51
//
// Moritz Scherer <scheremo@iis.ee.ethz.ch>

#include <soc_ctrl.h>

.global _start
_start:

Expand All @@ -13,7 +15,7 @@ _start:
la t0, _trap_handler_initial
csrrw x0, mtvec, t0

_rerun:
_rerun:
li x5, 0
li x6, 0
li x7, 0
Expand Down Expand Up @@ -41,7 +43,7 @@ _rerun:
li x29, 0
li x30, 0
li x31, 0

wfi

run_from_reg:
Expand All @@ -51,10 +53,10 @@ run_from_reg:

_return:
call cluster_return // By calling immediately after return, register contents in a0 are passed as the first argument
_exit:

_exit:
j _rerun

.align 4
_trap_handler_initial:
la t0, __chim_regs // CHIMERA REGS Base Addr
Expand Down
111 changes: 49 additions & 62 deletions hw/bootrom/snitch/snitch_startup.c
Original file line number Diff line number Diff line change
@@ -1,77 +1,64 @@
/* =====================================================================
* Title: snitch_startup.c
* Description:
*
* $Date: 28.06.2024
*
* ===================================================================== */
/*
* Copyright (C) 2020 ETH Zurich and University of Bologna.
*
* Author: Moritz Scherer, ETH Zurich
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
// Copyright 2024 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// Moritz Scherer <scheremo@iis.ee.ethz.ch>

#include <stdint.h>
#include <regs/soc_ctrl.h>
#include <soc_addr_map.h>

#define set_csr(reg, bit) ({ unsigned long __tmp; \
if (__builtin_constant_p(bit) && (unsigned long)(bit) < 32) \
asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "i"(bit)); \
else \
asm volatile ("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "r"(bit)); \
__tmp; })
#define set_csr(reg, bit) \
({ \
unsigned long __tmp; \
if (__builtin_constant_p(bit) && (unsigned long)(bit) < 32) \
asm volatile("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "i"(bit)); \
else \
asm volatile("csrrs %0, " #reg ", %1" : "=r"(__tmp) : "r"(bit)); \
__tmp; \
})

#define IRQ_M_SOFT 3
#define IRQ_M_SOFT 3

#define MSTATUS_MIE 0x00000008
#define MIP_MSIP (1 << IRQ_M_SOFT)
#define MSTATUS_MIE 0x00000008
#define MIP_MSIP (1 << IRQ_M_SOFT)

void cluster_startup(){
set_csr(mie, MIP_MSIP);
set_csr(mstatus, MSTATUS_MIE); // set M global interrupt enable
return;
void cluster_startup() {
set_csr(mie, MIP_MSIP);
set_csr(mstatus, MSTATUS_MIE); // set M global interrupt enable
return;
}

void cluster_return(uint32_t ret){
void cluster_return(uint32_t ret) {

uint32_t retVal = ret | 0x000000001;

uint8_t hartId;
asm ("csrr %0, mhartid" : "=r" (hartId) ::);
uint32_t retVal = ret | 0x000000001;

switch(hartId){
uint8_t hartId;
asm("csrr %0, mhartid" : "=r"(hartId)::);

case 1:
*((volatile uint32_t*)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_1_RETURN_REG_OFFSET)) = retVal;
break;
case 10:
*((volatile uint32_t*)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_2_RETURN_REG_OFFSET)) = retVal;
break;
case 19:
*((volatile uint32_t*)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_3_RETURN_REG_OFFSET)) = retVal;
break;
case 28:
*((volatile uint32_t*)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_4_RETURN_REG_OFFSET)) = retVal;
break;
case 37:
*((volatile uint32_t*)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_5_RETURN_REG_OFFSET)) = retVal;
break;
}
switch (hartId) {

return;
case 1:
*((volatile uint32_t *)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_1_RETURN_REG_OFFSET)) =
retVal;
break;
case 10:
*((volatile uint32_t *)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_2_RETURN_REG_OFFSET)) =
retVal;
break;
case 19:
*((volatile uint32_t *)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_3_RETURN_REG_OFFSET)) =
retVal;
break;
case 28:
*((volatile uint32_t *)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_4_RETURN_REG_OFFSET)) =
retVal;
break;
case 37:
*((volatile uint32_t *)(SOC_CTRL_BASE + CHIMERA_SNITCH_CLUSTER_5_RETURN_REG_OFFSET)) =
retVal;
break;
}

return;
}
Loading

0 comments on commit 979b6ca

Please sign in to comment.