金牌会员
 
- 积分
- 1093
- 金钱
- 1093
- 注册时间
- 2015-11-29
- 在线时间
- 146 小时
|
always @(posedge sys_clk)
begin
if(rst_n == 1'b0) begin
//mo_pre_normal<=16'd0,
mo_normal<=16'd0;
//pa1_normal<=16'd0;
//pa2_normal<=16'd0;
normal_rdy <= 1'b0;
cnt_delay <= 32'd0;
//K1_en<= 1'b0;//pa2
//K2_en<= 1'b0;//pa1
K3_en<= 1'b1;//mo
state <= A;
end
else begin//run_moshi模式
case(state) //laser_mode
A: begin
if ({s3, s4} == 2'b10) begin // 0x02帧装订成功后,直接进入预热
//K1_en<= 1'b1;//pa2
// K2_en<= 1'b1;//pa1
if(run_moshi==2'd0)begin//连续模式
mo_normal<=mo_value;
//pa1_normal<=pa1_value;
//pa2_normal<=pa2_value;
cnt_delay <= 32'd0;
state <= B;
end else
if(run_moshi==1'd1)begin//脉冲模式
cnt_delay <= 32'd0;
mo_normal<=mo_value;
state <= D;
end
else
if(run_moshi==1'd2)begin//双波模式
cnt_delay <= 32'd0;
mo_normal<=mo_pre_value;
state <= F;
end
end
end
B: begin
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
C: begin
if(cnt_delay >= pa_mo_guanbi_yanshi) begin //
//pa2_normal<=16'd0;
//pa1_normal<=16'd0;
mo_normal<=16'd0;
//pa1_normal<=16'd0;
//pa2_normal<=16'd0;
cnt_delay <= 32'd0;
state <= A;
end
else begin
cnt_delay <= cnt_delay + 32'd1;
end
end
D: begin
if(cnt_delay>=mo_maikuan-32'd1)begin
mo_normal<=16'd0;
cnt_delay <= 32'd0;
state <= E;
end else begin
cnt_delay <= cnt_delay + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
E: begin
if(cnt_delay>=period_num_debug-mo_maikuan-32'd2)begin
mo_normal<=mo_value;
cnt_delay <= 32'd0;
state <= D ;
end else begin
cnt_delay <= cnt_delay + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
F:begin
if(cnt_delay>=mo_pre_maikuan-32'd1)begin
mo_normal<=16'd0;
cnt_delay <= 32'd0;
state <= G;
end else begin
cnt_delay <= cnt_delay + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
G:begin
if(cnt_delay>=mo_doub_yanshi)begin
mo_normal<=mo_value;
cnt_delay <= 32'd0;
state <= H;
end else begin
cnt_delay <= cnt_delay + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
H:begin
if(cnt_delay>=mo_maikuan-32'd1)begin
mo_normal<=16'd0;
cnt_delay <= 32'd0;
state <= I;
end else begin
cnt_delay <= cnt_delay + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
I:begin
if(cnt_delay>=period_num_debug-mo_maikuan-mo_pre_maikuan-mo_doub_yanshi-32'd3)begin
mo_normal<=mo_pre_value;
cnt_delay <= 32'd0;
state <= F ;
end else begin
cnt_delay <= cnt_delay + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
end
end
default: begin
//if(laser_mode==1'b0)begin //关闭激光器
cnt_delay <= 32'd0;
state <= C;
//end
end
endcase
end
end
always @(posedge sys_clk)
begin
if(rst_n == 1'b0) begin
//mo_pre_normal<=16'd0,
//mo_normal<=16'd0;
pa1_normal<=16'd0;
// pa2_normal<=16'd0;
//normal_rdy <= 1'b0;
cnt_delaypa1 <= 32'd0;
//K1_en<= 1'b0;//pa2
K2_en<= 1'b0;//pa1
//K3_en<= 1'b1;//mo
statePA1 <= A;
end
else begin//run_moshi模式
case(statePA1) //laser_mode
A: begin
if ({s3, s4} == 2'b10) begin // 0x02帧装订成功后,直接进入预热
//K1_en<= 1'b1;//pa2
K2_en<= 1'b1;//pa1
pa1_normal<=16'd0;
statePA1 <= B;
cnt_delaypa1 <= 32'd0;
end
end
B: begin
if(cnt_delaypa1 >= pa1_mo_yanshi) begin
cnt_delaypa1 <= 32'd0;
if(run_moshi==2'd0)begin//连续模式
pa1_normal<=pa1_value;
statePA1 <= C;
end else
if(run_moshi==1'd1)begin//脉冲模式
pa1_normal<=pa1_value;
statePA1 <= D;
end
else
if(run_moshi==1'd2)begin//双波模式
pa1_normal<=pa1_pre_value;
statePA1 <= F;
end
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
pa1_normal<=16'd0;
statePA1 <= C;
end
end
C: begin
//statePA1 <= A;
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
pa1_normal<=16'd0;
statePA1 <= A;
end
end
D: begin
if(cnt_delaypa1>=pa1_maikuan-32'd1)begin
pa1_normal<=16'd0;
cnt_delaypa1 <= 32'd0;
statePA1 <= E;
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
pa1_normal<=16'd0;
statePA1 <= C;
end
end
E: begin
if(cnt_delaypa1>=period_num_debug-pa1_maikuan-32'd2)begin
pa1_normal<=pa1_value;
cnt_delaypa1 <= 32'd0;
statePA1 <= D ;
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
pa1_normal<=16'd0;
statePA1 <= C;
end
end
F:begin
if(cnt_delaypa1>=pa1_pre_maikuan-32'd1)begin
pa1_normal<=16'd0;
cnt_delaypa1 <= 32'd0;
statePA1 <= G;
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
pa1_normal<=16'd0;
statePA1 <= C;
end
end
G:begin
if(cnt_delaypa1>=pa1_doub_yanshi)begin
pa1_normal<=pa1_value;
cnt_delaypa1 <= 32'd0;
statePA1 <= H;
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
pa1_normal<=16'd0;
statePA1 <= C;
end
end
H:begin
if(cnt_delaypa1>=pa1_maikuan-32'd1)begin
pa1_normal<=16'd0;
cnt_delaypa1 <= 32'd0;
statePA1 <= I;
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
cnt_delaypa1 <= 32'd0;
statePA1 <= C;
end
end
I:begin
if(cnt_delaypa1>=period_num_debug-pa1_maikuan-pa1_pre_maikuan-pa1_doub_yanshi-32'd3)begin
pa1_normal<=pa1_pre_value;
cnt_delaypa1 <= 32'd0;
if(laser_mode==1'b1)begin //关闭激光器
statePA1 <= F ;
end
else statePA1 <= J;
end else begin
cnt_delaypa1 <= cnt_delaypa1 + 32'd1;//period_num_debug
end
end
J:begin
if(laser_mode==1'b0)begin //关闭激光器
//pa2_normal<=16'd0;
pa1_normal<=16'd0;
cnt_delaypa1 <= 32'd0;
statePA1 <= C;
end
end
default: begin
end
endcase
end
end
always @(posedge sys_clk)
begin
if(rst_n == 1'b0) begin
//mo_pre_normal<=16'd0,
//mo_normal<=16'd0;
pa2_normal<=16'd0;
// pa2_normal<=16'd0;
//normal_rdy <= 1'b0;
cnt_delaypa2 <= 32'd0;
//K1_en<= 1'b0;//pa2
K1_en<= 1'b0;//pa1
//K3_en<= 1'b1;//mo
statePA2 <= A;
end
else begin//run_moshi模式
case(statePA2) //laser_mode
A: begin
if ({s3, s4} == 2'b10) begin // 0x02帧装订成功后,直接进入预热
//K1_en<= 1'b1;//pa2
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
K1_en<= 1'b1;//pa1
statePA2 <= B;
end
end
B: begin
if(cnt_delaypa2 >= pa2_mo_yanshi) begin //
if(run_moshi==2'd0)begin//连续模式
pa2_normal<=pa2_value;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end else
if(run_moshi==1'd1)begin//脉冲模式
cnt_delaypa2 <= 32'd0;
pa2_normal<=pa2_value;
statePA2 <= D;
end
else
if(run_moshi==1'd2)begin//双波模式
cnt_delaypa2 <= 32'd0;
pa2_normal<=pa2_pre_value;
statePA2 <= F;
end
end
else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;
end
if(laser_mode==1'b0)begin //关闭激光器
//pa2_normal<=16'd0;
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
C: begin
cnt_delaypa2 <= 32'd0;
//statePA2 <= A;
if(laser_mode==1'b0)begin //关闭激光器
//pa2_normal<=16'd0;
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= A;
end
end
D: begin
if(cnt_delaypa2>=pa2_maikuan-32'd1)begin
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= E;
end else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;//period_num_debugn
end
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
E: begin
if(cnt_delaypa2>=period_num_debug-pa2_maikuan-32'd2)begin
pa2_normal<=pa2_value;
cnt_delaypa2 <= 32'd0;
statePA2 <= D ;
end else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
F:begin
if(cnt_delaypa2>=pa2_pre_maikuan-32'd1)begin
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= G;
end else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
G:begin
if(cnt_delaypa2>=pa2_doub_yanshi)begin
pa2_normal<=pa2_value;
cnt_delaypa2 <= 32'd0;
statePA2 <= H;
end else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
H:begin
if(cnt_delaypa2>=pa2_maikuan-32'd1)begin
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= I;
end else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
I:begin
if(cnt_delaypa2>=period_num_debug-pa2_maikuan-pa2_pre_maikuan-pa2_doub_yanshi-32'd3)begin
pa2_normal<=pa2_pre_value;
cnt_delaypa2 <= 32'd0;
statePA2 <= F ;
end else begin
cnt_delaypa2 <= cnt_delaypa2 + 32'd1;//period_num_debug
end
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2<= C;
end
end
J:begin
if(laser_mode==1'b0)begin //关闭激光器
pa2_normal<=16'd0;
cnt_delaypa2 <= 32'd0;
statePA2 <= C;
end
end
default: begin
end
endcase
end
end
这样3个dac就会时不时无法开启或者关闭 |
|