WOW!!!! Ok, Fantastic answers! You guys are awesome! This was the
kind of answers I was looking for. And thank you Mark McDougall for
answering my specific questions. And thank the rest of you for
extending the discussion beyond my basic questions.
I am a newbie to VHDL but I've been a hardware engineer for almost 10
years. In those 10 years I've done a LOT of PLD coding in PALASM..yes
PALASM and quite a bit of coding in AHDL. I've decided to make the
move recently to VHDL to improve my formalism a bit. I'm still a
hardware guy for the most part. About 20% of my job is VHDL.
So, one last question. Is the LPM counter function (I'm talking about
the Altera brand here) a sychronous counter or a ripple counter? From
my basic understanding the examples like the one below from Andy would
result in a ripple counter.
Thanks again,
Shannon
On 22 Aug 2006 15:46:00 -0700, "Andy" <> wrote:
>Mike's example, while very well put together, is functionally more
>complex than what you require (it does more, not just takes more
>typing). Your requirements can be met with code as simple as:
>
>process (clk) is
> variable data : unsigned(data_out'range);
>begin
> if rising_edge(clk) then
> if synchronous_reset = '1' then
> data := (others => '0');
> elsif synchronous_load = '1' then
> data := data_in;
> elsif count_enable = '1' then
> data := data + 1;
> end if;
> end if;
> data_out <= data; -- copy data to data_out
>end process;
>
>Assumptions:
>1. data_out is a port of mode out that cannot be read.
>2. data_out and data_in are both of type numeric_std.unsigned.
>3. data_out and data_in are the same size.
>
>Note that you did not specify a reset, but I added a synchronous one.
>Adding an async reset would be just as trivial.
>
>You could always encapsulate the above process in an
>entity/architecture, but then it would be necessary to generate the
>control inputs for it. Sometimes it is easier and more self documenting
>to just merge a counter function into a state machine than it is to
>generate the signals to communicate with a separate counter. Especially
>when you want things done on the same clock edge (i.e. no register
>delays).
>
>LPM fifos and memories can only store std_logic_vector data types. What
>happens when you want to store enumerated types, arrays, and/or
>records? If you know how to infer memories and counters, fifos are
>easily designed of any size and any content type you want.
>
>Andy
>
>
>Shannon wrote:
>> On Fri, 18 Aug 2006 11:41:32 -0700, Mike Treseler
>> <> wrote:
>>
>> >KJ wrote:
>> >
>> >> Actually 'LPM' (Library of parameterizable modules) is fairly portable
>> >> and is (I think) an EIA standard
>> >
>> >The lpm models were written by Altera and
>> >were held by the now-defunct edif.org in
>> >the public domain. The models had complex
>> >string generics and were designed to be
>> >fronted by a wizard application to
>> >collect and fill in the option strings.
>> >The files were last updated by Altera in 1999
>> >and are now held by eia.
>> >
>> >Xilinx has tolerated the models for synthesis
>> >but you can find very little information
>> >about lpm on their website.
>> >Xilinx infers matching netlists, but
>> >they are not named lpm.
>> >Altera supports
>> >the existing models, but there has not been
>> >a new one in a long time.
>> >
>> >> it's the MegaWizard produced files
>> >> that are not and are specific to company 'A'. Within LPM, besides the
>> >> stupid things like 'and', 'or', etc. there are some useful ones like
>> >> 'lpm_divide', 'lpm_ram', 'lpm_rom', 'lpm_fifo' (and variants on those).
>> >> But you don't need a wizard to use these parts either,
>> >
>> >True for Altera. Tough otherwise since the source
>> >code is no longer public.
>> >
>> >> you simply
>> >> instantiate the lpm component hooking up signals, defining the
>> >> generics, etc just like you would any other entity.
>> >
>> >Quartus will also infer these for you from code.
>> >
>> >
>> > -- Mike Treseler
>>
>> It seems a bit much just for a simple counter to have to write piles
>> of code like Mike linked to in his first response. That is why the lpm
>> counter seemed so simple to me. The lpm counter made the code look
>> nice and clean and neat and readable. Also, I assumed the lpm code
>> had been properly tested and vetted so that it reduces the amount of
>> code testing/debuging I need to do.
>>
>> Harsh comments from Mike aside, what would be the "correct" way of
>> creating a "clean" reusable counter that includes: clock, count
>> enable, synchronous load, data in, and data out?
>>
>> As an aside to Mike I'd like to add this:
>>
>> I'm old school on the net and so my skin is pretty thick. But you
>> might want to conscider toning down your snide comments a bit. Act
>> like the person you are responding to is right in the room with you.
>> Maybe even act like he is a customer. I'm sure you have lots of good
>> things to say to help out newbies but acting like a jerk gets in the
>> way. I don't want to start a flame war here. My email address is
>> visible. I would be happy to take this offline.
>>
>> Shannon
|