Altera_Forum
Honored Contributor
11 years agoWhy does my code not like the addition clock in to the always loop?
Hi,
This is my very simple code. If i have a single clock going in to the always loop, i get very few warnings and when i simulate it, i get an output. If i add a second clock in to the always loop, as shown here. I don't get any errors but for some reason it doesn't like it and i don't get anything out. I do quite quite of few extra warnings. The clocks are generated by a PLL. I have a 50Mhz clock going in to the PLL and output 2 300Mhz outputs that are 180 degrees out of phase of each other. I'm using a Cyclone III EP3C25F324.module Pulse(input clk,
input clk2,
output reg out,
output reg state_var, //debug outputs
output reg counter);
parameter init = 4'd0,
run = 4'd1;
initial
begin
state_var<=init; //Straight in to Init
end
always @(posedge clk or posedge clk2)
begin
case (state_var)
init: begin
counter = 3'd0;
state_var <= run;
end
run: begin
if (counter == 2'd0)
begin
out<= 1'b1;
end
if (counter == 2'd1) //50% duty cycle
begin
out<= 1'b0;
end
if (counter == 2'd1) //Restart at 50% duty cycle
begin
counter <= 2'd0;
end
else
begin
counter <= counter + 1'b1;
end
end
endcase
end
endmodule Thanks