C
Chloe
Guest
Hello everyone,
I'm very new to Verilog and hardware design, so any help or advice
given would be appreciated.
I have 2 clocks in my design. First clock is running at 60MHz, and the
other one is generated at a divided frequency of 2 from the first
clock, ie at 30MHz. Because its frequency is only divided by two, I
don't see the need for a counter. But please check and let me know if
I'm thinking wrongly:
-----------------
module FreqDivider(in_clk, out_clk, rst);
input in_clk;
input rst;
output out_clk;
reg out_clk;
always @(posedge in_clk or negedge rst)
begin
if (!rst)
begin
out_clk <= 1'b0;
end
else
out_clk = ~out_clk;
end
endmodule
-------------------------
testbench :
module FreqDiv_tb();
wire out_clk;
reg in_clk;
reg rst;
initial
begin
rst = 0;
in_clk = 0;
forever #10 in_clk = ~in_clk;
end
initial
begin
#1000;
rst = 1;
#1000;
rst = 0;
#1000;
#10000 $finish;
end
FreqDivider freqdiv_inst (in_clk, out_clk, _rst);
endmodule
------------------------------
It's an asynchronous design.
Would the RTL (not the testbench) be synthesizable? What about the race
conditions?
Thanks very much in advance.
I'm very new to Verilog and hardware design, so any help or advice
given would be appreciated.
I have 2 clocks in my design. First clock is running at 60MHz, and the
other one is generated at a divided frequency of 2 from the first
clock, ie at 30MHz. Because its frequency is only divided by two, I
don't see the need for a counter. But please check and let me know if
I'm thinking wrongly:
-----------------
module FreqDivider(in_clk, out_clk, rst);
input in_clk;
input rst;
output out_clk;
reg out_clk;
always @(posedge in_clk or negedge rst)
begin
if (!rst)
begin
out_clk <= 1'b0;
end
else
out_clk = ~out_clk;
end
endmodule
-------------------------
testbench :
module FreqDiv_tb();
wire out_clk;
reg in_clk;
reg rst;
initial
begin
rst = 0;
in_clk = 0;
forever #10 in_clk = ~in_clk;
end
initial
begin
#1000;
rst = 1;
#1000;
rst = 0;
#1000;
#10000 $finish;
end
FreqDivider freqdiv_inst (in_clk, out_clk, _rst);
endmodule
------------------------------
It's an asynchronous design.
Would the RTL (not the testbench) be synthesizable? What about the race
conditions?
Thanks very much in advance.