⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 led_ctrl.rmh

📁 和picoblaze完全兼容的mcu ip core
💻 RMH
📖 第 1 页 / 共 2 页
字号:
/* Symbol Table */// ISR = LABEL: 254// ISR_preserve_s0 = CONSTANT: 13// ISR_preserve_s1 = CONSTANT: 14// ISR_preserve_s2 = CONSTANT: 15// LED0 = CONSTANT: 1// LED0_sequence = CONSTANT: 16// LED1 = CONSTANT: 2// LED1_sequence = CONSTANT: 17// LED2 = CONSTANT: 4// LED2_sequence = CONSTANT: 18// LED3 = CONSTANT: 8// LED3_sequence = CONSTANT: 19// LED4 = CONSTANT: 16// LED4_sequence = CONSTANT: 20// LED5 = CONSTANT: 32// LED5_sequence = CONSTANT: 21// LED6 = CONSTANT: 64// LED6_sequence = CONSTANT: 22// LED7 = CONSTANT: 128// LED7_sequence = CONSTANT: 23// LED_port = CONSTANT: 128// LED_read_port = CONSTANT: 0// LED_to_duty = LABEL: 168// PWM_channel0 = CONSTANT: 1// PWM_channel1 = CONSTANT: 2// PWM_channel2 = CONSTANT: 3// PWM_channel3 = CONSTANT: 4// PWM_channel4 = CONSTANT: 5// PWM_channel5 = CONSTANT: 6// PWM_channel6 = CONSTANT: 7// PWM_channel7 = CONSTANT: 8// PWM_duty_counter = CONSTANT: 0// all_LED_fade = LABEL: 228// all_LED_fade_loop = LABEL: 229// authentication_check = LABEL: 182// character_A = CONSTANT: 65// character_F = CONSTANT: 70// character_I = CONSTANT: 73// character_L = CONSTANT: 76// character_P = CONSTANT: 80// character_S = CONSTANT: 83// clear_loop = LABEL: 2// cold_start = LABEL: 0// decay_LEDs = LABEL: 234// delay_s0_loop = LABEL: 24// delay_s1_loop = LABEL: 23// delay_s2_loop = LABEL: 22// enable_int = LABEL: 7// fail_confirm = LABEL: 203// failed_LED_sequence = LABEL: 226// go_down = LABEL: 177// go_down_loop = LABEL: 178// go_up_loop = LABEL: 172// inc_LED0 = LABEL: 36// inc_LED1 = LABEL: 55// inc_LED2 = LABEL: 72// inc_LED3 = LABEL: 89// inc_LED4 = LABEL: 106// inc_LED5 = LABEL: 123// inc_LED6 = LABEL: 145// inc_LED7 = LABEL: 159// link_FIFO_data_present = CONSTANT: 1// link_FIFO_full = CONSTANT: 4// link_FIFO_half_full = CONSTANT: 2// link_FIFO_read_port = CONSTANT: 2// link_FIFO_status_port = CONSTANT: 1// link_fifo_control_port = CONSTANT: 32// link_fifo_reset = CONSTANT: 1// normal_LED1 = LABEL: 49// normal_LED6 = LABEL: 139// normal_LED_sequence = LABEL: 21// read_link_FIFO = LABEL: 249// request_delay = LABEL: 204// s0 = REGISTER: 0// s1 = REGISTER: 1// s2 = REGISTER: 2// s3 = REGISTER: 3// s4 = REGISTER: 4// s5 = REGISTER: 5// s6 = REGISTER: 6// s7 = REGISTER: 7// s8 = REGISTER: 8// s9 = REGISTER: 9// sA = REGISTER: 10// sB = REGISTER: 11// sC = REGISTER: 12// sD = REGISTER: 13// sE = REGISTER: 14// sF = REGISTER: 15// security_interrupt = CONSTANT: 1// security_request_port = CONSTANT: 64// stop_completely = LABEL: 248// test_LED0_start = LABEL: 38// test_LED1_start = LABEL: 57// test_LED2_start = LABEL: 74// test_LED3_start = LABEL: 91// test_LED4_start = LABEL: 108// test_LED5_start = LABEL: 125// test_LED6_start = LABEL: 147// test_LED7_start = LABEL: 161// update_LED0 = LABEL: 41// update_LED1 = LABEL: 63// update_LED2 = LABEL: 80// update_LED3 = LABEL: 97// update_LED4 = LABEL: 114// update_LED5 = LABEL: 131// update_LED6 = LABEL: 150// update_LED7 = LABEL: 164// wait_s1 = LABEL: 235// wait_s2 = LABEL: 236// wait_s3 = LABEL: 237// warm_start = LABEL: 19/* Program Code */// #1: ; KCPSM3 Program - LED control with Pulse Width Modulation (PWM).// #2: ;// #3: ; Design provided for use with the design 'low_cost_design_authentication_for_spartan_3e.vhd'// #4: ; and the Spartan-3E Starter Kit. This design provides the token 'real' application to be// #5: ; protected by design authentication.// #6: ;// #7: ; Ken Chapman - Xilinx Ltd// #8: ;// #9: ; Version v1.00 - 9th November 2006// #10: ;// #11: ; This code automatically sequences the LEDs on the board using PWM to change intensity.// #12: ; It also checks for correct design authentication and will perform a different sequence if// #13: ; the design is not authorised.// #14: ;// #15: ;// #16: ;**************************************************************************************// #17: ; NOTICE:// #18: ;// #19: ; Copyright Xilinx, Inc. 2006.   This code may be contain portions patented by other// #20: ; third parties.  By providing this core as one possible implementation of a standard,// #21: ; Xilinx is making no representation that the provided implementation of this standard// #22: ; is free from any claims of infringement by any third party.  Xilinx expressly// #23: ; disclaims any warranty with respect to the adequacy of the implementation, including// #24: ; but not limited to any warranty or representation that the implementation is free// #25: ; from claims of any third party.  Furthermore, Xilinx is providing this core as a// #26: ; courtesy to you and suggests that you contact all third parties to obtain the// #27: ; necessary rights to use this implementation.// #28: ;// #29: ;// #30: ;**************************************************************************************// #31: ; Port definitions// #32: ;**************************************************************************************// #33: ;// #34: ;// #35: ;// #36: CONSTANT(LED_port,128) ;8 simple LEDs// #37: CONSTANT(LED0,1) ;       LD0 - bit0// #38: CONSTANT(LED1,2) ;       LD1 - bit1// #39: CONSTANT(LED2,4) ;       LD2 - bit2// #40: CONSTANT(LED3,8) ;       LD3 - bit3// #41: CONSTANT(LED4,16) ;       LD4 - bit4// #42: CONSTANT(LED5,32) ;       LD5 - bit5// #43: CONSTANT(LED6,64) ;       LD6 - bit6// #44: CONSTANT(LED7,128) ;       LD7 - bit7// #45: ;// #46: CONSTANT(LED_read_port,0) ;read back of current LED drive values// #47: ;// #48: ;// #49: CONSTANT(security_request_port,64) ;Port to stimulate security KCPSM3 processor// #50: CONSTANT(security_interrupt,1) ; interrupt - bit0// #51: ;// #52: ;// #53: ;A FIFO buffer links the security KCPSM3 processor to the application KCPSM3 processor.// #54: ;  This application processor controls and reads the FIFO.// #55: ;  The security processor writes to the FIFO.// #56: ;// #57: CONSTANT(link_fifo_control_port,32) ;FIFO control// #58: CONSTANT(link_fifo_reset,1) ;     reset - bit0// #59: ;// #60: CONSTANT(link_FIFO_status_port,1) ;FIFO status input// #61: CONSTANT(link_FIFO_data_present,1) ;      half full - bit0// #62: CONSTANT(link_FIFO_half_full,2) ;           full - bit1// #63: CONSTANT(link_FIFO_full,4) ;   data present - bit2// #64: ;// #65: CONSTANT(link_FIFO_read_port,2) ;read FIFO data// #66: ;// #67: ;// #68: ;// #69: ;**************************************************************************************// #70: ; Special Register usage// #71: ;**************************************************************************************// #72: ;// #73: ;// #74: ;// #75: ;// #76: ;**************************************************************************************// #77: ;Scratch Pad Memory Locations// #78: ;**************************************************************************************// #79: ;// #80: CONSTANT(PWM_duty_counter,0) ;Duty Counter 0 to 255 within 1KHz period (1ms)// #81: CONSTANT(PWM_channel0,1) ;PWM settings for each channel// #82: CONSTANT(PWM_channel1,2) ; Channels 0 to 7 = LEDs 0 to 7// #83: CONSTANT(PWM_channel2,3)// #84: CONSTANT(PWM_channel3,4)// #85: CONSTANT(PWM_channel4,5)// #86: CONSTANT(PWM_channel5,6)// #87: CONSTANT(PWM_channel6,7)// #88: CONSTANT(PWM_channel7,8)// #89: CONSTANT(ISR_preserve_s0,13) ;preserve register contents during Interrupt Service Routine// #90: CONSTANT(ISR_preserve_s1,14)// #91: CONSTANT(ISR_preserve_s2,15)// #92: ;// #93: ;// #94: CONSTANT(LED0_sequence,16) ;LED sequence values// #95: CONSTANT(LED1_sequence,17)// #96: CONSTANT(LED2_sequence,18)// #97: CONSTANT(LED3_sequence,19)// #98: CONSTANT(LED4_sequence,20)// #99: CONSTANT(LED5_sequence,21)// #100: CONSTANT(LED6_sequence,22)// #101: CONSTANT(LED7_sequence,23)// #102: ;// #103: ;// #104: ;// #105: ;**************************************************************************************// #106: ;Useful data constants// #107: ;**************************************************************************************// #108: ;// #109: ;// #110: ;// #111: ;// #112: ;// #113: ;// #114: ;// #115: ;**************************************************************************************// #116: ;Initialise the system// #117: ;**************************************************************************************// #118: ;// #119: ; All PWM channels initialise to off (zero).// #120: ; Simple I/O outputs will remain off at all times.// #121: ;// @000 #122: [cold_start]00000 // @000 #122: LOAD(s0,0)00101 // @001 #123: LOAD(s1,PWM_channel0)// @002 #124: [clear_loop]2f010 // @002 #124: STORE(s0,s1)14108 // @003 #125: COMPARE(s1,PWM_channel7)35007 // @004 #126: JUMP(Z,enable_int)18101 // @005 #127: ADD(s1,1)34002 // @006 #128: JUMP(clear_loop)// #129: ;// @007 #130: [enable_int]3c001 // @007 #130: ENABLE(INTERRUPT) ;interrupts used to set PWM frequency// #131: ;// #132: ;// #133: ; Initialise LED pattern sequence// #134: ;00001 // @008 #135: LOAD(s0,1) ;trigger to start wave pattern2e010 // @009 #136: STORE(s0,LED0_sequence)00000 // @00a #137: LOAD(s0,0)2e011 // @00b #138: STORE(s0,LED1_sequence)2e012 // @00c #139: STORE(s0,LED2_sequence)2e013 // @00d #140: STORE(s0,LED3_sequence)2e014 // @00e #141: STORE(s0,LED4_sequence)2e015 // @00f #142: STORE(s0,LED5_sequence)2e016 // @010 #143: STORE(s0,LED6_sequence)2e017 // @011 #144: STORE(s0,LED7_sequence)// #145: ;// #146: ;// #147: ; Reset authentication check counter// #148: ;00f00 // @012 #149: LOAD(sF,0)// #150: ;// #151: ;// #152: ;**************************************************************************************// #153: ; Main program// #154: ;**************************************************************************************// #155: ;// #156: ; Provides a pattern of interest on the LEDs :-)// #157: ;// #158: ; Each LED increases intensity in 8 steps and then decreases intensity in 8 steps until it is off.// #159: ; The middle LEDs (LD2 to LD5) each start to turn on when either neighbour is turned half on and increasing// #160: ; to provide the effect of a passing a 'wave' of light passing from side to side. The pair of LEDs at each// #161: ; (LD0, Ld1 and LD6, LD7) are required to reflect the 'wave' so that the pattern continues.// #162: ;// #163: ; I'm sure this code cold be written in more elegant way, but I leave that as an exercise to you :-)// #164: ;// #165: ;// #166: ; Using a simple software counter (implemented by register sF) the design occasionally requests an// #167: ; authorisation message from the authentication processor. If it receives a PASS message it continues// #168: ; normally but if it receives a FAIL message the LED pattern is changed.// #169: ;// #170: ;// #171: ;// @013 #172: [warm_start]18f01 // @013 #172: ADD(sF,1) ;authentication check timer358b6 // @014 #173: JUMP(C,authentication_check) ;Check made approximately every 8 seconds.// #174: ;// @015 #175: [normal_LED_sequence]00203 // @015 #175: LOAD(s2,3) ;simple delay loop (delay will be increased by ISR processing)// @016 #176: [delay_s2_loop]001ff // @016 #176: LOAD(s1,FF)// @017 #177: [delay_s1_loop]000ff // @017 #177: LOAD(s0,FF)// @018 #178: [delay_s0_loop]1c001 // @018 #178: SUB(s0,1)35c18 // @019 #179: JUMP(NC,delay_s0_loop)1c101 // @01a #180: SUB(s1,1)35c17 // @01b #181: JUMP(NC,delay_s1_loop)1c201 // @01c #182: SUB(s2,1)35c16 // @01d #183: JUMP(NC,delay_s2_loop)// #184: ;// #185: ;Pattern generation// #186: ;06010 // @01e #187: FETCH(s0,LED0_sequence) ;read sequence for LED014000 // @01f #188: COMPARE(s0,0)35026 // @020 #189: JUMP(Z,test_LED0_start)1c020 // @021 #190: SUB(s0,32) ;Count longer to ensure end stops then reset count if maximum35029 // @022 #191: JUMP(Z,update_LED0)18020 // @023 #192: ADD(s0,32)// @024 #193: [inc_LED0]18001 // @024 #193: ADD(s0,1) ;increment counter34029 // @025 #194: JUMP(update_LED0)// @026 #195: [test_LED0_start]06111 // @026 #195: FETCH(s1,LED1_sequence) ;start LED0 if LED1 = 414104 // @027 #196: COMPARE(s1,4)35024 // @028 #197: JUMP(Z,inc_LED0)// @029 #198: [update_LED0]2e010 // @029 #198: STORE(s0,LED0_sequence)300a8 // @02a #199: CALL(LED_to_duty)2e101 // @02b #200: STORE(s1,PWM_channel0)// #201: ;06110 // @02c #202: FETCH(s1,LED0_sequence) ; refresh LED1 if LED0 = 11 (0B hex) to reflect wave1410b // @02d #203: COMPARE(s1,11)35431 // @02e #204: JUMP(NZ,normal_LED1)00004 // @02f #205: LOAD(s0,4)3403f // @030 #206: JUMP(update_LED1)// @031 #207: [normal_LED1]06011 // @031 #207: FETCH(s0,LED1_sequence) ;read sequence for LED114000 // @032 #208: COMPARE(s0,0)35039 // @033 #209: JUMP(Z,test_LED1_start)1c010 // @034 #210: SUB(s0,16) ;reset count if maximum3503f // @035 #211: JUMP(Z,update_LED1)18010 // @036 #212: ADD(s0,16)// @037 #213: [inc_LED1]18001 // @037 #213: ADD(s0,1) ;increment counter3403f // @038 #214: JUMP(update_LED1)// @039 #215: [test_LED1_start]06110 // @039 #215: FETCH(s1,LED0_sequence) ;start LED1 if LED0 = 11 (0B hex) to reflect wave1410b // @03a #216: COMPARE(s1,11)35037 // @03b #217: JUMP(Z,inc_LED1)06112 // @03c #218: FETCH(s1,LED2_sequence) ;start LED1 if LED2 = 414104 // @03d #219: COMPARE(s1,4)35037 // @03e #220: JUMP(Z,inc_LED1)// @03f #221: [update_LED1]2e011 // @03f #221: STORE(s0,LED1_sequence)300a8 // @040 #222: CALL(LED_to_duty)2e102 // @041 #223: STORE(s1,PWM_channel1)// #224: ;06012 // @042 #225: FETCH(s0,LED2_sequence) ;read sequence for LED214000 // @043 #226: COMPARE(s0,0)3504a // @044 #227: JUMP(Z,test_LED2_start)1c010 // @045 #228: SUB(s0,16) ;reset count if maximum35050 // @046 #229: JUMP(Z,update_LED2)18010 // @047 #230: ADD(s0,16)// @048 #231: [inc_LED2]18001 // @048 #231: ADD(s0,1) ;increment counter34050 // @049 #232: JUMP(update_LED2)// @04a #233: [test_LED2_start]06111 // @04a #233: FETCH(s1,LED1_sequence) ;start LED2 if LED1 = 414104 // @04b #234: COMPARE(s1,4)35048 // @04c #235: JUMP(Z,inc_LED2)06113 // @04d #236: FETCH(s1,LED3_sequence) ;start LED2 if LED3 = 414104 // @04e #237: COMPARE(s1,4)35048 // @04f #238: JUMP(Z,inc_LED2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -