| // Copyright lowRISC contributors. |
| // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| // SPDX-License-Identifier: Apache-2.0 |
| #define CLK_FIXED_FREQ_HZ (500 * 1000) |
| #define CLK_FIXED_FREQ_HZ (50ULL * 1000 * 1000) |
| #define REG8(add) *((volatile uint8_t *)(add)) |
| #define REG16(add) *((volatile uint16_t *)(add)) |
| #define REG32(add) *((volatile uint32_t *)(add)) |
| // Flash memory base defines, _SZ are presented in bytes |
| #define FLASH_MEM_BASE_ADDR 0x20000000 |
| #define FLASH_WORDS_PER_PAGE 256 |
| #define FLASH_PAGE_SZ (FLASH_WORDS_PER_PAGE * FLASH_WORD_SZ) |
| #define FLASH_PAGES_PER_BANK 256 |
| #define FLASH_BANK_SZ (FLASH_PAGES_PER_BANK * FLASH_PAGE_SZ) |
| #define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0])) |
| #define BITLENGTH_1(X) ((X) - (((X) >> 1) & 0x55555555)) |
| #define BITLENGTH_2(X) (((X)&0x33333333) + (((X) >> 2) & 0x33333333)) |
| #define BITLENGTH_3(X) (((X) + ((X) >> 4)) & 0x0f0f0f0f) |
| #define BITLENGTH_4(X) ((X) + ((X) >> 8)) |
| #define BITLENGTH_5(X) ((X) + ((X) >> 16)) |
| ((BITLENGTH_5(BITLENGTH_4(BITLENGTH_3(BITLENGTH_2(BITLENGTH_1(X)))))) & 0x7f) |