; demo.psm: PicoBlaze demo (8-bit counter) ; Copyright (C) 2009 Brno University of Technology, ; Faculty of Information Technology ; Author(s): Zdenek Vasicek ; ; LICENSE TERMS ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; 1. Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; 2. Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; 3. All advertising materials mentioning features or use of this software ; or firmware must display the following acknowledgement: ; ; This product includes software developed by the University of ; Technology, Faculty of Information Technology, Brno and its ; contributors. ; ; 4. Neither the name of the Company nor the names of its contributors ; may be used to endorse or promote products derived from this ; software without specific prior written permission. ; ; This software or firmware is provided ``as is'', and any express or implied ; warranties, including, but not limited to, the implied warranties of ; merchantability and fitness for a particular purpose are disclaimed. ; In no event shall the company or contributors be liable for any ; direct, indirect, incidental, special, exemplary, or consequential ; damages (including, but not limited to, procurement of substitute ; goods or services; loss of use, data, or profits; or business ; interruption) however caused and on any theory of liability, whether ; in contract, strict liability, or tort (including negligence or ; otherwise) arising in any way out of the use of this software, even ; if advised of the possibility of such damage. ; ; $Id$ ; ; ;------------------------------------------------------------------------------- CONSTANT port_counter, 80 ; Port address CONSTANT delay_loop, 5E ; Loop delay ; ================================================= ; Main routine ; ================================================= start: ; Init the value of s7 LOAD s7, 00 ; Write the s7 value to port next: OUTPUT s7, port_counter CALL delay ADD s7, 01 JUMP next ; ================================================= ; Delay routine (~1 sec.) ; ================================================= ; PicoBlaze requires 2 clocks per instruction ; 1s ~ 25M cycles for fclk = 25 MHz ; 2 + (4 + (4 + 4*256 + 4) * 256 + 4)*delay_loop + 2 = ; = 4 + 264200*delay_loop delay: LOAD s2, 00 rpt3: ADD s2, 01 LOAD s1, 00 rpt2: ADD s1, 01 LOAD s0, 00 rpt1: ADD s0, 01 JUMP NZ,rpt1 COMPARE s1, 00 JUMP NZ,rpt2 COMPARE s2, delay_loop JUMP NZ,rpt3 RETURN