123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- # MIPS DSP ASE simulator testsuite utility functions.
- # Copyright (C) 2005-2022 Free Software Foundation, Inc.
- # Contributed by MIPS Technologies, Inc. Written by Chao-ying Fu.
- #
- # This file is part of the GNU simulators.
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program 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 General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>. */
- # $4, $5, $6, $7, $ac0, $ac1, $ac2, $ac3 are used as temps by the macros
- # defined here.
- # If a != b, jump to _fail.
- # Otherwise, fall through.
- .macro dsp_assert a, b
- beq \a, \b, 1f
- nop
- j _fail
- nop
- 1:
- .endm
- # Set dsp control register <= crin
- # Check if d == (inst ?, s, t)
- # Check if crout == dsp control register
- .macro dspck_dstio inst, d, s, t, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \s
- li $5, \t
- \inst $6, $4, $5
- li $7, \d
- dsp_assert $6, $7
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # (inst s, t)
- # Check if crout == dsp control register
- .macro dspck_stio inst, s, t, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \s
- li $5, \t
- \inst $4, $5
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Check if d == (inst ?, s, t)
- .macro dspck_dsti inst, d, s, t, crin
- li $4, \crin
- wrdsp $4
- li $4, \s
- li $5, \t
- \inst $6, $4, $5
- li $7, \d
- dsp_assert $6, $7
- .endm
- # Set dsp control register <= crin
- # Check if tou == (inst tin, s)
- .macro dspck_tsi inst, tou, tin, s, crin
- li $4, \crin
- wrdsp $4
- li $4, \s
- li $5, \tin
- \inst $5, $4
- li $6, \tou
- dsp_assert $5, $6
- .endm
- # Set dsp control register <= crin
- # Check if d == (inst ?, imm)
- # Check if crout == dsp control register
- .macro dspck_dIio inst, d, imm, crin, crout
- li $4, \crin
- wrdsp $4
- \inst $5, \imm
- li $6, \d
- dsp_assert $5, $6
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Check if d == (inst ?, s)
- # Check if crout == dsp control register
- .macro dspck_dsio inst, d, s, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \s
- \inst $6, $4
- li $7, \d
- dsp_assert $6, $7
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Check if d == (inst ?, t, sa)
- # Check if crout == dsp control register
- .macro dspck_dtsaio inst, d, t, sa, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \t
- \inst $6, $4, \sa
- li $7, \d
- dsp_assert $6, $7
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Check if d == (inst ?, t, sa)
- .macro dspck_dtsai inst, d, t, sa, crin
- li $4, \crin
- wrdsp $4
- li $4, \t
- \inst $6, $4, \sa
- li $7, \d
- dsp_assert $6, $7
- .endm
- # Set dsp control register <= crin
- # Set $ac3 <= {hiin, loin}
- # (inst $ac3, s, t)
- # Check if {hiou, loou} == $ac3
- # Check if (crout & 0x80000) == (dsp control register & 0x80000)
- .macro dspck_astio inst, hiin, loin, hiou, loou, s, t, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hiin
- mthi $4, $ac3
- li $4, \loin
- mtlo $4, $ac3
- li $4, \s
- li $5, \t
- \inst $ac3, $4, $5
- li $4, \hiou
- mfhi $5, $ac3
- dsp_assert $4, $5
- li $4, \loou
- mflo $5, $ac3
- dsp_assert $4, $5
- li $4, \crout
- and $4, $4, 0x80000
- rddsp $5
- and $5, $5, 0x80000
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Set $ac1 <= {hi, lo}
- # Check if t == (inst ? $ac1, sa)
- # Check if crout == dsp control register
- .macro dspck_atsaio inst, hi, lo, t, sa, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hi
- mthi $4, $ac1
- li $4, \lo
- mtlo $4, $ac1
- \inst $5, $ac1, \sa
- li $6, \t
- dsp_assert $5, $6
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Set acc <= {hiin, loin}
- # (inst acc, s, t)
- # Check if {hiou, loou} == acc
- # Check if (crout & 0x80000) == (dsp control register & 0x80000)
- .macro dspckacc_astio inst, acc, hiin, loin, hiou, loou, s, t, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hiin
- mthi $4, \acc
- li $4, \loin
- mtlo $4, \acc
- li $4, \s
- li $5, \t
- \inst \acc, $4, $5
- li $4, \hiou
- mfhi $5, \acc
- dsp_assert $4, $5
- li $4, \loou
- mflo $5, \acc
- dsp_assert $4, $5
- li $4, \crout
- and $4, $4, 0x80000
- rddsp $5
- and $5, $5, 0x80000
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Set $ac1 <= {hi, lo}
- # Check if t == (inst ? $ac1, s)
- # Check if crout == dsp control register
- .macro dspck_atsio inst, hi, lo, t, s, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hi
- mthi $4, $ac1
- li $4, \lo
- mtlo $4, $ac1
- li $4, \s
- \inst $5, $ac1, $4
- li $6, \t
- dsp_assert $5, $6
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= (crin & crinmask)
- # Set $ac2 <= {hi, lo}
- # Check if t == (inst ? $ac2, size)
- # Check if (crout & croutmask) == (dsp control register & croutmask)
- .macro dspck_tasiimom inst, hi, lo, t, size, crin, crinmask, crout, croutmask
- li $4, \crin
- and $4, \crinmask
- wrdsp $4
- li $4, \hi
- mthi $4, $ac2
- li $4, \lo
- mtlo $4, $ac2
- \inst $5, $ac2, \size
- li $6, \t
- dsp_assert $5, $6
- li $4, \crout
- and $4, \croutmask
- rddsp $5
- and $5, \croutmask
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= (crin & crinmask)
- # Set $ac2 <= {hi, lo}
- # Check if t == (inst ? $ac2, size)
- .macro dspck_tasiim inst, hi, lo, t, size, crin, crinmask
- li $4, \crin
- and $4, \crinmask
- wrdsp $4
- li $4, \hi
- mthi $4, $ac2
- li $4, \lo
- mtlo $4, $ac2
- \inst $5, $ac2, \size
- li $6, \t
- dsp_assert $5, $6
- .endm
- # Set dsp control register <= (crin & crinmask)
- # Set $ac2 <= {hi, lo}
- # Check if t == (inst ? $ac2, s)
- # Check if (crout & croutmask) == (dsp control register & croutmask)
- .macro dspck_tasimom inst, hi, lo, t, s, crin, crinmask, crout, croutmask
- li $4, \crin
- and $4, \crinmask
- wrdsp $4
- li $4, \hi
- mthi $4, $ac2
- li $4, \lo
- mtlo $4, $ac2
- li $4, \s
- \inst $5, $ac2, $4
- li $6, \t
- dsp_assert $5, $6
- li $4, \crout
- and $4, \croutmask
- rddsp $5
- and $5, \croutmask
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= (crin & crinmask)
- # Set $ac2 <= {hi, lo}
- # Check if t == (inst ? $ac2, s)
- .macro dspck_tasim inst, hi, lo, t, s, crin, crinmask
- li $4, \crin
- and $4, \crinmask
- wrdsp $4
- li $4, \hi
- mthi $4, $ac2
- li $4, \lo
- mtlo $4, $ac2
- li $4, \s
- \inst $5, $ac2, $4
- li $6, \t
- dsp_assert $5, $6
- .endm
- # Set dsp control register <= crin
- # Set $ac0 <= {hi, lo}
- # (inst $ac0, shift)
- # Check if $ac0 == {hio, loo}
- # Check if crout == dsp control register
- .macro dspck_asaio inst, hi, lo, hio, loo, shift, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hi
- mthi $4, $ac0
- li $4, \lo
- mtlo $4, $ac0
- \inst $ac0, \shift
- mfhi $5, $ac0
- li $6, \hio
- dsp_assert $5, $6
- mflo $5, $ac0
- li $6, \loo
- dsp_assert $5, $6
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Set $ac0 <= {hi, lo}
- # (inst $ac0, s)
- # Check if $ac0 == {hio, loo}
- # Check if crout == dsp control register
- .macro dspck_asio inst, hi, lo, hio, loo, s, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hi
- mthi $4, $ac0
- li $4, \lo
- mtlo $4, $ac0
- li $4, \s
- \inst $ac0, $4
- mfhi $5, $ac0
- li $6, \hio
- dsp_assert $5, $6
- mflo $5, $ac0
- li $6, \loo
- dsp_assert $5, $6
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # Set $ac3 <= {hi, lo}
- # Check if s == (inst ? $ac3)
- # Check if $ac3 == {hio, loo}
- # Check if crout == dsp control register
- .macro dspck_saio inst, hi, lo, hio, loo, s, crin, crout
- li $4, \crin
- wrdsp $4
- li $4, \hi
- mthi $4, $ac3
- li $4, \lo
- mtlo $4, $ac3
- li $5, \s
- \inst $5, $ac3
- mfhi $5, $ac3
- li $6, \hio
- dsp_assert $5, $6
- mflo $5, $ac3
- li $6, \loo
- dsp_assert $5, $6
- li $4, \crout
- rddsp $5
- dsp_assert $4, $5
- .endm
- # Set dsp control register <= crin
- # (wrdsp s, m)
- # Check if crout == dsp control register
- .macro dspck_wrdsp s, m, crin, crout
- li $4, \crin
- wrdsp $4
- li $5, \s
- wrdsp $5, \m
- li $6, \crout
- rddsp $7
- dsp_assert $6, $7
- .endm
- # Set dsp control register <= crin
- # Check if d == (rddsp ?, m)
- .macro dspck_rddsp d, m, crin
- li $4, \crin
- wrdsp $4
- rddsp $5, \m
- li $6, \d
- dsp_assert $5, $6
- .endm
- # Check if d == (inst i(b))
- .macro dspck_load inst, d, i, b
- li $4, \i
- la $5, \b
- \inst $6, $4($5)
- li $7, \d
- dsp_assert $6, $7
- .endm
- # Set dsp control register <= crin
- # Check if bposge32 is taken or not as expected in r
- # (1 => taken, 0 => not taken)
- .macro dspck_bposge32 crin, r
- li $4, \crin
- wrdsp $4
- li $5, 1
- bposge32 1f
- nop
- li $5, 0
- 1:
- li $6, \r
- dsp_assert $5, $6
- .endm
- # Check if tou == (inst tin, s)
- .macro dspck_tsimm inst, tou, tin, s, sa
- li $4, \s
- li $5, \tin
- \inst $5, $4, \sa
- li $6, \tou
- dsp_assert $5, $6
- .endm
|