axi_fan_control: updated ip

fixed tacho evaluation bug; updated fsm;
main
Sergiu Arpadi 2019-05-08 14:07:31 +01:00 committed by Adrian Costina
parent 95afc461a6
commit 369974f2e7
1 changed files with 7 additions and 13 deletions

View File

@ -110,9 +110,8 @@ localparam DRP_READ_TEMP = 8'h03;
localparam DRP_READ_TEMP_WAIT_DRDY = 8'h04; localparam DRP_READ_TEMP_WAIT_DRDY = 8'h04;
localparam GET_TACHO = 8'h05; localparam GET_TACHO = 8'h05;
localparam EVAL_TEMP = 8'h06; localparam EVAL_TEMP = 8'h06;
localparam EVAL_PWM = 8'h07; localparam SET_PWM = 8'h07;
localparam SET_PWM = 8'h08; localparam EVAL_TACHO = 8'h08;
localparam EVAL_TACHO = 8'h09;
reg [31:0] up_scratch = 'd0; reg [31:0] up_scratch = 'd0;
reg [7:0] state = INIT; reg [7:0] state = INIT;
@ -409,19 +408,10 @@ always @(posedge up_clk)
//if no changes are needed make sure to mantain current pwm //if no changes are needed make sure to mantain current pwm
pwm_width_req <= pwm_width; pwm_width_req <= pwm_width;
end end
state <= EVAL_PWM;
end
EVAL_PWM : begin
//setting alarm for temperature increase
if (pwm_width_req > pwm_width) begin
temp_increase_alarm <= 1'b1;
end
state <= SET_PWM; state <= SET_PWM;
end end
SET_PWM : begin SET_PWM : begin
temp_increase_alarm <= 1'b0;
if ((up_pwm_width != pwm_width) && (up_pwm_width >= pwm_width_req) && (up_pwm_width <= PWM_PERIOD) && (pwm_change_done)) begin if ((up_pwm_width != pwm_width) && (up_pwm_width >= pwm_width_req) && (up_pwm_width <= PWM_PERIOD) && (pwm_change_done)) begin
pwm_width <= up_pwm_width; pwm_width <= up_pwm_width;
pulse_gen_load_config <= 1'b1; pulse_gen_load_config <= 1'b1;
@ -429,12 +419,14 @@ always @(posedge up_clk)
end else if ((pwm_width != pwm_width_req) && (pwm_width_req > up_pwm_width) && (pwm_change_done)) begin end else if ((pwm_width != pwm_width_req) && (pwm_width_req > up_pwm_width) && (pwm_change_done)) begin
pwm_width <= pwm_width_req; pwm_width <= pwm_width_req;
pulse_gen_load_config <= 1'b1; pulse_gen_load_config <= 1'b1;
temp_increase_alarm <= 1'b1;
//clear alarm when pwm duty changes //clear alarm when pwm duty changes
end end
state <= EVAL_TACHO; state <= EVAL_TACHO;
end end
EVAL_TACHO : begin EVAL_TACHO : begin
temp_increase_alarm <= 1'b0;
//tacho section //tacho section
//check if the fan is turning then see if it is turning correctly //check if the fan is turning then see if it is turning correctly
if(counter_overflow & pwm_change_done) begin if(counter_overflow & pwm_change_done) begin
@ -510,6 +502,8 @@ always @(posedge up_clk) begin
if ((up_wreq_s == 1'b1) && (up_waddr_s == 8'h23)) begin if ((up_wreq_s == 1'b1) && (up_waddr_s == 8'h23)) begin
up_tacho_tol <= up_wdata_s; up_tacho_tol <= up_wdata_s;
up_tacho_en <= 1'b1; up_tacho_en <= 1'b1;
end else if (temp_increase_alarm) begin
up_tacho_en <= 1'b0;
end end
if ((up_wreq_s == 1'b1) && (up_waddr_s == 8'h10)) begin if ((up_wreq_s == 1'b1) && (up_waddr_s == 8'h10)) begin
up_irq_mask <= up_wdata_s[3:0]; up_irq_mask <= up_wdata_s[3:0];