URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
[/] [amber/] [trunk/] [hw/] [tests/] [mul.S] - Rev 66
Go to most recent revision | Compare with Previous | Blame | View Log
/*****************************************************************// //// Amber 2 Core Instruction Test //// //// This file is part of the Amber project //// http://www.opencores.org/project,amber //// //// Description //// Tests the mul (multiply) instruction //// //// Uses a testset of 16 numbers and multiplies them //// with eachother in every combination - 256 multiplications. //// Checks each result against an expected result //// //// 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 mul@ -------------------------------mov r6, #0ldr r8, AdrTestsetloop: and r2, r6, #0xfldr r7, [r8, r2, lsl #2]and r4, r6, #0xf0ldr r5, [r8, r4, lsr #2]mul r4, r7, r5@-------------------------------@ Check Result@ -------------------------------ldr r9, AdrAnswersldr r10, [r9, r6, lsl #2]cmp r4, r10bne testfailadd r6, r6, #1cmp r6, #256beq test2b looptest2:@-------------------------------@ Test Flags@ Only the N and Z flags get set@ the C and V flags can be unpredictable in v4@ but this implementation leaves them at their@ old values@ -------------------------------@ clear flags firstbic r2, r2, #0xf0000000teqp pc, r2mov r0, #1mov r1, #-1muls r2, r0, r1mov r4, pcand r4, r4, #0xf0000000 @ clear non-flag bitscmp r4, #0x80000000movne r10, #100bne testfail2cmp r2, #-1movne r10, #110bne testfail2test3:@-------------------------------@ Test Flags@ This time ensure that C and V retain their@ old values@ -------------------------------@ clear flags firstmov r2, pcldr r7, PCMaskbic r2, r2, r7 @ clear pc bitsbic r2, r2, #0xf0000000 @ clear condition clagsorr r2, r2, #0x30000000 @ set C and V flagsteqp pc, r2mov r0, #0mov r1, #-1muls r2, r0, r1mov r4, pcand r4, r4, #0xf0000000 @ clear non-flag bitscmp r4, #0x70000000movne r10, #120bne testfail2cmp r2, #0movne r10, #130bne testfail2test4:@-------------------------------@ Test sequence of back-to-back MULs@ where only some are executed@-------------------------------mov r0, #1mov r1, #2mov r2, #7mov r3, #3mov r4, #5mov r5, #6mov r7, #0mov r8, #0mov r9, #0mov r10, #0cmp r0, r1mulne r7, r4, r5 @ executesmuleq r8, r2, r3 @ doesnt executemulne r9, r1, r4 @ executesmulne r10, r3, r3 @ executescmp r7, #30movne r10, #200bne testfail2cmp r8, #0movne r10, #210bne testfail2cmp r9, #10movne r10, #220bne testfail2cmp r10, #9movne r10, #230bne testfail2test5:@-------------------------------@ Test sequence of back-to-back MULs@ where only some are executed@ and some change flags@-------------------------------mov r0, #0mov r1, #-1mov r2, #7mov r3, #3mov r4, #5mov r5, #6mov r7, #0mov r8, #0mov r9, #0mov r10, #0cmp r0, r1mulnes r7, r0, r1 @ executes and changes flagsmuleq r8, r2, r3 @ executesmulne r9, r1, r4 @ doesnt executemulne r10, r3, r3 @ doesnt executescmp r7, #0movne r10, #240bne testfail2cmp r8, #21movne r10, #245bne testfail2cmp r9, #0movne r10, #250bne testfail2cmp r10, #0movne r10, #255bne testfail2test6:@-------------------------------@ Test tricky sequence of operations@-------------------------------mov r3, #1mov r5, #0mov r1, #7cmp r1, #7ldreq r2, Data1 @ 3ldrne r3, Data2 @ 7, not loadedmuleq r4, r2, r3ldrne r5, Data2cmp r5, #0movne r10, #150bne testfail2cmp r4, #3movne r10, #160bne testfail2@ ------------------------------------------@ ------------------------------------------b testpasstestfail:testfail2:ldr r11, AdrTestStatusstr r10, [r11]b testfail2testpass: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_STATUSAdrTestset: .word TestsetAdrAnswers: .word AnswersData1: .word 0x3Data2: .word 0x7PCMask: .word 0x03fffffcTestset:.word 0.word 1.word 2.word 3.word 27.word 0x0000ffff.word 0x40000000.word 0x7fffffff.word 0x7ffffffe.word 0xffffffff.word 0xfffffffe.word 0xfffffffd.word 0xffffffe5.word 0x8fff0000.word 0x80000000.word 0x80000001Answers:.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000000.word 0x00000001.word 0x00000002.word 0x00000003.word 0x0000001b.word 0x0000ffff.word 0x40000000.word 0x7fffffff.word 0x7ffffffe.word 0xffffffff.word 0xfffffffe.word 0xfffffffd.word 0xffffffe5.word 0x8fff0000.word 0x80000000.word 0x80000001.word 0x00000000.word 0x00000002.word 0x00000004.word 0x00000006.word 0x00000036.word 0x0001fffe.word 0x80000000.word 0xfffffffe.word 0xfffffffc.word 0xfffffffe.word 0xfffffffc.word 0xfffffffa.word 0xffffffca.word 0x1ffe0000.word 0x00000000.word 0x00000002.word 0x00000000.word 0x00000003.word 0x00000006.word 0x00000009.word 0x00000051.word 0x0002fffd.word 0xc0000000.word 0x7ffffffd.word 0x7ffffffa.word 0xfffffffd.word 0xfffffffa.word 0xfffffff7.word 0xffffffaf.word 0xaffd0000.word 0x80000000.word 0x80000003.word 0x00000000.word 0x0000001b.word 0x00000036.word 0x00000051.word 0x000002d9.word 0x001affe5.word 0xc0000000.word 0x7fffffe5.word 0x7fffffca.word 0xffffffe5.word 0xffffffca.word 0xffffffaf.word 0xfffffd27.word 0x2fe50000.word 0x80000000.word 0x8000001b.word 0x00000000.word 0x0000ffff.word 0x0001fffe.word 0x0002fffd.word 0x001affe5.word 0xfffe0001.word 0xc0000000.word 0x7fff0001.word 0x7ffe0002.word 0xffff0001.word 0xfffe0002.word 0xfffd0003.word 0xffe5001b.word 0x70010000.word 0x80000000.word 0x8000ffff.word 0x00000000.word 0x40000000.word 0x80000000.word 0xc0000000.word 0xc0000000.word 0xc0000000.word 0x00000000.word 0xc0000000.word 0x80000000.word 0xc0000000.word 0x80000000.word 0x40000000.word 0x40000000.word 0x00000000.word 0x00000000.word 0x40000000.word 0x00000000.word 0x7fffffff.word 0xfffffffe.word 0x7ffffffd.word 0x7fffffe5.word 0x7fff0001.word 0xc0000000.word 0x00000001.word 0x80000002.word 0x80000001.word 0x00000002.word 0x80000003.word 0x8000001b.word 0x70010000.word 0x80000000.word 0xffffffff.word 0x00000000.word 0x7ffffffe.word 0xfffffffc.word 0x7ffffffa.word 0x7fffffca.word 0x7ffe0002.word 0x80000000.word 0x80000002.word 0x00000004.word 0x80000002.word 0x00000004.word 0x80000006.word 0x80000036.word 0xe0020000.word 0x00000000.word 0x7ffffffe.word 0x00000000.word 0xffffffff.word 0xfffffffe.word 0xfffffffd.word 0xffffffe5.word 0xffff0001.word 0xc0000000.word 0x80000001.word 0x80000002.word 0x00000001.word 0x00000002.word 0x00000003.word 0x0000001b.word 0x70010000.word 0x80000000.word 0x7fffffff.word 0x00000000.word 0xfffffffe.word 0xfffffffc.word 0xfffffffa.word 0xffffffca.word 0xfffe0002.word 0x80000000.word 0x00000002.word 0x00000004.word 0x00000002.word 0x00000004.word 0x00000006.word 0x00000036.word 0xe0020000.word 0x00000000.word 0xfffffffe.word 0x00000000.word 0xfffffffd.word 0xfffffffa.word 0xfffffff7.word 0xffffffaf.word 0xfffd0003.word 0x40000000.word 0x80000003.word 0x80000006.word 0x00000003.word 0x00000006.word 0x00000009.word 0x00000051.word 0x50030000.word 0x80000000.word 0x7ffffffd.word 0x00000000.word 0xffffffe5.word 0xffffffca.word 0xffffffaf.word 0xfffffd27.word 0xffe5001b.word 0x40000000.word 0x8000001b.word 0x80000036.word 0x0000001b.word 0x00000036.word 0x00000051.word 0x000002d9.word 0xd01b0000.word 0x80000000.word 0x7fffffe5.word 0x00000000.word 0x8fff0000.word 0x1ffe0000.word 0xaffd0000.word 0x2fe50000.word 0x70010000.word 0x00000000.word 0x70010000.word 0xe0020000.word 0x70010000.word 0xe0020000.word 0x50030000.word 0xd01b0000.word 0x00000000.word 0x00000000.word 0x8fff0000.word 0x00000000.word 0x80000000.word 0x00000000.word 0x80000000.word 0x80000000.word 0x80000000.word 0x00000000.word 0x80000000.word 0x00000000.word 0x80000000.word 0x00000000.word 0x80000000.word 0x80000000.word 0x00000000.word 0x00000000.word 0x80000000.word 0x00000000.word 0x80000001.word 0x00000002.word 0x80000003.word 0x8000001b.word 0x8000ffff.word 0x40000000.word 0xffffffff.word 0x7ffffffe.word 0x7fffffff.word 0xfffffffe.word 0x7ffffffd.word 0x7fffffe5.word 0x8fff0000.word 0x80000000.word 0x00000001
Go to most recent revision | Compare with Previous | Blame | View Log
