[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [oc] VHDL code for following condition needed



Aloha!

rshlp@indiainfo.com wrote:
> Hi,
> 
> Assume you have a control pin A [Integer], a clk and output CNT.
> Now, depending on the value of A, CNT should count from A value.
> 
> That is, 
> if A = 0, the counter should count from 0 to 3.
> if A = 1, the counter should count from 4 to 7.
> if A = 5, the counter should count from 20 to 23.
> if A = 2, the counter should count from 8 to 11.
> ... and so on.
> 
> Is there any way to write a general code for the above condition.
> Thanks in advance.

You need to supply a bit more information. For example:

What is the expected behaviour of the counter when A changes? Shall the 
counter start counting at the lower end of the new range? What happens when 
the counter goes back to a previous visited A state?

In general though, the answer to your question is yes. You can quite easily 
write code for this in either Verilog or VHDL. Think of it as a generic MOD4 
counter with settable base value.

Good luck!

-- 
Med vänlig hälsning, Yours

Joachim Strömbergson - Alltid i harmonisk svängning.
VP, Research & Development
----------------------------------------------------------------------
InformAsic AB / Hugo Grauers gata 5B / SE-411 33 GÖTEBORG / Sweden
Tel: +46 31 68 54 90  Fax: +46 31 68 54 91  Mobile: +46 733 75 97 02
E-mail: joachim.strombergson@informasic.com  Home: www.informasic.com


--
To unsubscribe from cores mailing list please visit http://www.opencores.org/mailinglists.shtml