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

Subversion Repositories zipcpu

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 41 to Rev 40
    Reverse comparison

Rev 41 → Rev 40

/zipcpu/trunk/bench/asm/lfsrleds.S
0,0 → 1,123
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Filename: lfsrleds.S
;
; Project: Zip CPU -- a small, lightweight, RISC CPU soft core
;
; Purpose: A test of whether or not we can generate a pseudorandom
; number stream. This will test the timer peripheral, as well
; as the LED peripheral external to the Zip CPU.
;
; Creator: Dan Gisselquist, Ph.D.
; Gisselquist Tecnology, LLC
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (C) 2015, Gisselquist Technology, LLC
;
; This program is free software (firmware): 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 MERCHANTIBILITY or
; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
; for more details.
;
; License: GPL, v3, as defined and found on www.gnu.org,
; http://www.gnu.org/licenses/gpl.html
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Registers:
; R12 - Peripheral base address, for access to the timer(s)
; R11 - Address of the LED peripheral
; R10 - LFSR Taps (Galois)
; R9 - Currend LFSR (Galois) Fill
; R8 - Curent/next value for the LED register
; R7 - Value to clear/reset the PIC
; R6 - Number of ticks in one second
; R5 - One past top LED bit
; R4 - LED Update time
start:
BRA supervisor_task_start
user_task:
WAIT
BRA user_task
supervisor_task_start:
MOV user_task+PC,uPC
CLR R12 ; Load the address of the peripherals into R12
LDIHI $c000h,R12
LDI $8,R11 ; Load the address of the LEDs into R11
LDI $10000h,R8 ; Clear the value for the LED register
STO R8,(R11) ; Clear the LEDs
LDIHI $8010h,R7 ; Clear the PIC
LDILO $7fffh,R7
STO R7,(R12)
LDI $5f5e1h,R6 ; Set the number of ticks per second
; LDI $5f5h,R6 ; Set the number of ticks per second
LSL $8,R6
MOV R6,R0
LSL $1,R0 ; Wait 2 seconds with the LEDs off
STO R0,$4(R12) ; Use timer A
LDI $-1,R0 ; Set a watchdog timer
STO R0,$1(R12)
RTU ; Execute our wait
 
STO R7,(R12) ; Reset our interrupt controller
LDI $-1,R0 ; (Re)Set a watchdog timer
STO R0,$1(R12)
LDI $1ffffh,R8 ; Turn all the LEDs on
STO R8,(R11) ;
STO R6,$4(R12) ; Wait one second with LEDs on
RTU ; Execute our wait
 
wait_til_leds_off:
STO R7,(R12) ; Reset our interrupt controller
LDI $-1,R0 ; (Re)Set a watchdog timer
STO R0,$1(R12)
MOV R6,R0 ; Set a time, 1/2 second
LSR $1,R0 ; Now ahalf second
STO R0,$4(R12) ; Wait one half second with LEDs on
AND $0ffffh,R8
LSR $1,R8 ; Shift on LEDs to the right
OR $10000h,R8
STO R8,(R11) ;
RTU ; Execute our wait
 
TST 0x0ffff,R8
BNZ wait_til_leds_off ; Repeat until all LEDs are off again
 
; Now, start our pseudorandom LED test
STO R7,(R12) ; Reset our interrupt controller
LDI $-1,R0 ; (Re)Set a watchdog timer
STO R0,$1(R12)
LDI $2408bh,R10 ; Set up our LFSR register
LDI $1,R9
LDI $10000,R5 ; One past the number of LEDs in LED register
MOV R6,R4
LSR $2,R4 ; Update 4x/second
loop:
STO R7,(R12) ; Reset our interrupt controller
STO R4,$4(R12) ; Wait one quarter second
LDI $-1,R0 ; (Re)Set a watchdog timer
STO R0,$1(R12)
AND $0ffffh,R8
MOV R9,R0 ; Shift top bit of LFSR into LED
AND $1,R0
OR.NE $10000h,R8
LSR $1,R8
OR $10000h,R8
LSR $1,R9
TST $1,R0
STO R8,(R11) ; Update the LEDs with our pseudorandom info
XOR.NE R10,R9
RTU ; Wait for next interrupt
 
BRA loop ; Loop until kingdom come
HALT
 

powered by: WebSVN 2.1.0

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