hsnhsyn1
Junior Member level 1
- Joined
- Mar 19, 2013
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,400
hi, i'm new to the forum and FPGA.
i'm designing a simple clock divider from 50 MHz as parameterized for a small part of a project.
my code is successfully compiled but when i try to simulate it with quartus timing analyzer, the output clock is all X.
i suppose there's something wrong with the output assignment.
any help would be helpful.
and here is the verilog code and also simulation capture.
https://obrazki.elektroda.pl/4895845300_1363727509.png
i'm designing a simple clock divider from 50 MHz as parameterized for a small part of a project.
my code is successfully compiled but when i try to simulate it with quartus timing analyzer, the output clock is all X.
i suppose there's something wrong with the output assignment.
any help would be helpful.
and here is the verilog code and also simulation capture.
Code:
// Clock divider circuit
// From 50 MHz to 1 MHz/200 Hz with %50 duty cycle
module clk_div(Clk_in, Clk_out);
// input ports
input Clk_in;
// output ports
output reg Clk_out;
// counter size calculation according to input and output frequencies
parameter sys_clk = 50000000; // 50 MHz system clock
parameter clk_out = 1000000; // 1 MHz clock output
parameter max = sys_clk / (2*clk_out); // max-counter size
reg [4:0]counter = 0; // 5-bit counter size
always@(posedge Clk_in) begin
if (counter == max-1)
begin
counter <= 0;
Clk_out <= ~Clk_out;
end
else
begin
counter <= counter + 1'd1;
end
Clk_out <= (counter == 5'd0);
end
endmodule