URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
[/] [amber/] [trunk/] [hw/] [tests/] [ethmac_reg.S] - Rev 63
Go to most recent revision | Compare with Previous | Blame | View Log
/*****************************************************************// //// Amber 2 System Ethernet MAC Test //// //// This file is part of the Amber project //// http://www.opencores.org/project,amber //// //// Description //// Tests wishbone access to registers in the Ethernet MAC //// module. //// //// Author(s): //// - Conor Santifort, csantifort.amber@gmail.com //// ////////////////////////////////////////////////////////////////////// //// Copyright (C) 2010 Authors and OPENCORES.ORG //// //// This source file may be used and distributed without //// restriction provided that this copyright statement is not //// removed from the file and that any derivative work contains //// the original copyright notice and the associated disclaimer. //// //// This source file is free software; you can redistribute it //// and/or modify it under the terms of the GNU Lesser General //// Public License as published by the Free Software Foundation; //// either version 2.1 of the License, or (at your option) any //// later version. //// //// This source is distributed in the hope that it will be //// useful, but WITHOUT ANY WARRANTY; without even the implied //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //// PURPOSE. See the GNU Lesser General Public License for more //// details. //// //// You should have received a copy of the GNU Lesser General //// Public License along with this source; if not, download it //// from http://www.opencores.org/lgpl.shtml //// //*****************************************************************/#include "amber_registers.h".section .text.globl mainmain:@ Test reading of a register in the ethmac moduleldr r0, AdrEthMacModerldr r1, [r0]ldr r2, EthMacModerDefaultcmp r1, r2movne r10, #10bne testfail@ Turn on Duplex Mode, bit 10, and write back new valueorr r1, r1, #0x400str r1, [r0]@ Read back again to check the valueldr r3, [r0]orr r2, r2, #0x400cmp r3, r2movne r10, #20bne testfail@ Set clock divider to 10 -> 3.3MHz MDCldr r4, AdrEthMacMIIModermov r5, #10str r5, [r4]@ Set MII address - device [4:0], register [12:8]ldr r4, AdrEthMacMIIAddressmov r5, #0x07orr r5, r5, #0x1600str r5, [r4]@ receive (read PHY register) Commandldr r4, AdrEthMacMIICommandmov r5, #0x2str r5, [r4]@ wait for busy, bit 1, to go low@ Use r6 as a timeoutldr r4, AdrEthMacMIIStatusmov r6, #0wait_busy:add r6, r6, #1cmp r6, #0x400@ Timeout errormoveq r10, #30beq testfailldr r5, [r4]ands r5, r5, #2beq readbackb wait_busyreadback:ldr r4, AdrEthMacMIIRxDataldr r5, [r4]ldr r6, ExpectedMIIReadBackcmp r5, r6movne r10, #100bne testfailb testpasstestfail:ldr r11, AdrTestStatusstr r10, [r11]b testfailtestpass:ldr r11, AdrTestStatusmov r10, #17str r10, [r11]b testpass/* Write 17 to this address to generate a Test Passed message */AdrTestStatus: .word ADR_AMBER_TEST_STATUSAdrEthMacModer: .word ADR_ETHMAC_MODERAdrEthMacMIIModer: .word ADR_ETHMAC_MIIMODERAdrEthMacMIICommand: .word ADR_ETHMAC_MIICOMMANDAdrEthMacMIIAddress: .word ADR_ETHMAC_MIIADDRESSAdrEthMacMIITxData: .word ADR_ETHMAC_MIITXDATAAdrEthMacMIIRxData: .word ADR_ETHMAC_MIIRXDATAAdrEthMacMIIStatus: .word ADR_ETHMAC_MIISTATUSEthMacModerDefault: .word 0x0000a000ExpectedMIIReadBack: .word 0x0000ffff/* ========================================================================= *//* ========================================================================= */
Go to most recent revision | Compare with Previous | Blame | View Log
