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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [cache_flush.S] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 Core Instruction Test                               //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Tests the cache flush function. Does a flush in the middle  //
10
//  of a sequence of data reads. Checks that all the data       //
11
//  reads are correct.                                          //
12
//                                                              //
13
//  Author(s):                                                  //
14
//      - Conor Santifort, csantifort.amber@gmail.com           //
15
//                                                              //
16
//////////////////////////////////////////////////////////////////
17
//                                                              //
18
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
19
//                                                              //
20
// This source file may be used and distributed without         //
21
// restriction provided that this copyright statement is not    //
22
// removed from the file and that any derivative work contains  //
23
// the original copyright notice and the associated disclaimer. //
24
//                                                              //
25
// This source file is free software; you can redistribute it   //
26
// and/or modify it under the terms of the GNU Lesser General   //
27
// Public License as published by the Free Software Foundation; //
28
// either version 2.1 of the License, or (at your option) any   //
29
// later version.                                               //
30
//                                                              //
31
// This source is distributed in the hope that it will be       //
32
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
33
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
34
// PURPOSE.  See the GNU Lesser General Public License for more //
35
// details.                                                     //
36
//                                                              //
37
// You should have received a copy of the GNU Lesser General    //
38
// Public License along with this source; if not, download it   //
39
// from http://www.opencores.org/lgpl.shtml                     //
40
//                                                              //
41
*****************************************************************/
42
 
43
#include "amber_registers.h"
44
 
45
        .section .text
46
        .globl  main
47
main:
48
        @ ---------------------
49
        @ Enable the cache
50
        @ ---------------------
51
        mov     r0,  #0x00000001
52
        mcr     p15, 0, r0, c3, c0, 0   @ cacheable area
53
        mov     r0,  #1
54
        mcr     p15, 0, r0, c2, c0, 0   @ cache enable
55
        nop
56
        nop
57
 
58
 
59
        @ Write to a block of memory that straddles
60
        @ across a cache region boundary so that
61
        @ the first 16 bytes are cacheable and
62
        @ the second 16 are not
63
        ldr     r0, AdrTestBase
64
        mov     r2, #0x20
65
1:      subs    r2, r2, #1
66
        str     r2, [r0], #4
67
        bne     1b
68
 
69
        @ loop a few times so that
70
        @ the instructions will be caches on the second and
71
        @ subsequent passes
72
        mov     r7, #7
73
 
74
        @ Read back the same block
75
loop:   ldr     r3, AdrTestBase
76
        mov     r5, #0x20
77
        mov     r6, #0
78
2:      ldr     r4, [r3], #4
79
        add     r6, r6, r4
80
 
81
        @ Flush the cache when the r7 loop count value is even
82
        @ a write of any value to cp15, reg 1 will trigger a flush
83
        ands    r8, r7, #1
84
        cmpeq   r5, #21
85
        cmpne   r5, #0x100
86
        mcreq   p15, 0, r0, c1, c0, 0   @ cache enable
87
 
88
        subs    r5, r5, #1
89
        bne     2b
90
 
91
 
92
        @ Check that the sum of the data reads is correct
93
        cmp     r6, #0x1f0
94
        movne   r10, #10
95
        bne     testfail
96
 
97
        subs    r7, r7, #1
98
        bne     loop
99
 
100
 
101
        b       testpass
102
@ ------------------------------------------
103
@ ------------------------------------------
104
 
105
testfail:
106
        ldr     r11, AdrTestStatus
107
        str     r10, [r11]
108
        b       testfail
109
 
110
testpass:
111
        ldr     r11, AdrTestStatus
112
        mov     r10, #17
113
        str     r10, [r11]
114
        b       testpass
115
 
116
 
117
 
118
/* Write 17 to this address to generate a Test Passed message */
119
AdrTestStatus:              .word ADR_AMBER_TEST_STATUS
120
AdrTestBase  :              .word 0x001fffc0
121
 
122
/* sum of numbers 0 to 2047 inclusive */
123
MagicNumber1024  :          .word  523776
124
MagicNumber2048  :          .word 2096128
125
 
126
/* ========================================================================= */
127
/* ========================================================================= */
128
 

powered by: WebSVN 2.1.0

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