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

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-21-2006, 11:36 AM
Fred
Guest
 
Posts: n/a
Default Video circle generator

I would like to use a FPGA to create some simple test patterns. One of
which is a circle with a variable diameter. I'm not sure where to start.
Can this be realistically be done in an FPGA using minimal resources?


Reply With Quote
  #2 (permalink)  
Old 04-21-2006, 11:53 AM
Arlet
Guest
 
Posts: n/a
Default Re: Video circle generator

Fred wrote:

> I would like to use a FPGA to create some simple test patterns. One of
> which is a circle with a variable diameter. I'm not sure where to start.
> Can this be realistically be done in an FPGA using minimal resources?


As long as you only want one circle, this can be done fairly easily.
For each generated pixel, calculate x^2 + y^2, and compare with r^2. If
smaller than r^2, you're inside the circle, otherwise you're outside.

Updating x^2 + y^2 is simple because you can use the previous result:
(x+1)^2 = x^2 + 2x + 1, so it only involves an addition. r^2 can be
supplied as a pre-calculated parameter.

For multiple circles, you can instantiate multiple copies, and mix the
outputs.

Reply With Quote
  #3 (permalink)  
Old 04-21-2006, 02:22 PM
John_H
Guest
 
Posts: n/a
Default Re: Video circle generator

Fred wrote:
> I would like to use a FPGA to create some simple test patterns. One of
> which is a circle with a variable diameter. I'm not sure where to start.
> Can this be realistically be done in an FPGA using minimal resources?


For a single line, the Y distance from center is known - it's from your
line count - and you know the desired radius so your unknowns are the
leading and trailing edges for either a filled circle or an outline.

X^2+Y^2=R^2 or X = +/-sqrt(r^2-Y^2)

Here you just need to think of the center as 0,0 and make adjustments
accordingly. The calculation only needs to be done once per line rather
than for each generated pixel which means you have a full scan line's
worth of time to do a calculation; serial aritmatic anyone?

If you don't need to ultra-tiny solution, the raw math is pretty simple
in an FPGA with embedded multipliers and a simple square root algorithm.
Reply With Quote
  #4 (permalink)  
Old 04-21-2006, 03:09 PM
Ray Andraka
Guest
 
Posts: n/a
Default Re: Video circle generator

Fred wrote:
> I would like to use a FPGA to create some simple test patterns. One of
> which is a circle with a variable diameter. I'm not sure where to start.
> Can this be realistically be done in an FPGA using minimal resources?
>
>

Yes, it can. In fact, it doesn't take much logic if you think outside
the box a little bit. Google "Bresenham circle" to find Bresenham's
circle drawing algorithm. No need for multiplies and square
roots...this does it with adds and subtracts by taking advantage of the
incremental algorithm for drawing a circle on a raster.
Reply With Quote
  #5 (permalink)  
Old 04-21-2006, 03:40 PM
Ben Jones
Guest
 
Posts: n/a
Default Re: Video circle generator

Hi Fred,

"Fred" <[email protected]> wrote in message
news:[email protected]
> I would like to use a FPGA to create some simple test patterns. One of
> which is a circle with a variable diameter. I'm not sure where to start.
> Can this be realistically be done in an FPGA using minimal resources?


Circle are in fact very easy to draw (or "scan convert", in the lingo). You
can do it without any square-roots or even multiplies (except by 2). The
algorithm due to Bresenham has been around for some time. Here's a good
tutorial page:

http://www.cs.unc.edu/~mcmillan/comp...e7/circle.html

The basic algorithm can easily be adapted to do filled circles.

Have a lot of fun,

-Ben-


Reply With Quote
  #6 (permalink)  
Old 04-21-2006, 04:51 PM
Thomas Womack
Guest
 
Posts: n/a
Default Re: Video circle generator

In article <[email protected]>,
Fred <[email protected]> wrote:
>I would like to use a FPGA to create some simple test patterns. One of
>which is a circle with a variable diameter. I'm not sure where to start.
>Can this be realistically be done in an FPGA using minimal resources?


If you already have an X and Y register from your video driver, and a
starting-new-line signal, then you can manage with two adders and a
comparator.

Have a register initialised to cx^2+cy^2 at the start of the frame.

At the start of each line, add 2*(y-cy)+1 to the register.

At every pixel, add 2*(x-cx)+1 to the register.

If the register value is less than a threshold, light the pixel,
otherwise don't.

Tom





Reply With Quote
  #7 (permalink)  
Old 04-22-2006, 06:00 PM
Kolja Sulimma
Guest
 
Posts: n/a
Default Re: Video circle generator

Ben Jones schrieb:
> Hi Fred,

You
> can do it without any square-roots or even multiplies (except by 2).

Not even that because
2(x+1) + 1 = (2x+1) + 2
You need a total of two adders and one comparator per ordinate.

Kolja Sulimma

Reply With Quote
  #8 (permalink)  
Old 04-24-2006, 12:45 AM
Fred
Guest
 
Posts: n/a
Default Re: Video circle generator


"Fred" <[email protected]> wrote in message
news:[email protected]
>I would like to use a FPGA to create some simple test patterns. One of
>which is a circle with a variable diameter. I'm not sure where to start.
>Can this be realistically be done in an FPGA using minimal resources?
>
>


I greatly appreciate the responses here. It's made life a great deal
easier!

Many thanks again.


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
NTSC video capture Matt Fornero FPGA 1 04-10-2006 07:24 PM
FPGA and video generation Johan FPGA 4 01-11-2006 04:42 PM
FPGA for video processing Dave Moore FPGA 5 06-30-2005 01:57 PM
RC100 Video DAC Mees FPGA 0 07-11-2004 07:48 PM
Video decoder and encoder IC's Ljubisa Bajic FPGA 1 11-02-2003 03:57 AM


All times are GMT +1. The time now is 02:33 AM.


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