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 |
|
|
Wishbone Test:
|
24 |
|
|
- Configures MPRJ lower 8-IO pins as outputs
|
25 |
|
|
- Checks counter value through the wishbone port
|
26 |
|
|
*/
|
27 |
|
|
int i = 0;
|
28 |
|
|
int clk = 0;
|
29 |
|
|
|
30 |
|
|
void main()
|
31 |
|
|
{
|
32 |
|
|
|
33 |
|
|
/*
|
34 |
|
|
IO Control Registers
|
35 |
|
|
| DM | VTRIP | SLOW | AN_POL | AN_SEL | AN_EN | MOD_SEL | INP_DIS | HOLDH | OEB_N | MGMT_EN |
|
36 |
|
|
| 3-bits | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit |
|
37 |
|
|
Output: 0000_0110_0000_1110 (0x1808) = GPIO_MODE_USER_STD_OUTPUT
|
38 |
|
|
| DM | VTRIP | SLOW | AN_POL | AN_SEL | AN_EN | MOD_SEL | INP_DIS | HOLDH | OEB_N | MGMT_EN |
|
39 |
|
|
| 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
Input: 0000_0001_0000_1111 (0x0402) = GPIO_MODE_USER_STD_INPUT_NOPULL
|
43 |
|
|
| DM | VTRIP | SLOW | AN_POL | AN_SEL | AN_EN | MOD_SEL | INP_DIS | HOLDH | OEB_N | MGMT_EN |
|
44 |
|
|
| 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
|
45 |
|
|
*/
|
46 |
|
|
|
47 |
|
|
/* Set up the housekeeping SPI to be connected internally so */
|
48 |
|
|
/* that external pin changes don't affect it. */
|
49 |
|
|
|
50 |
|
|
reg_spimaster_config = 0xa002; // Enable, prescaler = 2,
|
51 |
|
|
// connect to housekeeping SPI
|
52 |
|
|
|
53 |
|
|
// Connect the housekeeping SPI to the SPI master
|
54 |
|
|
// so that the CSB line is not left floating. This allows
|
55 |
|
|
// all of the GPIO pins to be used for user functions.
|
56 |
|
|
|
57 |
|
|
reg_mprj_io_31 = GPIO_MODE_MGMT_STD_OUTPUT;
|
58 |
|
|
reg_mprj_io_30 = GPIO_MODE_MGMT_STD_OUTPUT;
|
59 |
|
|
reg_mprj_io_29 = GPIO_MODE_MGMT_STD_OUTPUT;
|
60 |
|
|
reg_mprj_io_28 = GPIO_MODE_MGMT_STD_OUTPUT;
|
61 |
|
|
reg_mprj_io_27 = GPIO_MODE_MGMT_STD_OUTPUT;
|
62 |
|
|
reg_mprj_io_26 = GPIO_MODE_MGMT_STD_OUTPUT;
|
63 |
|
|
reg_mprj_io_25 = GPIO_MODE_MGMT_STD_OUTPUT;
|
64 |
|
|
reg_mprj_io_24 = GPIO_MODE_MGMT_STD_OUTPUT;
|
65 |
|
|
reg_mprj_io_23 = GPIO_MODE_MGMT_STD_OUTPUT;
|
66 |
|
|
reg_mprj_io_22 = GPIO_MODE_MGMT_STD_OUTPUT;
|
67 |
|
|
reg_mprj_io_21 = GPIO_MODE_MGMT_STD_OUTPUT;
|
68 |
|
|
reg_mprj_io_20 = GPIO_MODE_MGMT_STD_OUTPUT;
|
69 |
|
|
reg_mprj_io_19 = GPIO_MODE_MGMT_STD_OUTPUT;
|
70 |
|
|
reg_mprj_io_18 = GPIO_MODE_MGMT_STD_OUTPUT;
|
71 |
|
|
reg_mprj_io_17 = GPIO_MODE_MGMT_STD_OUTPUT;
|
72 |
|
|
reg_mprj_io_16 = GPIO_MODE_MGMT_STD_OUTPUT;
|
73 |
|
|
|
74 |
|
|
/* Apply configuration */
|
75 |
|
|
reg_mprj_xfer = 1;
|
76 |
|
|
while (reg_mprj_xfer == 1);
|
77 |
|
|
|
78 |
|
|
reg_la2_oenb = reg_la2_iena = 0xFFFFFFFF; // [95:64]
|
79 |
|
|
|
80 |
|
|
// Flag start of the test
|
81 |
|
|
reg_mprj_datal = 0xAB600000;
|
82 |
|
|
|
83 |
|
|
reg_mprj_slave = 0x00002710;
|
84 |
|
|
if (reg_mprj_slave == 0x2752) {
|
85 |
|
|
reg_mprj_datal = 0xAB610000;
|
86 |
|
|
} else {
|
87 |
|
|
reg_mprj_datal = 0xAB600000;
|
88 |
|
|
}
|
89 |
|
|
}
|