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 07-15-2008, 02:37 PM
Chip
Guest
 
Posts: n/a
Default Gated clock

Greetings,

I have a 4-bit chip select bus (1 of 16) that I want to use as an
event. The simplest solution is to simply AND the 4 input lines to
produce a single signal called ChipSelect. As you probably know using
this signal in an 'always' block returns the 'Gated clock' warning.
Is there a solution to this problem?

Thanks
Reply With Quote
  #2 (permalink)  
Old 07-15-2008, 03:10 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Gated clock

Chip wrote:

> I have a 4-bit chip select bus (1 of 16) that I want to use as an
> event. The simplest solution is to simply AND the 4 input lines to
> produce a single signal called ChipSelect. As you probably know using
> this signal in an 'always' block returns the 'Gated clock' warning.
> Is there a solution to this problem?


A clocked block that ChipSelect as an input.

-- Mike Treseler
Reply With Quote
  #3 (permalink)  
Old 07-16-2008, 05:42 AM
rubson
Guest
 
Posts: n/a
Default Re: Gated clock

On Jul 15, 10:37*pm, Chip <[email protected]> wrote:
> Greetings,
>
> I have a 4-bit chip select bus (1 of 16) that I want to use as an
> event. *The simplest solution is to simply AND the 4 input lines to
> produce a single signal called ChipSelect. *As you probably know using
> this signal in an 'always' block returns the 'Gated clock' warning.
> Is there a solution to this problem?
>
> Thanks


if you wanna use it as asynchronous event then yes, is it critical for
you?
if not just use it as conditional statement, in other words

always @ (posedge xClk)begin
if (!CS) begin
............
............
............


end
end
Reply With Quote
  #4 (permalink)  
Old 07-16-2008, 07:06 PM
Chip
Guest
 
Posts: n/a
Default Re: Gated clock

On Jul 15, 9:42*pm, rubson <[email protected]> wrote:
> On Jul 15, 10:37*pm, Chip <[email protected]> wrote:
>
> > Greetings,

>
> > I have a 4-bit chip select bus (1 of 16) that I want to use as an
> > event. *The simplest solution is to simply AND the 4 input lines to
> > produce a single signal called ChipSelect. *As you probably know using
> > this signal in an 'always' block returns the 'Gated clock' warning.
> > Is there a solution to this problem?

>
> > Thanks

>
> if you wanna use it as asynchronous event then yes, is it critical for
> you?
> if not just use it as conditional statement, in other words
>
> always @ (posedge xClk)begin
> if (!CS) begin
> ............
> ............
> ............
>
> end
> end


This is a SPI slave engine. I want to build a state machine that
responds to each bit communicated via SPI. This requires that I know
the count/index of each bit. I want the /CS event to clear the bit
count/index back to 0 BEFORE the SPI clock edges begin to clock in
data.

If CS was a single line it would be easy and I could write something
like (in this example SPCK idle polarity is LO):

always @ (negedge CS or posedge SPCK) begin
if(!SPCK)
BitIndex <= 0;
else
BitIndex <= BitIndex + 1;
end

This process initializes the BitIndex at the beginning of each
transfer.

The problem is that I have a 4-bit (1 of 16) CS bus and the only way I
know of to get the equivalent falling edge is to AND the 4 bits:

wire CS;
and(CS, IN[0], IN[1], IN[2], IN[3]);

In this way I get the Gate Clock warning on signal CS.

Any ideas?

Thanks
Reply With Quote
  #5 (permalink)  
Old 07-16-2008, 07:43 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Gated clock

Chip wrote:

> This is a SPI slave engine.
> Any ideas?


http://www.fpga4fun.com/SPI.html
Reply With Quote
  #6 (permalink)  
Old 07-17-2008, 01:47 AM
rubson
Guest
 
Posts: n/a
Default Re: Gated clock

