OpenCores
URL https://opencores.org/ocsvn/yifive/yifive/trunk

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [dv/] [la_test1/] [la_test1.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
 
24
/*
25
        MPRJ Logic Analyzer Test:
26
                - Observes counter value through LA probes [31:0]
27
                - Sets counter initial value through LA probes [63:32]
28
                - Flags when counter value exceeds 500 through the management SoC gpio
29
                - Outputs message to the UART when the test concludes successfuly
30
*/
31
 
32
void main()
33
{
34
 
35
        /* Set up the housekeeping SPI to be connected internally so    */
36
        /* that external pin changes don't affect it.                   */
37
 
38
        reg_spimaster_config = 0xa002;  // Enable, prescaler = 2,
39
                                        // connect to housekeeping SPI
40
 
41
        // Connect the housekeeping SPI to the SPI master
42
        // so that the CSB line is not left floating.  This allows
43
        // all of the GPIO pins to be used for user functions.
44
 
45
        // The upper GPIO pins are configured to be output
46
        // and accessble to the management SoC.
47
        // Used to flad the start/end of a test 
48
        // The lower GPIO pins are configured to be output
49
        // and accessible to the user project.  They show
50
        // the project count value, although this test is
51
        // designed to read the project count through the
52
        // logic analyzer probes.
53
        // I/O 6 is configured for the UART Tx line
54
 
55
        reg_mprj_io_31 = GPIO_MODE_MGMT_STD_OUTPUT;
56
        reg_mprj_io_30 = GPIO_MODE_MGMT_STD_OUTPUT;
57
        reg_mprj_io_29 = GPIO_MODE_MGMT_STD_OUTPUT;
58
        reg_mprj_io_28 = GPIO_MODE_MGMT_STD_OUTPUT;
59
        reg_mprj_io_27 = GPIO_MODE_MGMT_STD_OUTPUT;
60
        reg_mprj_io_26 = GPIO_MODE_MGMT_STD_OUTPUT;
61
        reg_mprj_io_25 = GPIO_MODE_MGMT_STD_OUTPUT;
62
        reg_mprj_io_24 = GPIO_MODE_MGMT_STD_OUTPUT;
63
        reg_mprj_io_23 = GPIO_MODE_MGMT_STD_OUTPUT;
64
        reg_mprj_io_22 = GPIO_MODE_MGMT_STD_OUTPUT;
65
        reg_mprj_io_21 = GPIO_MODE_MGMT_STD_OUTPUT;
66
        reg_mprj_io_20 = GPIO_MODE_MGMT_STD_OUTPUT;
67
        reg_mprj_io_19 = GPIO_MODE_MGMT_STD_OUTPUT;
68
        reg_mprj_io_18 = GPIO_MODE_MGMT_STD_OUTPUT;
69
        reg_mprj_io_17 = GPIO_MODE_MGMT_STD_OUTPUT;
70
        reg_mprj_io_16 = GPIO_MODE_MGMT_STD_OUTPUT;
71
 
72
        reg_mprj_io_15 = GPIO_MODE_USER_STD_OUTPUT;
73
        reg_mprj_io_14 = GPIO_MODE_USER_STD_OUTPUT;
74
        reg_mprj_io_13 = GPIO_MODE_USER_STD_OUTPUT;
75
        reg_mprj_io_12 = GPIO_MODE_USER_STD_OUTPUT;
76
        reg_mprj_io_11 = GPIO_MODE_USER_STD_OUTPUT;
77
        reg_mprj_io_10 = GPIO_MODE_USER_STD_OUTPUT;
78
        reg_mprj_io_9  = GPIO_MODE_USER_STD_OUTPUT;
79
        reg_mprj_io_8  = GPIO_MODE_USER_STD_OUTPUT;
80
        reg_mprj_io_7  = GPIO_MODE_USER_STD_OUTPUT;
81
        reg_mprj_io_5  = GPIO_MODE_USER_STD_OUTPUT;
82
        reg_mprj_io_4  = GPIO_MODE_USER_STD_OUTPUT;
83
        reg_mprj_io_3  = GPIO_MODE_USER_STD_OUTPUT;
84
        reg_mprj_io_2  = GPIO_MODE_USER_STD_OUTPUT;
85
        reg_mprj_io_1  = GPIO_MODE_USER_STD_OUTPUT;
86
        reg_mprj_io_0  = GPIO_MODE_USER_STD_OUTPUT;
87
 
88
        reg_mprj_io_6  = GPIO_MODE_MGMT_STD_OUTPUT;
89
 
90
        // Set UART clock to 64 kbaud (enable before I/O configuration)
91
        reg_uart_clkdiv = 625;
92
        reg_uart_enable = 1;
93
 
94
        /* Apply configuration */
95
        reg_mprj_xfer = 1;
96
        while (reg_mprj_xfer == 1);
97
 
98
        // Configure LA probes [31:0], [127:64] as inputs to the cpu 
99
        // Configure LA probes [63:32] as outputs from the cpu
100
        reg_la0_oenb = reg_la0_iena = 0xFFFFFFFF;    // [31:0]
101
        reg_la1_oenb = reg_la1_iena = 0x00000000;    // [63:32]
102
        reg_la2_oenb = reg_la2_iena = 0xFFFFFFFF;    // [95:64]
103
        reg_la3_oenb = reg_la3_iena = 0xFFFFFFFF;    // [127:96]
104
 
105
        // Flag start of the test 
106
        reg_mprj_datal = 0xAB400000;
107
 
108
        // Set Counter value to zero through LA probes [63:32]
109
        reg_la1_data = 0x00000000;
110
 
111
        // Configure LA probes from [63:32] as inputs to disable counter write
112
        reg_la1_oenb = reg_la1_iena = 0xFFFFFFFF;
113
 
114
        while (1) {
115
                if (reg_la0_data > 0x1F4) {
116
                        reg_mprj_datal = 0xAB410000;
117
                        break;
118
                }
119
        }
120
        print("\n");
121
        print("Monitor: Test 2 Passed\n\n");    // Makes simulation very long!
122
        reg_mprj_datal = 0xAB510000;
123
}
124
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.