1
Microcontrollers / Re: Divide clock by 3 on a ATF16V8B
« Last post by Wiljan on Today at 05:55:06 pm »No, it's impossible.
VHDL code use triggers with positive and negative clock edges. ATF16V8B have only positive clocked triggers.
You can create simple divider by 3 on it, but you've got not symmetrical output (with duty cycle 1//3 or 2/3 - on your choice)
And for ATF you need a special programmer (hardware), do you need any?
I don't know if this is possible on the ATF16V8B but this code will divide by 3 symmetrically only on the posedge of the clk
It's a cheat where you make a counter count to 3 and mux the output between 0, clk and 1 so I get the symmetrically from the clk input
Code: [Select]
module clk_div_3(
input wire clk,
output reg out);
reg [1:0] cnt = 0;
always@(posedge clk)
begin
begin
cnt <= cnt + 1;
if (cnt == 2) cnt<= 0;
end
end
always@(clk)
begin
case(cnt)
2'b00 : out = 0;
2'b01 : out = clk;
2'b10 : out = 1;
endcase
end
endmodule