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 |
22 |
dinesha |
// User Project Slaves (0x3000_0000)
|
23 |
|
|
#define reg_mprj_slave (*(volatile uint32_t*)0x30000000)
|
24 |
|
|
|
25 |
|
|
#define reg_mprj_globl_reg0 (*(volatile uint32_t*)0x30000000)
|
26 |
|
|
#define reg_mprj_globl_reg1 (*(volatile uint32_t*)0x30000004)
|
27 |
|
|
#define reg_mprj_globl_reg2 (*(volatile uint32_t*)0x30000008)
|
28 |
|
|
#define reg_mprj_globl_reg3 (*(volatile uint32_t*)0x3000000C)
|
29 |
|
|
#define reg_mprj_globl_reg4 (*(volatile uint32_t*)0x30000010)
|
30 |
|
|
#define reg_mprj_globl_reg5 (*(volatile uint32_t*)0x30000014)
|
31 |
|
|
#define reg_mprj_globl_reg6 (*(volatile uint32_t*)0x30000018)
|
32 |
|
|
#define reg_mprj_globl_reg7 (*(volatile uint32_t*)0x3000001C)
|
33 |
|
|
#define reg_mprj_globl_reg8 (*(volatile uint32_t*)0x30000020)
|
34 |
|
|
#define reg_mprj_globl_reg9 (*(volatile uint32_t*)0x30000024)
|
35 |
|
|
#define reg_mprj_globl_reg10 (*(volatile uint32_t*)0x30000028)
|
36 |
|
|
#define reg_mprj_globl_reg11 (*(volatile uint32_t*)0x3000002C)
|
37 |
|
|
#define reg_mprj_globl_reg12 (*(volatile uint32_t*)0x30000030)
|
38 |
|
|
#define reg_mprj_globl_reg13 (*(volatile uint32_t*)0x30000034)
|
39 |
|
|
#define reg_mprj_globl_reg14 (*(volatile uint32_t*)0x30000038)
|
40 |
|
|
#define reg_mprj_globl_reg15 (*(volatile uint32_t*)0x3000003C)
|
41 |
|
|
|
42 |
|
|
|
43 |
2 |
dinesha |
/*
|
44 |
|
|
Wishbone Test:
|
45 |
|
|
- Configures MPRJ lower 8-IO pins as outputs
|
46 |
|
|
- Checks counter value through the wishbone port
|
47 |
|
|
*/
|
48 |
|
|
int i = 0;
|
49 |
|
|
int clk = 0;
|
50 |
|
|
|
51 |
|
|
void main()
|
52 |
|
|
{
|
53 |
|
|
|
54 |
22 |
dinesha |
int bFail = 0;
|
55 |
2 |
dinesha |
/*
|
56 |
|
|
IO Control Registers
|
57 |
|
|
| DM | VTRIP | SLOW | AN_POL | AN_SEL | AN_EN | MOD_SEL | INP_DIS | HOLDH | OEB_N | MGMT_EN |
|
58 |
|
|
| 3-bits | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit | 1-bit |
|
59 |
|
|
Output: 0000_0110_0000_1110 (0x1808) = GPIO_MODE_USER_STD_OUTPUT
|
60 |
|
|
| DM | VTRIP | SLOW | AN_POL | AN_SEL | AN_EN | MOD_SEL | INP_DIS | HOLDH | OEB_N | MGMT_EN |
|
61 |
|
|
| 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
Input: 0000_0001_0000_1111 (0x0402) = GPIO_MODE_USER_STD_INPUT_NOPULL
|
65 |
|
|
| DM | VTRIP | SLOW | AN_POL | AN_SEL | AN_EN | MOD_SEL | INP_DIS | HOLDH | OEB_N | MGMT_EN |
|
66 |
|
|
| 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
|
67 |
|
|
*/
|
68 |
|
|
|
69 |
|
|
/* Set up the housekeeping SPI to be connected internally so */
|
70 |
|
|
/* that external pin changes don't affect it. */
|
71 |
|
|
|
72 |
|
|
reg_spimaster_config = 0xa002; // Enable, prescaler = 2,
|
73 |
|
|
// connect to housekeeping SPI
|
74 |
|
|
|
75 |
|
|
// Connect the housekeeping SPI to the SPI master
|
76 |
|
|
// so that the CSB line is not left floating. This allows
|
77 |
|
|
// all of the GPIO pins to be used for user functions.
|
78 |
|
|
|
79 |
|
|
reg_mprj_io_31 = GPIO_MODE_MGMT_STD_OUTPUT;
|
80 |
|
|
reg_mprj_io_30 = GPIO_MODE_MGMT_STD_OUTPUT;
|
81 |
|
|
reg_mprj_io_29 = GPIO_MODE_MGMT_STD_OUTPUT;
|
82 |
|
|
reg_mprj_io_28 = GPIO_MODE_MGMT_STD_OUTPUT;
|
83 |
|
|
reg_mprj_io_27 = GPIO_MODE_MGMT_STD_OUTPUT;
|
84 |
|
|
reg_mprj_io_26 = GPIO_MODE_MGMT_STD_OUTPUT;
|
85 |
|
|
reg_mprj_io_25 = GPIO_MODE_MGMT_STD_OUTPUT;
|
86 |
|
|
reg_mprj_io_24 = GPIO_MODE_MGMT_STD_OUTPUT;
|
87 |
|
|
reg_mprj_io_23 = GPIO_MODE_MGMT_STD_OUTPUT;
|
88 |
|
|
reg_mprj_io_22 = GPIO_MODE_MGMT_STD_OUTPUT;
|
89 |
|
|
reg_mprj_io_21 = GPIO_MODE_MGMT_STD_OUTPUT;
|
90 |
|
|
reg_mprj_io_20 = GPIO_MODE_MGMT_STD_OUTPUT;
|
91 |
|
|
reg_mprj_io_19 = GPIO_MODE_MGMT_STD_OUTPUT;
|
92 |
|
|
reg_mprj_io_18 = GPIO_MODE_MGMT_STD_OUTPUT;
|
93 |
|
|
reg_mprj_io_17 = GPIO_MODE_MGMT_STD_OUTPUT;
|
94 |
|
|
reg_mprj_io_16 = GPIO_MODE_MGMT_STD_OUTPUT;
|
95 |
|
|
|
96 |
|
|
/* Apply configuration */
|
97 |
|
|
reg_mprj_xfer = 1;
|
98 |
|
|
while (reg_mprj_xfer == 1);
|
99 |
|
|
|
100 |
|
|
reg_la2_oenb = reg_la2_iena = 0xFFFFFFFF; // [95:64]
|
101 |
|
|
|
102 |
|
|
// Flag start of the test
|
103 |
|
|
reg_mprj_datal = 0xAB600000;
|
104 |
|
|
|
105 |
22 |
dinesha |
if (reg_mprj_globl_reg1 != 0xA55AA55A) bFail = 1;
|
106 |
|
|
if (reg_mprj_globl_reg2 != 0xAABBCCDD) bFail = 1;
|
107 |
|
|
|
108 |
|
|
// Write software Write & Read Register
|
109 |
|
|
reg_mprj_globl_reg6 = 0x11223344;
|
110 |
|
|
reg_mprj_globl_reg7 = 0x22334455;
|
111 |
|
|
reg_mprj_globl_reg8 = 0x33445566;
|
112 |
|
|
reg_mprj_globl_reg9 = 0x44556677;
|
113 |
|
|
reg_mprj_globl_reg10 = 0x55667788;
|
114 |
|
|
reg_mprj_globl_reg11 = 0x66778899;
|
115 |
|
|
reg_mprj_globl_reg12 = 0x778899AA;
|
116 |
|
|
reg_mprj_globl_reg13 = 0x8899AABB;
|
117 |
|
|
reg_mprj_globl_reg14 = 0x99AABBCC;
|
118 |
|
|
reg_mprj_globl_reg15 = 0xAABBCCDD;
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
if (reg_mprj_globl_reg6 != 0x11223344) bFail = 1;
|
122 |
|
|
if (reg_mprj_globl_reg7 != 0x22334455) bFail = 1;
|
123 |
|
|
if (reg_mprj_globl_reg8 != 0x33445566) bFail = 1;
|
124 |
|
|
if (reg_mprj_globl_reg9 != 0x44556677) bFail = 1;
|
125 |
|
|
if (reg_mprj_globl_reg10 != 0x55667788) bFail = 1;
|
126 |
|
|
if (reg_mprj_globl_reg11 != 0x66778899) bFail = 1;
|
127 |
|
|
if (reg_mprj_globl_reg12 != 0x778899AA) bFail = 1;
|
128 |
|
|
if (reg_mprj_globl_reg13 != 0x8899AABB) bFail = 1;
|
129 |
|
|
if (reg_mprj_globl_reg14 != 0x99AABBCC) bFail = 1;
|
130 |
|
|
if (reg_mprj_globl_reg15 != 0xAABBCCDD) bFail = 1;
|
131 |
|
|
|
132 |
|
|
if(bFail == 0) {
|
133 |
2 |
dinesha |
reg_mprj_datal = 0xAB610000;
|
134 |
|
|
} else {
|
135 |
|
|
reg_mprj_datal = 0xAB600000;
|
136 |
|
|
}
|
137 |
|
|
}
|