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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [ethmac_reg.S] - Blame information for rev 82

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 System Ethernet MAC Test                            //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests wishbone access to registers in the Ethernet MAC      //
10
//  module.                                                     //
11
//                                                              //
12
//  Author(s):                                                  //
13
//      - Conor Santifort, csantifort.amber@gmail.com           //
14
//                                                              //
15
//////////////////////////////////////////////////////////////////
16
//                                                              //
17
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
18
//                                                              //
19
// This source file may be used and distributed without         //
20
// restriction provided that this copyright statement is not    //
21
// removed from the file and that any derivative work contains  //
22
// the original copyright notice and the associated disclaimer. //
23
//                                                              //
24
// This source file is free software; you can redistribute it   //
25
// and/or modify it under the terms of the GNU Lesser General   //
26
// Public License as published by the Free Software Foundation; //
27
// either version 2.1 of the License, or (at your option) any   //
28
// later version.                                               //
29
//                                                              //
30
// This source is distributed in the hope that it will be       //
31
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
32
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
33
// PURPOSE.  See the GNU Lesser General Public License for more //
34
// details.                                                     //
35
//                                                              //
36
// You should have received a copy of the GNU Lesser General    //
37
// Public License along with this source; if not, download it   //
38
// from http://www.opencores.org/lgpl.shtml                     //
39
//                                                              //
40
*****************************************************************/
41
 
42
#include "amber_registers.h"
43
 
44
        .section .text
45
        .globl  main
46
main:
47
 
48
        @ Test reading of a register in the ethmac module
49
        ldr     r0, AdrEthMacModer
50
        ldr     r1, [r0]
51
        ldr     r2, EthMacModerDefault
52
        cmp     r1, r2
53
        movne   r10, #10
54
        bne     testfail
55
 
56
        @ Turn on Duplex Mode, bit 10, and write back new value
57
        orr     r1, r1, #0x400
58
        str     r1, [r0]
59
 
60
        @ Read back again to check the value
61
        ldr     r3, [r0]
62
        orr     r2, r2, #0x400
63
        cmp     r3, r2
64
        movne   r10, #20
65
        bne     testfail
66
 
67
        @ Set clock divider to 10 -> 3.3MHz MDC
68
        ldr     r4, AdrEthMacMIIModer
69
        mov     r5, #10
70
        str     r5, [r4]
71
 
72
        @ Set MII address - device [4:0], register [12:8]
73
        ldr     r4, AdrEthMacMIIAddress
74
        mov     r5,       #0x07
75 82 csantifort
 
76
                @ MII_BMSR register in eth_test.v has reg address of 1
77
        orr     r5, r5, #0x0100
78 2 csantifort
        str     r5, [r4]
79
 
80
        @ receive (read PHY register) Command
81
        ldr     r4, AdrEthMacMIICommand
82
        mov     r5, #0x2
83
        str     r5, [r4]
84
 
85
        @ wait for busy, bit 1, to go low
86
        @ Use r6 as a timeout
87
        ldr     r4, AdrEthMacMIIStatus
88
        mov     r6, #0
89
wait_busy:
90
        add     r6, r6, #1
91
        cmp     r6, #0x400
92
        @ Timeout error
93
        moveq   r10, #30
94
        beq     testfail
95
 
96
        ldr     r5, [r4]
97
        ands    r5, r5, #2
98
        beq     readback
99
        b       wait_busy
100
 
101
 
102
readback:
103
        ldr     r4, AdrEthMacMIIRxData
104
        ldr     r5, [r4]
105
        ldr     r6, ExpectedMIIReadBack
106
        cmp     r5, r6
107
        movne   r10, #100
108
        bne     testfail
109
        b       testpass
110
 
111
 
112
testfail:
113
        ldr     r11, AdrTestStatus
114
        str     r10, [r11]
115
        b       testfail
116
 
117
testpass:
118
        ldr     r11, AdrTestStatus
119
        mov     r10, #17
120
        str     r10, [r11]
121
        b       testpass
122
 
123
 
124
/* Write 17 to this address to generate a Test Passed message */
125
AdrTestStatus:          .word  ADR_AMBER_TEST_STATUS
126
AdrEthMacModer:         .word  ADR_ETHMAC_MODER
127
AdrEthMacMIIModer:      .word  ADR_ETHMAC_MIIMODER
128
AdrEthMacMIICommand:    .word  ADR_ETHMAC_MIICOMMAND
129
AdrEthMacMIIAddress:    .word  ADR_ETHMAC_MIIADDRESS
130
AdrEthMacMIITxData:     .word  ADR_ETHMAC_MIITXDATA
131
AdrEthMacMIIRxData:     .word  ADR_ETHMAC_MIIRXDATA
132
AdrEthMacMIIStatus:     .word  ADR_ETHMAC_MIISTATUS
133
 
134
EthMacModerDefault:     .word  0x0000a000
135 82 csantifort
ExpectedMIIReadBack:    .word  0x0000fe04  @ value from eth_test.v, state MD_TURN1
136 2 csantifort
 
137
 
138
/* ========================================================================= */
139
/* ========================================================================= */
140
 

powered by: WebSVN 2.1.0

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