URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-mac.S] - Rev 425
Go to most recent revision | Compare with Previous | Blame | View Log
/*OR1200 MAC testVery basic, testing simple instructions and multiplication,accumulation valuesJulius Baxter, julius.baxter@orsoc.se*/////////////////////////////////////////////////////////////////////////// //////// 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 "spr-defs.h"#include "board.h"#include "or1200-defines.h"// Check MAC unit is enabled before trying to run this test#ifndef OR1200_MAC_IMPLEMENTED# error# error No MAC unit detected. This test requires hardware MAC support# error#endif/* =================================================== [ exceptions ] === */.section .vectors, "ax"/* ---[ 0x100: RESET exception ]----------------------------------------- */.org 0x100l.movhi r0, 0/* Clear status register */l.ori r1, r0, SPR_SR_SMl.mtspr r0, r1, SPR_SR/* Clear timer */l.mtspr r0, r0, SPR_TTMR/* Jump to program initialisation code */.global _startl.movhi r4, hi(_start)l.ori r4, r4, lo(_start)l.jr r4l.nop/* =================================================== [ text ] === */.section .text/* =================================================== [ start ] === */.global _start_start:/* Instruction cache enable *//* Check if IC present and skip enabling otherwise */l.mfspr r24,r0,SPR_UPRl.andi r26,r24,SPR_UPR_ICPl.sfeq r26,r0l.bf .L8l.nop/* Disable IC */l.mfspr r6,r0,SPR_SRl.addi r5,r0,-1l.xori r5,r5,SPR_SR_ICEl.and r5,r6,r5l.mtspr r0,r5,SPR_SR/* Establish cache block sizeIf BS=0, 16;If BS=1, 32;r14 contain block size*/l.mfspr r24,r0,SPR_ICCFGRl.andi r26,r24,SPR_ICCFGR_CBSl.srli r28,r26,7l.ori r30,r0,16l.sll r14,r30,r28/* Establish number of cache setsr16 contains number of cache setsr28 contains log(# of cache sets)*/l.andi r26,r24,SPR_ICCFGR_NCSl.srli r28,r26,3l.ori r30,r0,1l.sll r16,r30,r28/* Invalidate IC */l.addi r6,r0,0l.sll r5,r14,r28.L7:l.mtspr r0,r6,SPR_ICBIRl.sfne r6,r5l.bf .L7l.add r6,r6,r14/* Enable IC */l.mfspr r6,r0,SPR_SRl.ori r6,r6,SPR_SR_ICEl.mtspr r0,r6,SPR_SRl.nopl.nopl.nopl.nopl.nopl.nopl.nopl.nop.L8:/* Data cache enable *//* Check if DC present and skip enabling otherwise */l.mfspr r24,r0,SPR_UPRl.andi r26,r24,SPR_UPR_DCPl.sfeq r26,r0l.bf .L10l.nop/* Disable DC */l.mfspr r6,r0,SPR_SRl.addi r5,r0,-1l.xori r5,r5,SPR_SR_DCEl.and r5,r6,r5l.mtspr r0,r5,SPR_SR/* Establish cache block sizeIf BS=0, 16;If BS=1, 32;r14 contain block size*/l.mfspr r24,r0,SPR_DCCFGRl.andi r26,r24,SPR_DCCFGR_CBSl.srli r28,r26,7l.ori r30,r0,16l.sll r14,r30,r28/* Establish number of cache setsr16 contains number of cache setsr28 contains log(# of cache sets)*/l.andi r26,r24,SPR_DCCFGR_NCSl.srli r28,r26,3l.ori r30,r0,1l.sll r16,r30,r28/* Invalidate DC */l.addi r6,r0,0l.sll r5,r14,r28.L9:l.mtspr r0,r6,SPR_DCBIRl.sfne r6,r5l.bf .L9l.add r6,r6,r14/* Enable DC */l.mfspr r6,r0,SPR_SRl.ori r6,r6,SPR_SR_DCEl.mtspr r0,r6,SPR_SR.L10:// Kick off testl.jal _mainl.nop/* =================================================== [ main ] === */.global _main_main:// First clear MACl.macrc r3l.nop 0x2// Load a constant into r3l.ori r4, r0, 0x3 // r4 = 3l.ori r5, r0, 0x2 // r5 = 2l.ori r6, r0, 0 // r6 = 0l.ori r7, r0, 0x7 // r7 = 7// Test back-to-back l.mac operationsl.mac r4, r5 // Multiply: MAC reg 6l.mac r4, r7 // Multiply: MAC reg 27l.mac r5, r5 // Multiply: MAC reg 31l.mac r4, r0 // Multiply: MAC reg 31l.mac r4, r5 // Multiply: MAC reg 37 (0x25)l.macrc r3l.nop 0x2l.sfeqi r3, 0x25l.bnf faill.ori r3, r0, 0x1 // Test 1 failed// Test back-to-back l.maci operationsl.maci r4, 5 // Multiply: MAC reg 15l.maci r4, 8 // Multiply: MAC reg 39l.maci r5, 1 // Multiply: MAC reg 41l.maci r4, 0 // Multiply: MAC reg 41l.maci r4, 3 // Multiply: MAC reg 50 (0x32)l.nopl.nopl.macrc r3l.nop 0x2l.sfeqi r3, 0x32l.bnf faill.ori r3, r0, 0x2 // Test 2 failed#define NUM_MAC_LOOPS 8macloop:l.mac r4, r5 // Multiply: MAC reg 6l.addi r6, r6, 1 // Increment counterl.sfltui r6, NUM_MAC_LOOPSl.bf macloopl.nopl.macrc r3l.nop 0x2l.sfeqi r3, (NUM_MAC_LOOPS*6)l.bnf faill.ori r3, r0, 0x3 // Test 3 failedl.movhi r3, 0x8000l.ori r3, r3, 0x000dl.nop 0x2l.ori r3, r0, 0l.nop 0x1fail:l.nop 0x1
Go to most recent revision | Compare with Previous | Blame | View Log