I think, the reason why you geting warrning of gated clock is not your
and logic CS, it is because you using that CS as a Clock , in your
example you using posedge clock then you using !SCLK as an event,
which will sampled with the negedge Chip Select.
1. Don't warry to much about gated clock warning, ( I guess you are
using Altera CPLD/FPGA, I have done a project with gated clock
warning , and it is still working fine)
2. As I understand you need just a counter which is counting your SPI
input DATA bits, then it shoud reset when SPI access is finished, if
this is rigth then you don't need the CS as an event of always block

parameter BIT;

reg [BIT:0] index;

always @ ( posedge SCLK ) begin
if (!CS)
index <= index +1;
else
index <= 'b0;
end

the index will remain always 0 until the next /CS will fall down:
Reply With Quote
  #7 (permalink)  
Old 07-17-2008, 05:20 AM
Chip
Guest
 
Posts: n/a
Default Re: Gated clock

On Jul 16, 5:47*pm, rubson <[email protected]> wrote:
> I think, the reason why you geting warrning of gated clock is not your
> and logic CS, it is because you using that CS as a Clock , in your
> example you using posedge clock then you using !SCLK as an event,
> which will sampled with the negedge Chip Select.
> 1. Don't warry to much about gated clock warning, ( I guess you are
> using Altera CPLD/FPGA, I have done a project with gated clock
> warning , and it is still working fine)
> 2. As I understand you need just a counter which is counting your SPI
> input DATA bits, then it shoud reset when SPI access is finished, if
> this is rigth then you don't need the CS as an event of always block
>
> parameter BIT;
>
> reg *[BIT:0] index;
>
> always @ ( posedge SCLK ) begin
> * if (!CS)
> * * * * * *index <= index +1;
> * else
> * * * * * *index <= *'b0;
> end
>
> the index will remain always 0 until the next /CS will fall down:


Thanks for the suggestion but the problem is that SCLK only clocks
when CS is LO. In other words the 'else' (reset) will never execute.
Reply With Quote
  #8 (permalink)  
Old 07-17-2008, 05:44 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Gated clock

Chip wrote:

> Thanks for the suggestion but the problem is that SCLK only clocks
> when CS is LO. In other words the 'else' (reset) will never execute.


CS goes HI when a different slave is accessed.
Consider reading the link I posted.
It explains the interface and implements it in verilog.

-- Mike Treseler
Reply With Quote
  #9 (permalink)  
Old 07-17-2008, 10:17 PM
Chip
Guest
 
Posts: n/a
Default Re: Gated clock

On Jul 17, 9:44*am, Mike Treseler <[email protected]> wrote:
> Chip wrote:
> > Thanks for the suggestion but the problem is that SCLK only clocks
> > when CS is LO. *In other words the 'else' (reset) will never execute.

>
> CS goes HI when a different slave is accessed.
> Consider reading the link I posted.
> It explains the interface and implements it in verilog.
>
> * * * * -- Mike Treseler


I did review your link but that example requires an additional 'clk'
that is faster than SPCK which I don't have.

Thanks anyway
Reply With Quote
  #10 (permalink)  
Old 07-17-2008, 11:47 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Gated clock

Chip wrote:

> I did review your link but that example requires an additional 'clk'
> that is faster than SPCK which I don't have.


No, that is the SPCK from the master.
It's just a shift register.
Data changes on one edge, but not the other.

see slide 9 here for a better waveform graphic:
http://ww1.microchip.com/downloads/en/devicedoc/spi.pdf
Reply With Quote
Reply

Bookmarks


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
Single clock pulse transfer b/w clock domain himassk Verilog 3 05-18-2007 07:10 AM
How to simulate netlist with gated clock? Davy Verilog 9 11-09-2006 07:43 PM
HELP: High fanout load on Gated clock output whizkid Verilog 3 11-15-2004 10:20 AM
How to implement gated clock and/or gated partial circuit in Verilog? walala Verilog 4 09-29-2003 04:49 PM
generate a 20 MHZ clock(pulse) with duty cycle other than 50 % from master clock 40 MHZ having 50 % duty cycle MegaPowerStar Verilog 2 08-19-2003 01:29 AM


All times are GMT +1. The time now is 12:07 PM.


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