blob: 576ff7178a968c7d545ab1e7247bb3cb361909a5 [file] [log] [blame]
// SPDX-FileCopyrightText: 2020 Efabless Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0
#include "defines.h"
#define STDOUT 0xd0580000
// Code to execute
.section .text
.global _start
_start:
// li x1, 0x5f555555
// csrw 0x7c0, x1
csrw minstret, zero
csrw minstreth, zero
li x4, 4 // Neccessary for terminating code
csrw 0x7f9 ,x4 // Neccessary for terminating code
li s0, 0xf0040000 //dccm base address
//li s5,0xf0040100 //Queue Adress
addi s1,x0,5 //element 1 to push INPUT expected output should be 5 6 7
addi s2,x0,6 //element 2 to push INPUT
addi s3,x0,7 //element 3 to push INPUT
addi s4,x0,3 //size of queue
addi t0,x0,0 //counter initialization
addi t1,x0,1 //
addi t2,x0,2 //
addi t3,x0,3 //
jal ra,PUSH //JUMP to push elements
j LOAD_QUEUE //code will load Queue Elements
PUSH:
addi t0,t0,1 //counter increment
beq t0,t1,PUSH1 //if count == 1 jump to push 1
beq t0,t2,PUSH2 //if count == 2 jump to push 2
beq t0,t3,PUSH3 //if count == 3 jump to push 3
ret
PUSH1:
sw s1,0(s0) // save element 1 on first location of queue
j PUSH // jump to push function
PUSH2:
sw s2,4(s0) // save element 2 on second location of queue
j PUSH
PUSH3:
sw s3,8(s0) // save element 3 on third location of queue
j PUSH
LOAD_QUEUE:
lw x5,0(s0)
lw x6,4(s0)
lw x7,8(s0)
li s6,STDOUT
sw x5,0(s6) //Sending element 1 to tb
addi s6, s6, 4
nop
nop
nop
nop
sw x6,0(s6) //Sending element 2 to tb
addi s6, s6, 4
nop
nop
nop
sw x7,0(s6) //Sending element 3 to tb
nop
nop
nop
// Write 0xff to STDOUT for TB to termiate test.
_finish:
li x3, STDOUT
addi x5, x0, 0xff
sb x5, 0(x3)
beq x0, x0, _finish
.rept 100
nop
.endr