FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-25-2004, 03:37 PM
bharathi
Guest
 
Posts: n/a
Default frequency divider

hi all,
i did a module for frequency divider , is capable to convert 30Mhz
to 400 kHz
i can get the proper simulation result, but the code is not
synthesisable, i given the code below.. suggest me some thing


module fre_div (
out_clk,
in_clk,
i_sysrst
);

input in_clk;
input i_sysrst;

output out_clk;

reg out_clk;

reg [6:0]cnt;
reg temp;

always @(posedge in_clk or i_sysrst)
begin
if(!i_sysrst)
begin
cnt <= 7'd0;
out_clk <= 1'b0;
end

else if (cnt == 7'd37)
begin
temp <= 1'b1;
cnt <= cnt +7'd1;
end

else if (cnt == 7'd75)
begin
out_clk <= ~out_clk;
cnt <= 7'd1;
end

else
cnt = cnt+7'd1;
end

always @(negedge in_clk)
begin
if(temp == 1'b1)
begin
out_clk <= ~out_clk;
temp <= 1'b0;
end

end

endmodule
Reply With Quote
  #2 (permalink)  
Old 11-25-2004, 04:27 PM
Mike Lewis
Guest
 
Posts: n/a
Default Re: frequency divider

You are trying to clock "out_clk" with both a positive and
negative edge of "in_clk". I haven't seen a real life flip yet
that has two clock inputs! That would be one reason why
it's not synthesizable.

Mike



"bharathi" <[email protected]> wrote in message
news:[email protected] om...
> hi all,
> i did a module for frequency divider , is capable to convert 30Mhz
> to 400 kHz
> i can get the proper simulation result, but the code is not
> synthesisable, i given the code below.. suggest me some thing
>
>
> module fre_div (
> out_clk,
> in_clk,
> i_sysrst
> );
>
> input in_clk;
> input i_sysrst;
>
> output out_clk;
>
> reg out_clk;
>
> reg [6:0]cnt;
> reg temp;
>
> always @(posedge in_clk or i_sysrst)
> begin
> if(!i_sysrst)
> begin
> cnt <= 7'd0;
> out_clk <= 1'b0;
> end
>
> else if (cnt == 7'd37)
> begin
> temp <= 1'b1;
> cnt <= cnt +7'd1;
> end
>
> else if (cnt == 7'd75)
> begin
> out_clk <= ~out_clk;
> cnt <= 7'd1;
> end
>
> else
> cnt = cnt+7'd1;
> end
>
> always @(negedge in_clk)
> begin
> if(temp == 1'b1)
> begin
> out_clk <= ~out_clk;
> temp <= 1'b0;
> end
>
> end
>
> endmodule



Reply With Quote
  #3 (permalink)  
Old 12-21-2004, 07:07 AM
john hong
Guest
 
Posts: n/a
Default Re: frequency divider

This is one of the pitfalls for people new to HDL's. Both temp and
out_clk have two drivers in this code, which would be sythesized to
wired 'OR's using Synopsys DC. For VHDL, it is not even synthesizable
in DC last time I checked...

Reply With Quote
  #4 (permalink)  
Old 12-29-2004, 08:02 AM
Guest
 
Posts: n/a
Default Re: frequency divider

Below is the freq divider by 4 code, whcih is synthesizable, with asyn
reset.

You can modify it to suit ur requirements.
--------------------------------------------------------------------

module FreqDivider1(in_clk, out_clk, _rst);
input in_clk;
input _rst;

output out_clk;

reg out_clk;
reg [6:0] cnt;

always @(negedge _rst)
begin
out_clk <= 1'b0;
cnt <= 0;
end



always @(posedge in_clk)
begin
if (cnt == 1)
begin
out_clk <= ~out_clk;
cnt <= 0;
end
else
cnt <= cnt +1;
end

endmodule
----------------------------------------------------------------

`timescale 1ns/1ns

module newBench ;
reg in_clk;
wire out_clk;

reg _rst;

FreqDivider1 Test_Entity( in_clk, out_clk, _rst);

initial
begin
_rst = 1;
in_clk = 0;
$display( $time," in_clk = %b , out_clk = %b , _rst = %b
",in_clk,out_clk,_rst);
#1 _rst = 0;
$display( $time," in_clk = %b , out_clk = %b , _rst = %b
",in_clk,out_clk,_rst);
#1 _rst = 1;
$display( $time," in_clk = %b , out_clk = %b , _rst = %b
",in_clk,out_clk,_rst);
#8 in_clk = ~in_clk;
$display( $time," in_clk = %b , out_clk = %b , _rst = %b
",in_clk,out_clk,_rst);
forever
begin
#10 in_clk = ~in_clk;
$display( $time," in_clk = %b , out_clk = %b , _rst = %b
",in_clk,out_clk,_rst);
end
end

initial
#300 $finish;

endmodule
------------------------------------------------------------
hope it helps.

-Ankur

Reply With Quote
  #5 (permalink)  
Old 12-30-2004, 06:43 AM
Guest
 
Posts: n/a
Default Re: frequency divider

above RTL will give u a race condition..

I pasted correct code at :

http://groups-beta.google.com/group/...b034fffaec8080
-Ankur

Reply With Quote
  #6 (permalink)  
Old 12-30-2004, 07:16 AM
Guest
 
Posts: n/a
Default Re: frequency divider

above RTL will give u a race condition..

I pasted correct code at :

http://groups-beta.google.com/group/...b034fffaec8080
-Ankur

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
max frequency with TSMC .18u std cell library whizkid Verilog 2 11-02-2004 04:43 PM
combinational divider snehashis Verilog 7 10-26-2004 11:02 PM
frequency synthesizer Carson Verilog 1 08-27-2004 05:38 PM
a 50/50 clock divider Eng Gan Verilog 0 08-28-2003 02:17 AM
combinational divider hswnetin Verilog 1 06-27-2003 03:32 PM


All times are GMT +1. The time now is 03:23 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved