fg_ctrl.rmh

来自「和picoblaze完全兼容的mcu ip core」· RMH 代码 · 共 1,476 行 · 第 1/5 页

RMH
1,476 行
字号
// #911: ;Registers used s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,sA,sB// #912: ;// @0e5 #913: [BCD_to_integer]00209 // @0e5 #913: LOAD(s2,9) ;9 digits to convert00000 // @0e6 #914: LOAD(s0,0) ;clear frequency value ready to accumulate result2e00c // @0e7 #915: STORE(s0,frequency0)2e00d // @0e8 #916: STORE(s0,frequency1)2e00e // @0e9 #917: STORE(s0,frequency2)2e00f // @0ea #918: STORE(s0,frequency3)00b00 // @0eb #919: LOAD(sB,0) ;initialise BCD digit weighting [sB,sA,s9,s8] to 100a00 // @0ec #920: LOAD(sA,0)00900 // @0ed #921: LOAD(s9,0)00801 // @0ee #922: LOAD(s8,1)00303 // @0ef #923: LOAD(s3,BCD_digit0) ;locate LS-digit// @0f0 #924: [next_BCD_to_int_digit]07130 // @0f0 #924: FETCH(s1,s3)// @0f1 #925: [BCD_digit_convert]14100 // @0f1 #925: COMPARE(s1,0) ;test for zero35101 // @0f2 #926: JUMP(Z,next_digit_value)0600c // @0f3 #927: FETCH(s0,frequency0) ;add 32-bit digit weighting to memory value19080 // @0f4 #928: ADD(s0,s8)2e00c // @0f5 #929: STORE(s0,frequency0)0600d // @0f6 #930: FETCH(s0,frequency1)1b090 // @0f7 #931: ADDCY(s0,s9)2e00d // @0f8 #932: STORE(s0,frequency1)0600e // @0f9 #933: FETCH(s0,frequency2)1b0a0 // @0fa #934: ADDCY(s0,sA)2e00e // @0fb #935: STORE(s0,frequency2)0600f // @0fc #936: FETCH(s0,frequency3)1b0b0 // @0fd #937: ADDCY(s0,sB)2e00f // @0fe #938: STORE(s0,frequency3)1c101 // @0ff #939: SUB(s1,1) ;decrement digit value340f1 // @100 #940: JUMP(BCD_digit_convert)// #941: ;Increase weighting by 10x// @101 #942: [next_digit_value]017b0 // @101 #942: LOAD(s7,sB) ;copy existing weighting016a0 // @102 #943: LOAD(s6,sA)01590 // @103 #944: LOAD(s5,s9)01480 // @104 #945: LOAD(s4,s8)20806 // @105 #946: SL0(s8) ;multiply weight by 4x (shift left 2 places)20900 // @106 #947: SLA(s9)20a00 // @107 #948: SLA(sA)20b00 // @108 #949: SLA(sB)20806 // @109 #950: SL0(s8)20900 // @10a #951: SLA(s9)20a00 // @10b #952: SLA(sA)20b00 // @10c #953: SLA(sB)19840 // @10d #954: ADD(s8,s4) ;add previous weight to form 5x multiplication1b950 // @10e #955: ADDCY(s9,s5)1ba60 // @10f #956: ADDCY(sA,s6)1bb70 // @110 #957: ADDCY(sB,s7)20806 // @111 #958: SL0(s8) ;multiply weight by 2x (shift left 1 places)20900 // @112 #959: SLA(s9)20a00 // @113 #960: SLA(sA)20b00 // @114 #961: SLA(sB) ;weight value is now 10x previous value18301 // @115 #962: ADD(s3,1) ;move to next digit for conversion1c201 // @116 #963: SUB(s2,1)354f0 // @117 #964: JUMP(NZ,next_BCD_to_int_digit)2a000 // @118 #965: RETURN// #966: ;// #967: ;// #968: ;**************************************************************************************// #969: ; 32-bit x 48-bit multiply to scale the integer frequency// #970: ;**************************************************************************************// #971: ;// #972: ;Multiply the 32-bit frequency binary integer by the 48-bit scaling factor// #973: ;to form a full precision 80-bit product.// #974: ;// #975: ;The frequency binary integer is stored in scratch pad memory using ascending// #976: ;locations frequency0 to frequency3// #977: ;// #978: ;The product will be stored in scratch pad memory using ascending// #979: ;locations product0 to product9// #980: ;// #981: ;The scaling factor is provided directly as constants// #982: ; scale_constant0 to scale_constant5// #983: ;// #984: ;The multiplication is performed as a 32-bit 'shift and add' process in which the// #985: ;integer frequency is examined LSB first using a register set [sB,sA,s9,s8] and// #986: ;a scaling accumulator is formed directly in the 'product' memory locations.// #987: ;// #988: ;The process requires up to 1772 instructions which is 3544 clock cycle or// #989: ;approximately 71us at 50MHz clock rate.// #990: ;// #991: ;Registers used s0,s1,s8,s9,sA,sB (s1,s8,s9,sA,sB clear on return)// #992: ;// @119 #993: [scale_frequency]00000 // @119 #993: LOAD(s0,0) ;clear accumulator section of 'product'2e01b // @11a #994: STORE(s0,product9)2e01a // @11b #995: STORE(s0,product8)2e019 // @11c #996: STORE(s0,product7)2e018 // @11d #997: STORE(s0,product6)2e017 // @11e #998: STORE(s0,product5)2e016 // @11f #999: STORE(s0,product4)06b0f // @120 #1000: FETCH(sB,frequency3) ;read frequency integer value06a0e // @121 #1001: FETCH(sA,frequency2)0690d // @122 #1002: FETCH(s9,frequency1)0680c // @123 #1003: FETCH(s8,frequency0)00120 // @124 #1004: LOAD(s1,32) ;32-bit multiply// @125 #1005: [scale_mult_bit]20b0e // @125 #1005: SR0(sB) ;shift right frequency integer20a08 // @126 #1006: SRA(sA)20908 // @127 #1007: SRA(s9)20808 // @128 #1008: SRA(s8)35d3c // @129 #1009: JUMP(NC,product_shift) ;no add if bit is zero (note carry is zero)06016 // @12a #1010: FETCH(s0,product4) ;addition of scaling factor to most significant bits of product18062 // @12b #1011: ADD(s0,scale_constant0)2e016 // @12c #1012: STORE(s0,product4)06017 // @12d #1013: FETCH(s0,product5)1a084 // @12e #1014: ADDCY(s0,scale_constant1)2e017 // @12f #1015: STORE(s0,product5)06018 // @130 #1016: FETCH(s0,product6)1a011 // @131 #1017: ADDCY(s0,scale_constant2)2e018 // @132 #1018: STORE(s0,product6)06019 // @133 #1019: FETCH(s0,product7)1a077 // @134 #1020: ADDCY(s0,scale_constant3)2e019 // @135 #1021: STORE(s0,product7)0601a // @136 #1022: FETCH(s0,product8)1a0cc // @137 #1023: ADDCY(s0,scale_constant4)2e01a // @138 #1024: STORE(s0,product8)0601b // @139 #1025: FETCH(s0,product9)1a0ab // @13a #1026: ADDCY(s0,scale_constant5)2e01b // @13b #1027: STORE(s0,product9) ;carry holds any overflow of addition// @13c #1028: [product_shift]0601b // @13c #1028: FETCH(s0,product9) ;Divide product by 2 (shift right by 1)20008 // @13d #1029: SRA(s0) ;overflow of addition included in shift2e01b // @13e #1030: STORE(s0,product9)0601a // @13f #1031: FETCH(s0,product8)20008 // @140 #1032: SRA(s0)2e01a // @141 #1033: STORE(s0,product8)06019 // @142 #1034: FETCH(s0,product7)20008 // @143 #1035: SRA(s0)2e019 // @144 #1036: STORE(s0,product7)06018 // @145 #1037: FETCH(s0,product6)20008 // @146 #1038: SRA(s0)2e018 // @147 #1039: STORE(s0,product6)06017 // @148 #1040: FETCH(s0,product5)20008 // @149 #1041: SRA(s0)2e017 // @14a #1042: STORE(s0,product5)06016 // @14b #1043: FETCH(s0,product4)20008 // @14c #1044: SRA(s0)2e016 // @14d #1045: STORE(s0,product4)06015 // @14e #1046: FETCH(s0,product3)20008 // @14f #1047: SRA(s0)2e015 // @150 #1048: STORE(s0,product3)06014 // @151 #1049: FETCH(s0,product2)20008 // @152 #1050: SRA(s0)2e014 // @153 #1051: STORE(s0,product2)06013 // @154 #1052: FETCH(s0,product1)20008 // @155 #1053: SRA(s0)2e013 // @156 #1054: STORE(s0,product1)06012 // @157 #1055: FETCH(s0,product0)20008 // @158 #1056: SRA(s0)2e012 // @159 #1057: STORE(s0,product0)1c101 // @15a #1058: SUB(s1,1) ;move to next bit35525 // @15b #1059: JUMP(NZ,scale_mult_bit)2a000 // @15c #1060: RETURN// #1061: ;// #1062: ;**************************************************************************************// #1063: ; Display DDS control information on the lower line of the LCD display.// #1064: ;**************************************************************************************// #1065: ;// #1066: ;Display the 32-bit DDS control word and 8-bit DDS scaling word.// #1067: ;// @15d #1068: [display_DDS_data]00520 // @15d #1068: LOAD(s5,32) ;Line 2 position 03022b // @15e #1069: CALL(LCD_cursor)0054e // @15f #1070: LOAD(s5,character_N)301eb // @160 #1071: CALL(LCD_write_data)0053d // @161 #1072: LOAD(s5,character_equals)301eb // @162 #1073: CALL(LCD_write_data)0071f // @163 #1074: LOAD(s7,DDS_control3) ;pointer to most significant byte in memory30184 // @164 #1075: CALL(display_hex_32_bit)300e2 // @165 #1076: CALL(display_space)00544 // @166 #1077: LOAD(s5,character_D)301eb // @167 #1078: CALL(LCD_write_data)0053d // @168 #1079: LOAD(s5,character_equals)301eb // @169 #1080: CALL(LCD_write_data)06020 // @16a #1081: FETCH(s0,DDS_scaling)3017e // @16b #1082: CALL(display_hex_byte)2a000 // @16c #1083: RETURN// #1084: ;// #1085: ;**************************************************************************************// #1086: ; Routines to display hexadecimal values on LCD display// #1087: ;**************************************************************************************// #1088: ;// #1089: ;// #1090: ; Convert hexadecimal value provided in register s0 into ASCII characters// #1091: ;// #1092: ; The value provided must can be any value in the range 00 to FF and will be converted into// #1093: ; two ASCII characters.// #1094: ;     The upper nibble will be represented by an ASCII character returned in register s3.// #1095: ;     The lower nibble will be represented by an ASCII character returned in register s2.// #1096: ;// #1097: ; The ASCII representations of '0' to '9' are 30 to 39 hexadecimal which is simply 30 hex// #1098: ; added to the actual decimal value. The ASCII representations of 'A' to 'F' are 41 to 46// #1099: ; hexadecimal requiring a further addition of 07 to the 30 already added.// #1100: ;// #1101: ; Registers used s0, s2 and s3.// #1102: ;// @16d #1103: [hex_byte_to_ASCII]01200 // @16d #1103: LOAD(s2,s0) ;remember value supplied2000e // @16e #1104: SR0(s0) ;isolate upper nibble2000e // @16f #1105: SR0(s0)2000e // @170 #1106: SR0(s0)2000e // @171 #1107: SR0(s0)30179 // @172 #1108: CALL(hex_to_ASCII) ;convert01300 // @173 #1109: LOAD(s3,s0) ;upper nibble value in s301020 // @174 #1110: LOAD(s0,s2) ;restore complete value0a00f // @175 #1111: AND(s0,15) ;isolate lower nibble30179 // @176 #1112: CALL(hex_to_ASCII) ;convert01200 // @177 #1113: LOAD(s2,s0) ;lower nibble value in s22a000 // @178 #1114: RETURN// #1115: ;// #1116: ; Convert hexadecimal value provided in register s0 into ASCII character// #1117: ;// #1118: ;Register used s0// #1119: ;// @179 #1120: [hex_to_ASCII]1c00a // @179 #1120: SUB(s0,10) ;test if value is in range 0 to 93597c // @17a #1121: JUMP(C,number_char)18007 // @17b #1122: ADD(s0,7) ;ASCII char A to F in range 41 to 46// @17c #1123: [number_char]1803a // @17c #1123: ADD(s0,58) ;ASCII char 0 to 9 in range 30 to 402a000 // @17d #1124: RETURN// #1125: ;// #1126: ;// #1127: ; Display the two character HEX value of the register contents 's0' on the LCD// #1128: ; at the current cursor position.// #1129: ;// #1130: ; Registers used s0, s1, s2, s3, s4, s5// #1131: ;// @17e #1132: [display_hex_byte]3016d // @17e #1132: CALL(hex_byte_to_ASCII)01530 // @17f #1133: LOAD(s5,s3)301eb // @180 #1134: CALL(LCD_write_data)01520 // @181 #1135: LOAD(s5,s2)301eb // @182 #1136: CALL(LCD_write_data)2a000 // @183 #1137: RETURN// #1138: ;// #1139: ;// #1140: ;// #1141: ; Display the 32-bit value stored in 4 ascending memory locations as an 8 character// #1142: ; HEX value at the current cursor position. Register s7 must contain the memory// #1143: ; location of the most significant byte (which is also the highest address).// #1144: ;// #1145: ; Registers used s0, s1, s2, s3, s4, s5, s6, s7// #1146: ;// @184 #1147: [display_hex_32_bit]00604 // @184 #1147: LOAD(s6,4) ;4 bytes to display// @185 #1148: [disp32_loop]07070 // @185 #1148: FETCH(s0,s7) ;read byte3017e // @186 #1149: CALL(display_hex_byte) ;display byte1c701 // @187 #1150: SUB(s7,1) ;decrement pointer1c601 // @188 #1151: SUB(s6,1) ;count bytes displayed2b000 // @189 #1152: RETURN(Z)34185 // @18a #1153: JUMP(disp32_loop)// #1154: ;// #1155: ;// #1156: ;**************************************************************************************// #1157: ;LCD text messages// #1158: ;**************************************************************************************// #1159: ;// #1160: ;// #1161: ;Display 'Frequency' on LCD at current cursor position// #1162: ;// @18b #1163: [disp_Frequency]00546 // @18b #1163: LOAD(s5,character_F)301eb // @18c #1164: CALL(LCD_write_data)00572 // @18d #1165: LOAD(s5,character_r)301eb // @18e #1166: CALL(LCD_write_data)00565 // @18f #1167: LOAD(s5,character_e)301eb // @190 #1168: CALL(LCD_write_data)00571 // @191 #1169: LOAD(s5,character_q)301eb // @192 #1170: CALL(LCD_write_data)00575 // @193 #1171: LOAD(s5,character_u)301eb // @194 #1172: CALL(LCD_write_data)00565 // @195 #1173: LOAD(s5,character_e)301eb // @196 #1174: CALL(LCD_write_data)0056e // @197 #1175: LOAD(s5,character_n)301eb // @198 #1176: CALL(LCD_write_data)00563 // @199 #1177: LOAD(s5,character_c)301eb // @19a #1178: CALL(LCD_write_data)00579 // @19b #1179: LOAD(s5,character_y)301eb // @19c #1180: CALL(LCD_write_data)2a000 // @19d #1181: RETURN// #1182: ;// #1183: ;Display 'Generator' on LCD at current cursor position// #1184: ;// @19e #1185: [disp_Generator]00547 // @19e #1185: LOAD(s5,character_G)301eb // @19f #1

⌨️ 快捷键说明

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