Draw Arc in Verilog - Page 1
Forum section: electronics / general

author: davorin
author_rank: Unknown
timestamp: February 26, 2021, 12:32:59 pm
content: [ Specified attachment is not available ]Good afternoon (o;Loooong time I was here the last time (o;Playing around with Trion FPGAs and a round 2.1" display....To draw a circle or a ring is just 4 lines of code...But has someone came across an implementation, preferrably Verilog, how to draw a circle segment?Like something to draw a meter gauge on a round display?

author: ralphrmartin
author_rank: Frequent Contributor
timestamp: February 26, 2021, 08:08:12 pm
content: Look up Bresenham's Circle Drawing Algorithm.

author: BrianHG
author_rank: Super Contributor
timestamp: February 26, 2021, 09:20:32 pm
content: This could help:https://www.eevblog.com/forum/fpga/systemverilog-example-testbench-which-saves-a-bmp-picture-and-executes-a-script/And here for more complex with line generators, box, triangles, filled, blitter memory access, multiple bitplane depth:https://www.eevblog.com/forum/fpga/fpga-vga-controller-for-8-bit-computer/msg3465124/#msg3465124

author: davorin
author_rank: Unknown
timestamp: February 26, 2021, 09:27:55 pm
content: Thanks BrianBut I was hoping it would be possible to do without any frame buffer to draw pixels first...Just a circle or a ring is a no-brainer in Verilog...Reason for going without frame buffer: costsThose Trion FPGAs are around $1 or lower... but then again I am already using 6 out of 8 multipliers on a T8F81...

author: BrianHG
author_rank: Super Contributor
timestamp: February 26, 2021, 09:35:42 pm
content: Quote from: davorin on February 26, 2021, 09:27:55 pmRead the ellipse_generator.sv code. No frame buffer, you enter 4 coordinates + optional fill with an enabler and it spits X&Y coordinates. It's the test-bench which logs the output and saves the .bmp.Also, as you can see my ellipse code, I have around 10 multiplies required to setup an ellipse, but the code only uses 1 24 bit multiplier. Read how I use the 'consolidated multiplier' and maybe you can adapt your existing code in such a way to consolidate more of your multipliers into 1 unit. My code is also engineered for speed as it spits out 125 million new pixels a second. There are ways to shrink down the logic but cut the FMAX down by a large margin. Also, drawing a circle instead of an ellipse would also cut a good number of gates, however, I think the feature is worth it.

author: davorin
author_rank: Unknown
timestamp: February 26, 2021, 09:41:50 pm
content: Hello BrianBut that is for a full ellipse/circle only....How about when I need only a 60 degree circle?

author: BrianHG
author_rank: Super Contributor
timestamp: February 26, 2021, 09:51:16 pm
content: I never claimed I had all the answers, but I gave you a look at what is minimum required to draw an arc. You need to work out what you want to do on your own. IE, draw a bitmap or string of coordinates from memory. Or maybe run my sim source code, look at the internal regs at 2 points on your selected arc and drive my arc generator with those internal regs either from ram or calculated to define a start position, then use a counter to define the end position. How about running the arc without drawing the output to count the number of pixels required to construct your arc, then run it again only enabling the output for the begin and end % of the total pixel count of when you want to write the pixels.I know with the 'full' geometry unit, I would make the partial arc by painting the full or selected quadrants of an arc, then run 2 filled triangles to remove the un-wanted portions creating the final partial arc I like.