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

Subversion Repositories yifive

[/] [yifive/] [trunk/] [caravel_yifive/] [verilog/] [dv/] [mprj_stimulus/] [mprj_stimulus.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
 
21
// --------------------------------------------------------
22
 
23
void main()
24
{
25
    // The upper GPIO pins are configured to be output
26
    // and accessble to the management SoC.
27
    // Used to flag the start/end of a test
28
    // The lower GPIO pins are configured to be output
29
    // and accessible to the user project.  They show
30
    // the project count value, although this test is
31
    // designed to read the project count through the
32
    // logic analyzer probes.
33
    // I/O 6 is configured for the UART Tx line
34
    uint32_t testval;
35
 
36
    reg_spimaster_config = 0xa002;      // Enable, prescaler = 2
37
 
38
    reg_mprj_datal = 0x00000000;
39
    reg_mprj_datah = 0x00000000;
40
 
41
    reg_mprj_io_37 = GPIO_MODE_MGMT_STD_OUTPUT;;
42
    reg_mprj_io_36 = GPIO_MODE_MGMT_STD_OUTPUT;;
43
    reg_mprj_io_35 = GPIO_MODE_MGMT_STD_BIDIRECTIONAL;
44
    reg_mprj_io_34 = GPIO_MODE_MGMT_STD_BIDIRECTIONAL;
45
    reg_mprj_io_33 = GPIO_MODE_MGMT_STD_BIDIRECTIONAL;
46
    reg_mprj_io_32 = GPIO_MODE_MGMT_STD_BIDIRECTIONAL;
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_OUT_MONITORED;
66
    reg_mprj_io_14 = GPIO_MODE_USER_STD_OUT_MONITORED;
67
    reg_mprj_io_13 = GPIO_MODE_USER_STD_OUT_MONITORED;
68
    reg_mprj_io_12 = GPIO_MODE_USER_STD_OUT_MONITORED;
69
    reg_mprj_io_11 = GPIO_MODE_USER_STD_OUT_MONITORED;
70
    reg_mprj_io_10 = GPIO_MODE_USER_STD_OUT_MONITORED;
71
    reg_mprj_io_9  = GPIO_MODE_USER_STD_OUT_MONITORED;
72
    reg_mprj_io_8  = GPIO_MODE_USER_STD_OUT_MONITORED;
73
    reg_mprj_io_7  = GPIO_MODE_USER_STD_OUT_MONITORED;
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
    reg_mprj_io_6  = GPIO_MODE_MGMT_STD_OUTPUT;
82
 
83
    // Set UART clock to 64 kbaud (enable before I/O configuration)
84
    reg_uart_clkdiv = 625;
85
    reg_uart_enable = 1;
86
 
87
    /* Apply configuration */
88
    reg_mprj_xfer = 1;
89
    while (reg_mprj_xfer == 1);
90
 
91
    /* TEST:  Recast channels 35 to 32 to allow input to user project   */
92
    /* This is done locally only:  Do not run reg_mprj_xfer!            */
93
    reg_mprj_io_35 = GPIO_MODE_MGMT_STD_OUTPUT;
94
    reg_mprj_io_34 = GPIO_MODE_MGMT_STD_OUTPUT;
95
    reg_mprj_io_33 = GPIO_MODE_MGMT_STD_OUTPUT;
96
    reg_mprj_io_32 = GPIO_MODE_MGMT_STD_OUTPUT;
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
    reg_mprj_datal = 0xAB410000;
115
    reg_mprj_datah = 0x00000000;
116
 
117
    // Test ability to force data on channel 37
118
    // NOTE:  Only the low 6 bits of reg_mprj_datah are meaningful
119
    reg_mprj_datah = 0xffffffca;
120
    reg_mprj_datah = 0x00000000;
121
    reg_mprj_datah = 0x0f0f0fc5;
122
    reg_mprj_datah = 0x00000000;
123
 
124
    // Test ability to read back data generated by the user project
125
    // on the "monitored" outputs.  Read from the lower 16 bits and
126
    // copy the value to the upper 16 bits.
127
 
128
    testval = reg_mprj_datal;
129
    reg_mprj_datal = ((testval & 0xff8) << 9) & 0xffff0000;
130
 
131
    // Flag end of the test
132
    reg_mprj_datal = 0xAB510000;
133
}
134
 

powered by: WebSVN 2.1.0

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