rtl:timer: update interrupt assert
Signed-off-by: liangkangnan <liangkangnan@163.com>pull/1/head
parent
6f5fe893cb
commit
b0c4d1fa4d
|
@ -29,7 +29,7 @@ module timer(
|
||||||
input wire req_i,
|
input wire req_i,
|
||||||
|
|
||||||
output reg[31:0] data_o,
|
output reg[31:0] data_o,
|
||||||
output reg int_sig_o,
|
output wire int_sig_o,
|
||||||
output reg ack_o
|
output reg ack_o
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -53,28 +53,20 @@ module timer(
|
||||||
reg[31:0] timer_value;
|
reg[31:0] timer_value;
|
||||||
|
|
||||||
|
|
||||||
|
assign int_sig_o = ((timer_ctrl[2] == 1'b1) && (timer_ctrl[1] == 1'b1))? `INT_ASSERT: `INT_DEASSERT;
|
||||||
|
|
||||||
// counter
|
// counter
|
||||||
always @ (posedge clk) begin
|
always @ (posedge clk) begin
|
||||||
if (rst == `RstEnable) begin
|
if (rst == `RstEnable) begin
|
||||||
timer_count <= `ZeroWord;
|
timer_count <= `ZeroWord;
|
||||||
end else begin
|
end else begin
|
||||||
if (timer_ctrl[0] == 1'b1 && timer_value > 32'h0) begin
|
if (timer_ctrl[0] == 1'b1) begin
|
||||||
timer_count <= timer_count + 1'b1;
|
timer_count <= timer_count + 1'b1;
|
||||||
end else begin
|
if (timer_count >= timer_value) begin
|
||||||
timer_count <= `ZeroWord;
|
timer_count <= `ZeroWord;
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
// int signal
|
|
||||||
always @ (posedge clk) begin
|
|
||||||
if (rst == `RstEnable) begin
|
|
||||||
int_sig_o <= `INT_DEASSERT;
|
|
||||||
end else begin
|
end else begin
|
||||||
if (timer_count >= timer_value && timer_value > 32'h0) begin
|
timer_count <= `ZeroWord;
|
||||||
int_sig_o <= `INT_ASSERT;
|
|
||||||
end else if (we_i == `WriteEnable && addr_i[3:0] == REG_CTRL && timer_ctrl[2] == 1'b1) begin
|
|
||||||
int_sig_o <= `INT_DEASSERT;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -88,15 +80,16 @@ module timer(
|
||||||
if (we_i == `WriteEnable) begin
|
if (we_i == `WriteEnable) begin
|
||||||
case (addr_i[3:0])
|
case (addr_i[3:0])
|
||||||
REG_CTRL: begin
|
REG_CTRL: begin
|
||||||
timer_ctrl <= data_i;
|
timer_ctrl <= {data_i[31:3], (timer_ctrl[2] & (~data_i[2])), data_i[1:0]};
|
||||||
end
|
end
|
||||||
REG_VALUE: begin
|
REG_VALUE: begin
|
||||||
timer_value <= data_i;
|
timer_value <= data_i;
|
||||||
end
|
end
|
||||||
endcase
|
endcase
|
||||||
end else begin
|
end else begin
|
||||||
if (timer_count >= timer_value && timer_value > 32'h0) begin
|
if ((timer_ctrl[0] == 1'b1) && (timer_count >= timer_value)) begin
|
||||||
timer_ctrl[0] <= 1'b0;
|
timer_ctrl[0] <= 1'b0;
|
||||||
|
timer_ctrl[2] <= 1'b1;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue