Guest
Hi All,
I am trying to develop a timer module. Think of this timer module as a
black box that takes in a 50Khz signal output a window signal and a
period signal. My problem is I want to reset the countera, period and
window when there is a pulse on the Reference signal .. This code
gives me an error. I am trying to fix my code, can somebody help me
with this puzzle ...
Here is my code:
MasterCLK is 10Mhz input ...
Reference is 50Khz input
module timer( MasterCLK, Reference, period, Reset, Window
);
input MasterCLK;
input Reference;
output reg Window;
output reg period;
output reg RightReference;
input Reset;
reg Refout;
reg MCLK;
reg [31:0] countera;
reg Qreset;
always @ (posedge MasterCLK)
begin
Refout<=Reference; //
countera<=countera+1'b1; //increment the counter
//reset countera and period when Refout is asserted
case(countera)
01: period <= 1; //set cycle (up-count)
16: Window <= 1; //set pulse window
81: Window <= 0; //reset pulse window
100: period <= 0; //set cycle (down-count)
101: countera <= 0;
endcase
end
always @ (posedge Refout)
begin
countera <= 0; //reset counter
period <= 0; //reset period flip-flop
Window <= 0;
end
endmodule
I am trying to develop a timer module. Think of this timer module as a
black box that takes in a 50Khz signal output a window signal and a
period signal. My problem is I want to reset the countera, period and
window when there is a pulse on the Reference signal .. This code
gives me an error. I am trying to fix my code, can somebody help me
with this puzzle ...
Here is my code:
MasterCLK is 10Mhz input ...
Reference is 50Khz input
module timer( MasterCLK, Reference, period, Reset, Window
);
input MasterCLK;
input Reference;
output reg Window;
output reg period;
output reg RightReference;
input Reset;
reg Refout;
reg MCLK;
reg [31:0] countera;
reg Qreset;
always @ (posedge MasterCLK)
begin
Refout<=Reference; //
countera<=countera+1'b1; //increment the counter
//reset countera and period when Refout is asserted
case(countera)
01: period <= 1; //set cycle (up-count)
16: Window <= 1; //set pulse window
81: Window <= 0; //reset pulse window
100: period <= 0; //set cycle (down-count)
101: countera <= 0;
endcase
end
always @ (posedge Refout)
begin
countera <= 0; //reset counter
period <= 0; //reset period flip-flop
Window <= 0;
end
endmodule