FreeCPU/Callback.v
GabrielTofvesson a3f7a48276 Fixed minor issues in ALU.v
Rewrote RAM.v
  RAM should now support read and write
  RAM CKE will be pulled low when no queries to it are being made
  Added bank-independent read/write systems
  Added parameterized per-bank clock-hogging
2018-10-17 02:34:03 +02:00

25 lines
552 B
Verilog

module Callback(
input wire clk,
input wire [ISIZE-1:0] countdown,
input wire reset,
output wire callback
);
parameter ISIZE;
reg [ISIZE-1:0] counter;
reg [2:0] ctr_trigger = 2'b00;
assign callback = !counter && ctr_trigger ? 1'b1 : 1'b0;
always @(posedge clk or posedge reset) begin
if(reset) begin
counter <= countdown;
ctr_trigger <= 2'b10;
end
else if(counter) counter <= counter - 1'b1;
else if(ctr_trigger) ctr_trigger = ctr_trigger - 2'b1; // pull trigger high for 2 clock cycles to correct for 2.5ns pulse issues
end
endmodule