Showing posts with label VHDL. Show all posts
Showing posts with label VHDL. Show all posts

Tuesday, January 11, 2011

Why must ModelSim Suck?

Only in the windows or linux world is it reasonable to expect the user to hunt down all the required libraries to do a simulation. Which is to say it is reasonable, I guess, in this unfair world.

Anyhow, when doing a ModelSim on my Actel ProAsic3e design, my module used a primitive, which consequently required the proasic3e library to simulate. To get ModelSim to know where the library was, it required two nonintuitive steps. First, I had to use the vmap command on the ModelSim console to map the name "proasic3e" to the physical library file. This also required that I figure out where it was hidden on my system, which I would never have been able to do without hints from various forum threads. Secondly, I had to specify the path name with forward rather than windows (backwards) slashes. The resulting vmap command is:

vmap proasic3e C:/Actel/Libero_v8.6/Designer/lib/modelsim/precompiled/vhdl/proasic3e

Now, "proasic3e" appears on the library tab and everything compiles and works.

Sunday, January 9, 2011

Sequencer work

Misc links to remember for future steps of compiling my sequencer demo:

The page which answered the question about whether processes in testbenches are repeating:

http://www.embeddedrelated.com/showarticle/31.php

The page which showed that the fuction conv_to_std_logic_vector seemed to demand a variable rather than an integer or other signal:

http://www.quest4tech.net/hardware/vhdl/techniques/

And some info about variables in VHDL:

http://www.gmvhdl.com/variable.htm

An illustrative public debate about the hazards of using asynchronous signals for a state machine.

http://www.fpgarelated.com/usenet/fpga/show/94294-1.php

The Actel PDF about the EDAC RAM:

http://www.actel.com/documents/EDAC_71_AN.pdf

The first hit on my search for information about the Actel RAM4K9 primitive used by Waltero and others:

http://www.kxcad.net/actel_designer/actel_designer_online_help/ACTgenIII%20files/a3_ProASIC3E_RAM4k9.htm

Monday, May 10, 2010

VHDL evaluating B GT A

So I stop screwing this up over and over,

Method for determinging A GT B for two unsigned integers using standard subtractor in VHDL:

where f(x,y) = x-y = x + 2's complement(y),

carry out of f(B-A) shows B > A. not f(A-B).

Examples:

1) is 70128 GT 65535?
for 24 bit case,
B = 70128 = x0111F0
A = 65535 = x00FFFF, 2s_comp(B) = xFF0001

B - A = x0111F0 + xFF0001 = x10011F1, carry out is 1, remainder = B-A = 4593

2) is 32768 GT 65535?
for 24 bit case,
B = 32768 = x008000
A = 65535 = x00FFFF, 2s_comp(B) = xFF0001

B - A = x008000 + xFF0001 = xFF8001, carry out is 0, remainder = B-A = -32767

Wednesday, March 17, 2010

Divide By 5 counter

For an FPGA, getting specific frequencies from the system clock involves things like "divide by 5". This turns out to be a little tricky if you want a real clock output with something resembling a 50% duty cycle. Some answers that I recently stumbled on include.

1. Use a PLL module if the FPGA has them, since they have multipliers and dividers built in that can make multiples or fractions of the input clock.

2. Use two binary dividers and combine them in novel ways that I don't completely understand yet. However, the following papers seem to explain it:

A SNUG paper from 2002 by ST Microelectronics, the original of which seems to not have the text contained in the still-barely-readable google cache:

http://74.125.95.132/search?q=cache:XH_x-8eBw-4J:www.scribd.com/doc/6868408/Clock-Dividers+vhdl+%22divide+by+5%22+counter+example&cd=6&hl=en&ct=clnk&gl=us

(original, seems to be working now: http://www.scribd.com/doc/6868408/Clock-Dividers)

Here seems to be some examples similar to the above, except the code makes no sense to me (particularly if x=n then x=x+1):

http://www.asic-world.com/examples/vhdl/counters.html

The first question in this quiz with answers looks interesting, but the problem in the outputs is not entirely clear:
http://www.ece.stevens-tech.edu/~bmcnair/SwTh-Sum04/quiz4-with-answers.pdf

Thursday, January 21, 2010

dividers in VHDL

Two nice versions of the same idea for making a divider in VHDL without doing stupid loops:

Here it is in simple, non-machine code:

http://www.missiontech.co.nz/index.php?page=read-an-article&articleId=85

Here is the same idea, implemented fully using cascades of adders/subtracters

http://www.cs.umbc.edu/portal/help/VHDL/samples/samples.shtml

And, surprisingly, here's all the source code for the above so that you don't have to do any thinking yourself:

http://www.cs.umbc.edu/~squire/download/divcas4_test.vhdl

Tuesday, October 13, 2009

Time to write VHDL like a big boy now

first leads on doing my shift registers with GENERATE:

Nice complete example in PPT format:

http://www.cse.wustl.edu/~jbf/cse362.d/cse362.vhdl.Generate.pdf

Very similar example except that he did the shift out code the way that I've done it so far:

http://www.people.vcu.edu/~rhklenke/tutorials/vhdl/modules/m11_23/sld035.htm

The google search:
http://www.google.com/search?hl=en&safe=active&q=vhdl+shift+register+generate+example&aq=f&oq=&aqi=

And the even more basic google search:
http://www.google.com/search?hl=en&safe=active&q=vhdl+generate+statement&aq=0&oq=vhdl+generate&aqi=g10

Sunday, January 18, 2009

Instantiating Block RAM for Spartan 3E in VHDL without using COREGEN

Screw Coregen!

To use block RAMs directly, use RAMB primitives given in the Xilinx primitives handbook (here: http://www.xilinx.com/itp/xilinx9/books/docs/s3edl/s3edl.pdf.

The question not answered is how to insert them into the VHDL. Obviously they need to be called out as a component somehow.

The answer was in Xilinx's block ram application note (http://www.xilinx.com/support/documentation/application_notes/xapp463.pdf) but did not jump out on initial reading. It took this forum thread to point out that there are quite easy to use templates for intantiating primitives built right into ISE. In ISE, Edit => Language Templates => VHDL => Component Instantiation => Block RAM (it gets a little more complicated than that at the end, but the basic idea is there). This gives the component declaration, and most importantly the library call that contains the actual primitive, both as a bitmap and as a simulation library.

Most of the forum threads out there on this subject are entirely devoted to how to use the INIT label or whatever to specify the initial contents of the RAM. Not sure why this is so worried over.

Also, the Spartan3e RAM primitive declaration has a fancy "SSR" line which is separate from the gbinit; gbinit produces the contents specified in the INITs, SSR is some weird enable for putting a constant output on the data lines regardless of the value of the address lines.