哪位大侠帮帮我呀,这里附上用汇编做的程序,根据实际需要,我要把它用verilog hdl给描述出来。
;//==================================
PHASE_DETECT:
MOV PHASE_NUMBER,#10H ;//相位调节次数=10H
MOV A,U414_STATUS
JB ACC.5,PHASE_DETECT_10
MOV A,U414_STATUS
SETB ACC.5 ;//EHT INH=0(高压板上的绿灯灭)
MOV U414_STATUS,A
MOV DPTR,#0CFFFH ;//选通U413
MOVX @DPTR,A
MOV A,SOL_STATUS
SETB ACC.7 ;//GREEN RELAY 合上
MOV SOL_STATUS,A
MOV DPTR,#7FFFH
MOVX @DPTR,A
SETB FRT_PRT_RDY
MOV A,FAULT_UNIT
SETB ACC.4 ;//EHT_ON
MOV FAULT_UNIT,A
PHASE_DETECT_10:
MOV R2,#00H
MOV R3,#00H
MOV R4,#00H
DJNZ R4,$
MOV R4,#00H ;//22H
DJNZ R4,$
MOV R1,PHASE_NUMBER ;//相位调节次数
PHASE_DETECT_90:
MOV R4,#39H ;//R4=17H(39H)
JB PHASE_REQUEST,PHASE_DETECT_20 ;//有相位请求吗?
RET
PHASE_DETECT_20:
JB T1,$
JNB T1,$
CLR EA
CLR PHASE_CLAMP ;//P14=0,PHASE SWITCH OFF
DJNZ R4,$
SETB PHASE_CLAMP ;//P14=1,PHASE SWITCH ON
MOV R4,#1EH ;//R4=07H(14H)
DJNZ R4,$
CLR F0
MOV R4,#32H ;//R4=26H(40H)
PHASE_DETECT_40:
MOV DPTR,#0CFFFH ;//选通U413
MOVX A,@DPTR
JB ACC.1,PHASE_DETECT_30 ;//PHASE_ALIG="1"?OK,PHASE ALIGNED MUCH
DJNZ R4,PHASE_DETECT_40
SJMP PHASE_DETECT_50
PHASE_DETECT_30:
SETB F0
PHASE_DETECT_50:
MOV A,P1 ;//NO,PHASE ALIGNED LITTLE
ANL A,#0FCH
ORL A,#11H
MOV R6,A ;//保存调频系数--->R6
MOV R4,#12H
JB F0,PHASE_DETECT_60
MOV R4,#10H ;//F0=0,PHASE DIG LITTLE
INC R3
MOV A,PHASE_OFFSET
INC A
JZ PHASE_DETECT_70
MOV PHASE_OFFSET,A
SJMP PHASE_DETECT_70
PHASE_DETECT_60: ;//F0=1,PHASE DIG MUCH
INC R2
MOV A,PHASE_OFFSET
DEC A
JZ PHASE_DETECT_70
MOV PHASE_OFFSET,A
PHASE_DETECT_70:
MOV A,P1
ANL A,#0FCH
ORL A,R4
MOV R4,#02H ;//R4=01H(02H)
JB PHASE_REQUEST,PHASE_DETECT_80 ;//CHK IF PHASE_REQUEST=0
SETB EA
RET
PHASE_DETECT_80:
JB T1,$
JNB T1,$
MOV P1,A ;//P14=1,ON PHASE SWITCH
XCH A,R6
DJNZ R4,$
MOV P1,A ;//恢复调频系数--->P1
MOV R4,#25H ;//R4=0FH(25H)
DJNZ R4,$
DJNZ R1,PHASE_DETECT_90
CLR EA
MOV A,PHASE_NUMBER ;//PHASE ADJUST
CLR C
CPL A
INC A
ADD A,R2
MOV R2,#00H
JC PHASE_DETECT_A0
MOV A,PHASE_NUMBER ;//PHASE ADJUST
CPL A
INC A
ADD A,R3 ;//PHASE DIG LITTLE
MOV R3,#00H
JC PHASE_DETECT_B0
MOV DPTR,#0CFFFH ;//选通U413
MOVX A,@DPTR
CPL A
JB ACC.3,PHASE_DETECT_C0 ;//JET START
MOV A,SOL_STATUS
SETB ACC.7 ;//GREEN RELAY 合上
MOV SOL_STATUS,A
MOV DPTR,#7FFFH
MOVX @DPTR,A
SETB FRT_PRT_RDY
PHASE_DETECT_C0:
CALL FAULT_DISPLAY
SETB EA
RET
;//================================== ;//相位调节过大(相位调节过大时,绿灯不灭)
PHASE_DETECT_B0:
MOV A,U415_STATUS
JNB ACC.1,PHASE_DETECT_B1 ;//相位调制故障已存在吗?
SETB EA
RET
PHASE_DETECT_B1:
ORL A,#01H ;//充电故障灯亮,相位故障灯灭
;// ANL A,#0FBH
MOV U415_STATUS,A
MOV DPTR,#5FFFH ;//选通U414
MOVX @DPTR,A
MOV A,FAULT_UNIT
SETB ACC.1
CLR ACC.4
MOV FAULT_UNIT,A
MOV A,SOL_STATUS
SETB ACC.6 ;//黄灯亮
MOV SOL_STATUS,A
MOV DPTR,#7FFFH
MOVX @DPTR,A
MOV A,U414_STATUS
SETB ACC.2 ;//面板充电故障灯亮
MOV U414_STATUS,A
MOV DPTR,#0CFFFH ;//选通U413
MOVX @DPTR,A
SETB EA
RET
;//================================== ;//相位调节过小(相位调节过小时,绿灯不灭)
PHASE_DETECT_A0:
MOV A,U415_STATUS
JNB ACC.1,PHASE_DETECT_A1 ;//相位调制故障已存在吗?
SETB EA
RET
PHASE_DETECT_A1:
; ORL A,#04H ;//充电故障灯灭,相位故障灯亮
ANL A,#0FEH
MOV U415_STATUS,A
MOV DPTR,#5FFFH ;//选通U414
MOVX @DPTR,A
MOV A,FAULT_UNIT
SETB ACC.1
CLR ACC.4
MOV FAULT_UNIT,A
MOV A,SOL_STATUS
SETB ACC.6 ;//黄灯亮
MOV SOL_STATUS,A
MOV DPTR,#7FFFH
MOVX @DPTR,A
MOV A,U414_STATUS
SETB ACC.2 ;//面板充电故障灯亮
MOV U414_STATUS,A
MOV DPTR,#0CFFFH ;//选通U413
MOVX @DPTR,A
SETB EA
RET
版主,我附上用汇编做的程序,根据实际需要,我要把该程序用verilog hdl给描述出来。请您过目,谢谢。
;//======================================
VOC_DETECT:
MOV R3,#00H ;//READ COUNTER
VOC_DETECT_20:
CLR TF0
CLR P2.5 ;//ENABLE ADC0804
MOV R0,#0FFH ;//START ADC0804
MOV A,#0FFH
MOVX @R0,A
MOV R4,#00H
DJNZ R4,$
MOVX A,@R0
SETB P2.5 ;//DISABLE ADC0804
MOV TEMP_MEAS,A
CLR C
SUBB A,#32H ;//50℃
JC VOC_DETECT_10
INC R3
MOV A,R3
CLR C
SUBB A,#200 ;//200 COUNTER
JC VOC_DETECT_20
RET
VOC_DETECT_10:
CLR C
MOV A,#0D4H ;//#D4H-->A,IF(28H)>2BH=43℃
ADD A,TEMP_MEAS ;//(28H)
MOV R1,#0BH ;//#14H-->R0
JC VOC_DETECT_30
MOV R1,#00H
MOV A,TEMP_MEAS
CPL A ;//FFH-(28H)+04H+04H
ADD A,#04H ;//GAP=4℃
MOV TEMP_MEAS,A
JC VOC_DETECT_30
VOC_DETECT_40:
MOV A,#04H ;//GAP=4℃
ADD A,TEMP_MEAS
MOV TEMP_MEAS,A
JC VOC_DETECT_30 ;//C=1,JUMP,IF(28H)R4
ADD A,#32
MOV THOERY32,A ;//THOERY VALUE+25
MOV A,R4 ;//THOERY VALUE
ADD A,#2
MOV THOERY2,A ;//THOERY VALUE+10
CLR C
MOV A,R4 ;//THOERY VALUE
SUBB A,#10
JC VOC_DETECT_D0 ;//FAULT ON
MOV THOERY10,A ;//THOERY VALUE-10
CLR C
MOV A,R4 ;//THOERY VALUE
SUBB A,#32
JC VOC_DETECT_D0 ;//FAULT ON
MOV R5,A ;//THOERY VALUE-25
MOV A,R7 ;//TEST VALUE
SUBB A,#10
JC VOC_DETECT_D0 ;//FAULT ON
MOV A,R7 ;//TEST VALUE
SUBB A,R4 ;//THOERY VALUE
JNC VOC_DETECT_E0 ;//TEST VALUE>THOERY VALUE
CLR C
MOV A,R7 ;//TEST VALUE
SUBB A,R5 ;//THORY VALUE-20
JC VOC_DETECT_D0 ;//FAULT ON,TEST VALUETHORY VALUE-32
VOC_DETECT_E0:
MOV A,R7 ;//TEST VALUE
SUBB A,THOERY2 ;//THOERY VALUE+5
JC VOC_DETECT_F0 ;//NO FAULT,TEST VALUE