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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [mpy_mpy.s43] - Blame information for rev 74

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

Line No. Rev Author Line
1 67 olivier.gi
/*===========================================================================*/
2
/* Copyright (C) 2001 Authors                                                */
3
/*                                                                           */
4
/* This source file may be used and distributed without restriction provided */
5
/* that this copyright statement is not removed from the file and that any   */
6
/* derivative work contains the original copyright notice and the associated */
7
/* disclaimer.                                                               */
8
/*                                                                           */
9
/* This source file is free software; you can redistribute it and/or modify  */
10
/* it under the terms of the GNU Lesser General Public License as published  */
11
/* by the Free Software Foundation; either version 2.1 of the License, or    */
12
/* (at your option) any later version.                                       */
13
/*                                                                           */
14
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
15
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
16
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
17
/* License for more details.                                                 */
18
/*                                                                           */
19
/* You should have received a copy of the GNU Lesser General Public License  */
20
/* along with this source; if not, write to the Free Software Foundation,    */
21
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
22
/*                                                                           */
23
/*===========================================================================*/
24
/*                          HARDWARE MULTIPLIER                              */
25
/*---------------------------------------------------------------------------*/
26
/* Test the hardware multiplier:                                             */
27
/*                                - MPY  mode.                               */
28
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33
/* $Rev: 18 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2009-08-04 23:44:12 +0200 (Tue, 04 Aug 2009) $          */
36
/*===========================================================================*/
37
 
38
.global main
39
 
40
.set   WDTCTL, 0x0120
41
 
42
.set   MPY,    0x0130
43
.set   MPYS,   0x0132
44
.set   MAC,    0x0134
45
.set   MACS,   0x0136
46
.set   OP2,    0x0138
47
.set   RESLO,  0x013A
48
.set   RESHI,  0x013C
49
.set   SUMEXT, 0x013E
50
 
51
 
52
main:
53
 
54
        /* --------------   UNSIGNED MULTIPLICATION   --------------- */
55
 
56
        ;; Disable watchdog
57
        mov #0x5A80, &WDTCTL
58
 
59
        ;; Initialize variables
60
        mov #0x0000, R15
61
        mov #0x0000, R8
62
        mov #0x0000, R9
63
 
64
mpy_loop:
65
 
66
        ;; Initialize RESLO and RESHI to make sure it is overwritten
67
        mov #0x0000, &RESLO
68
        mov #0xC000, &RESHI
69
 
70
        ;; Perform unsigned R8*R9
71
        mov R8, &MPY
72
        mov R9, &OP2
73
 
74
        ;; Read result
75
        mov &RESLO,  R10
76
        mov &RESHI,  R11
77
        mov &SUMEXT, R12
78
 
79
        ;; Notify verilog checker
80
        add #1, R15
81
 
82
        ;; Update next OP1 (R8)
83
        cmp #0xF0F0, R8
84
        jeq op2_update
85
 
86
        mov #0x00FF, R7
87
        and R8, R7
88
        cmp #0x00F0, R7
89
        jeq op1_hi_update
90
 
91
        add #0x0010, R8
92
        jmp mpy_loop
93
  op1_hi_update:
94
        and #0xff00, R8
95
        add #0x1000, R8
96
        jmp mpy_loop
97
 
98
 
99
        ;; Update next OP2 (R9)
100
  op2_update:
101
        cmp #0xF0F0, R9
102
        jeq end_of_test
103
 
104
        mov #0x0000, R8
105
 
106
        mov #0x00FF, R7
107
        and R9, R7
108
        cmp #0x00F0, R7
109
        jeq op2_hi_update
110
 
111
        add #0x0010, R9
112
        jmp mpy_loop
113
  op2_hi_update:
114
        and #0xff00, R9
115
        add #0x1000, R9
116
        jmp mpy_loop
117
 
118
 
119
 
120
        /* ----------------------         END OF TEST        --------------- */
121
end_of_test:
122
        nop
123
        br #0xffff
124
 
125
 
126
 
127
 
128
        /* ----------------------         INTERRUPT VECTORS  --------------- */
129
 
130
.section .vectors, "a"
131
.word end_of_test  ; Interrupt  0 (lowest priority)    
132
.word end_of_test  ; Interrupt  1                      
133
.word end_of_test  ; Interrupt  2                      
134
.word end_of_test  ; Interrupt  3                      
135
.word end_of_test  ; Interrupt  4                      
136
.word end_of_test  ; Interrupt  5                      
137
.word end_of_test  ; Interrupt  6                      
138
.word end_of_test  ; Interrupt  7                      
139
.word end_of_test  ; Interrupt  8                      
140
.word end_of_test  ; Interrupt  9                      
141
.word end_of_test  ; Interrupt 10                      Watchdog timer
142
.word end_of_test  ; Interrupt 11                      
143
.word end_of_test  ; Interrupt 12                      
144
.word end_of_test  ; Interrupt 13                      
145
.word end_of_test  ; Interrupt 14                      NMI
146
.word main         ; Interrupt 15 (highest priority)   RESET

powered by: WebSVN 2.1.0

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