| 1 |
2 |
dinesha |
/*
|
| 2 |
|
|
* SPDX-FileCopyrightText: 2020 Efabless Corporation
|
| 3 |
|
|
*
|
| 4 |
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
|
|
* you may not use this file except in compliance with the License.
|
| 6 |
|
|
* You may obtain a copy of the License at
|
| 7 |
|
|
*
|
| 8 |
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
|
|
*
|
| 10 |
|
|
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
|
|
* See the License for the specific language governing permissions and
|
| 14 |
|
|
* limitations under the License.
|
| 15 |
|
|
* SPDX-License-Identifier: Apache-2.0
|
| 16 |
|
|
*/
|
| 17 |
|
|
|
| 18 |
|
|
// This include is relative to $CARAVEL_PATH (see Makefile)
|
| 19 |
|
|
#include "verilog/dv/caravel/defs.h"
|
| 20 |
|
|
#include "verilog/dv/caravel/stub.c"
|
| 21 |
|
|
|
| 22 |
|
|
/*
|
| 23 |
|
|
MPRJ LA Test:
|
| 24 |
|
|
- Sets counter clk through LA[64]
|
| 25 |
|
|
- Sets counter rst through LA[65]
|
| 26 |
|
|
- Observes count value for five clk cycle through LA[31:0]
|
| 27 |
|
|
*/
|
| 28 |
|
|
|
| 29 |
|
|
int clk = 0;
|
| 30 |
|
|
int i;
|
| 31 |
|
|
|
| 32 |
|
|
void main()
|
| 33 |
|
|
{
|
| 34 |
|
|
/* Set up the housekeeping SPI to be connected internally so */
|
| 35 |
|
|
/* that external pin changes don't affect it. */
|
| 36 |
|
|
|
| 37 |
|
|
reg_spimaster_config = 0xa002; // Enable, prescaler = 2,
|
| 38 |
|
|
// connect to housekeeping SPI
|
| 39 |
|
|
|
| 40 |
|
|
// Connect the housekeeping SPI to the SPI master
|
| 41 |
|
|
// so that the CSB line is not left floating. This allows
|
| 42 |
|
|
// all of the GPIO pins to be used for user functions.
|
| 43 |
|
|
|
| 44 |
|
|
|
| 45 |
|
|
// All GPIO pins are configured to be output
|
| 46 |
|
|
// Used to flad the start/end of a test
|
| 47 |
|
|
|
| 48 |
|
|
reg_mprj_io_31 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 49 |
|
|
reg_mprj_io_30 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 50 |
|
|
reg_mprj_io_29 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 51 |
|
|
reg_mprj_io_28 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 52 |
|
|
reg_mprj_io_27 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 53 |
|
|
reg_mprj_io_26 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 54 |
|
|
reg_mprj_io_25 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 55 |
|
|
reg_mprj_io_24 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 56 |
|
|
reg_mprj_io_23 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 57 |
|
|
reg_mprj_io_22 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 58 |
|
|
reg_mprj_io_21 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 59 |
|
|
reg_mprj_io_20 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 60 |
|
|
reg_mprj_io_19 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 61 |
|
|
reg_mprj_io_18 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 62 |
|
|
reg_mprj_io_17 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 63 |
|
|
reg_mprj_io_16 = GPIO_MODE_MGMT_STD_OUTPUT;
|
| 64 |
|
|
|
| 65 |
|
|
reg_mprj_io_15 = GPIO_MODE_USER_STD_OUTPUT;
|
| 66 |
|
|
reg_mprj_io_14 = GPIO_MODE_USER_STD_OUTPUT;
|
| 67 |
|
|
reg_mprj_io_13 = GPIO_MODE_USER_STD_OUTPUT;
|
| 68 |
|
|
reg_mprj_io_12 = GPIO_MODE_USER_STD_OUTPUT;
|
| 69 |
|
|
reg_mprj_io_11 = GPIO_MODE_USER_STD_OUTPUT;
|
| 70 |
|
|
reg_mprj_io_10 = GPIO_MODE_USER_STD_OUTPUT;
|
| 71 |
|
|
reg_mprj_io_9 = GPIO_MODE_USER_STD_OUTPUT;
|
| 72 |
|
|
reg_mprj_io_8 = GPIO_MODE_USER_STD_OUTPUT;
|
| 73 |
|
|
reg_mprj_io_7 = GPIO_MODE_USER_STD_OUTPUT;
|
| 74 |
|
|
reg_mprj_io_5 = GPIO_MODE_USER_STD_OUTPUT;
|
| 75 |
|
|
reg_mprj_io_4 = GPIO_MODE_USER_STD_OUTPUT;
|
| 76 |
|
|
reg_mprj_io_3 = GPIO_MODE_USER_STD_OUTPUT;
|
| 77 |
|
|
reg_mprj_io_2 = GPIO_MODE_USER_STD_OUTPUT;
|
| 78 |
|
|
reg_mprj_io_1 = GPIO_MODE_USER_STD_OUTPUT;
|
| 79 |
|
|
reg_mprj_io_0 = GPIO_MODE_USER_STD_OUTPUT;
|
| 80 |
|
|
|
| 81 |
|
|
/* Apply configuration */
|
| 82 |
|
|
reg_mprj_xfer = 1;
|
| 83 |
|
|
while (reg_mprj_xfer == 1);
|
| 84 |
|
|
|
| 85 |
|
|
// Configure All LA probes as inputs to the cpu
|
| 86 |
|
|
reg_la0_oenb = reg_la0_iena = 0xFFFFFFFF; // [31:0]
|
| 87 |
|
|
reg_la1_oenb = reg_la1_iena = 0xFFFFFFFF; // [63:32]
|
| 88 |
|
|
reg_la2_oenb = reg_la2_iena = 0xFFFFFFFF; // [95:64]
|
| 89 |
|
|
reg_la3_oenb = reg_la3_iena = 0xFFFFFFFF; // [127:96]
|
| 90 |
|
|
|
| 91 |
|
|
// Flag start of the test
|
| 92 |
|
|
reg_mprj_datal = 0xAB600000;
|
| 93 |
|
|
|
| 94 |
|
|
// Configure LA[64] LA[65] as outputs from the cpu
|
| 95 |
|
|
reg_la2_oenb = reg_la2_iena = 0xFFFFFFFC;
|
| 96 |
|
|
|
| 97 |
|
|
// Set clk & reset to one
|
| 98 |
|
|
reg_la2_data = 0x00000003;
|
| 99 |
|
|
|
| 100 |
|
|
// Toggle clk & de-assert reset
|
| 101 |
|
|
for (i=0; i<11; i=i+1) {
|
| 102 |
|
|
clk = !clk;
|
| 103 |
|
|
reg_la2_data = 0x00000000 | clk;
|
| 104 |
|
|
}
|
| 105 |
|
|
|
| 106 |
|
|
if (reg_la0_data == 0x05) {
|
| 107 |
|
|
reg_mprj_datal = 0xAB610000;
|
| 108 |
|
|
}
|
| 109 |
|
|
|
| 110 |
|
|
}
|
| 111 |
|
|
|