linebuffer
← All posts

OSD Design Studio, from the idea to a working module

Why I built an application for designing on-screen displays, what it generates, and a short guide to designing your first overlay with it.

A grayscale camera frame with an OSD overlay: camera name and mode at the top, a crosshair in the centre, and a gain bar, a rate readout and a REC indicator along the bottom.
The example project's overlay, drawn by the tool over a test scene.
On this page
  1. The idea
  2. What elements can be overlaid with OSD Design Studio?
  3. The design flow with the app
  4. The result
  5. A short guide
  6. What's coming next

The idea

On a project where I was providing digital design and consultancy services, one of the tasks was designing an OSD menu and text readouts overlaid on the video of an imaging system. There was no video processor in the system apart from the main FPGA, so the OSD had to be implemented in RTL. It had a wide variety of elements, such as text, numbers and menus, all overlaid on the streamed image.

I had done similar OSD designs before and I remember really enjoying them. Still, each one took quite some time, because I was building them almost from scratch. This time I wondered how I could make the process more enjoyable and at the same time quicker and easier. That is how the idea of an OSD designer app came about. One application where I could design every aspect of an OSD. I decided to give it a shot, and so I joined the AI train, where new applications and tools come out every day, with my OSD Design Studio. With it, designing an OSD and exporting it as RTL is now quick and easy.

What elements can be overlaid with OSD Design Studio?

An overlay is built from nine element types. Every element you place becomes its own small block in the generated module, with its own ROM for the glyphs or pixels it needs, so the hardware grows with the design rather than with the feature list.

Text: A fixed string in one of seven built-in fonts, or your own
TextA fixed string in one of seven built-in fonts, or your own
Text styles: Plain, outline or shadow, for any text
Text stylesPlain, outline or shadow, for any text
Text scale: Integer scale from 1x to 4x
Text scaleInteger scale from 1x to 4x
Readout: A number with sign, decimal point and unit
ReadoutA number with sign, decimal point and unit
Readout, no value: A placeholder while the valid flag is low
Readout, no valueA placeholder while the valid flag is low
Enum text: One string per value of an enum
Enum textOne string per value of an enum
Rectangle: Position and size can follow a binding
RectanglePosition and size can follow a binding
Rectangle, filled: A solid or half-blended panel
Rectangle, filledA solid or half-blended panel
Line: Horizontal or vertical, any length and thickness
LineHorizontal or vertical, any length and thickness
Crosshair: Arm length, centre gap and thickness
CrosshairArm length, centre gap and thickness
Crosshair, outlined: A 1 px outline keeps it visible on bright video
Crosshair, outlinedA 1 px outline keeps it visible on bright video
Bitmap: A 1-bit or palette PNG, scaled up to 8x
BitmapA 1-bit or palette PNG, scaled up to 8x
Bitmap, icon strip: An enum binding picks which icon is shown
Bitmap, icon stripAn enum binding picks which icon is shown
Bar: A gauge between a minimum and a maximum, with ticks
BarA gauge between a minimum and a maximum, with ticks
Bar, vertical: Either direction, filled from either end
Bar, verticalEither direction, filled from either end
Menu list: The menu's current page, with its cursor
Menu listThe menu's current page, with its cursor

Every tile above is drawn by the tool's own renderer, the same one that produces the golden frames, so this is what the RTL puts on the screen.

A live input can also be the value of a menu item instead of a binding, so a menu setting can drive the overlay directly, the way the Target box item in the example switches the marker on and off.

A few properties apply to every element:

  • Screens. An element belongs to one or more screens, and a binding selects the active screen at run time, the way the example switches between its main view and a diagnostics page.
  • Visibility. Up to two conditions, combined with AND or OR, decide when an element shows: a flag, the menu being open, or a particular menu page. An element can also blink at one of the project's blink rates.
  • Blend mode. Opaque paints the whole box, keyed skips transparent pixels, and half averages the overlay with the video. Invert, contrast and shift derive the colour from the video underneath, so the element stays readable on bright and dark scenes alike.
  • Palette and z-order. Colours come from a palette of up to 16 entries, and where elements overlap the one with the higher rank is drawn on top.

The design flow with the app

The flow has three parts: you design the overlay in the app, export it as one RTL module, and the export proves that module against the picture you designed.

1. Design in the app

The app is organised the way a design comes together. You describe the video the module will sit on, lay the overlay out, build the menu, choose the fonts and export. Until the export there is no RTL yet, but the Designer and the Menu page already run the same renderer and menu logic that go into the module, so what you see on the canvas is what the hardware will draw.

Designing in OSD Design Studio A design goes through five pages of the app: Project for the video format and budgets, Designer for the layout and bindings, Menu for pages and items, Assets for fonts and bitmaps, and Export for the RTL and testbench. Designer and Menu show a live preview that uses the same renderer and menu logic as the RTL. 01Project 02Designer 03Menu 04Assets 05Export video formatbudgets layoutbindings pagesitems fontsbitmaps RTLtestbench live preview: same renderer and menu logic as the RTL
Five pages, in the order a design usually moves through them.

2. Exported RTL

The export is a single synthesizable module, in Verilog or SystemVerilog, with four kinds of connection:

The exported OSD module in an FPGA or ASIC The generated osd module contains an adapter, a pipeline, a compositor, a menu controller and a font and bitmap ROM. Video comes in as parallel video or AXI4-Stream and leaves with the overlay drawn on it, with the same timing and a fixed latency. Bindings from the rest of the design feed readouts, flags, enums and coordinates; buttons drive the menu controller; menu outputs such as brightness and mode go back to the design. bindings readouts, flags, enums, coordinates osd generated module adapter pipeline compositor menu controller font + bitmap ROM video in parallel or AXI4-Stream video out same timing, fixed latency buttons up, down, enter, back menu outputs brightness, mode, ... to your design from 05 Export
The generated module in your design: video through it, bindings and buttons into it, menu outputs out of it.
  • Video in and video out. The stream passes through in the format and timing it arrived in, parallel or AXI4-Stream, and leaves a fixed number of clock cycles later with the overlay drawn on it. There is no frame buffer and no line buffer.
  • Bindings. The live values the overlay shows, such as a temperature readout, a recording flag or a target position. Your design drives them as plain ports, or writes them through an AXI4-Lite register map that the export generates.
  • Buttons. Up, down, enter and back go into the generated menu controller, which handles debounce, long-press repeat and timeouts.
  • Menu outputs. Each menu setting, brightness or mode for example, comes out as a port, so the rest of your design can act on it.

3. Verification

Every export comes with a self-checking testbench. It needs no expected values written by hand: the golden frames (plain-text hex files, one pixel per line, loaded with $readmemh) come from the same renderer you designed with, so the RTL is compared against the picture you saw.

How the exported testbench checks the module A scenario of frames, binding values and button presses drives two paths. The app's reference renderer produces golden frames; the generated RTL, simulated under Verilator, produces output frames. Each output frame is compared with its golden frame pixel for pixel, and the testbench reports pass or fail per frame. scenario sample framebinding valuesbutton presses reference renderer the app's own model goldenframes generated RTL simulated in Verilator outputframes compare every pixel, every frame frame 0..5: PASS
One scenario drives both the reference renderer and the RTL; every output frame must match its golden frame exactly.

The tool writes a scenario of frames and run-time states next to the testbench. By default it has six frames: the defaults, the OSD switched off, extreme binding values, the menu opened, the cursor moved and an item activated. Button presses and binding changes are applied between frames, and the reference model goes through the same events. A frame fails if a single pixel differs or the pixel count is wrong, and a failing frame is written to a text file so you can see where it went wrong.

The testbench also tries to break the module on purpose. With AXI4-Stream it pulls TREADY low at intervals, so the pipeline has to handle stalls. With parallel video it uses its own blanking, which the module must not depend on. It is written to be simulator-neutral, the command-line edition runs it under Verilator, and it ends with one PASS or FAIL line and a matching exit status, so it drops into a regression flow. For the example camera project, the whole check (generate, build in Verilator, simulate six 640x480 frames) takes about eight seconds:

frame 0: PASS
frame 1: PASS
frame 2: PASS
frame 3: PASS
frame 4: PASS
frame 5: PASS
RESULT: PASS (6 frames)

The result

You lay the overlay out over a sample frame, run the menu with on-screen buttons, and export a synthesizable module. Video goes in, the same video comes out with the overlay drawn on it, after a fixed number of clock cycles, with no frame buffer and no line buffer.

The same overlay with the menu open. The menu is part of the generated module, state machine included.
The same overlay with the menu open. The menu is part of the generated module, state machine included.

A short guide

The tool runs in the browser at linebuffer.com/tools/osd-design-studio, with nothing to install. File > Open example (also offered on the welcome screen) loads a camera project, which is a good place to start: every picture below comes from it. The left rail has five pages, and a design moves through them roughly in this order.

1. Project: the video and the budgets

Set the active area, the colour mode, the pixel clock and the stream interface so they match the bus the module will sit on. The budgets (latency, ROM, RAM, logic) are limits the tool checks the design against as you work. Bindings, the live values the overlay shows, and the menu buttons are declared on the tabs at the top.

Project settings: the video format, the stream interface and the budgets.
Project settings: the video format, the stream interface and the budgets.

2. Designer: lay out the overlay

Add text, readouts, enumerated text, rectangles, lines, crosshairs, bitmaps and bars over the sample frame, and connect each one to a binding. The run-time panel on the right changes the binding values and presses the buttons, so you see the overlay react before any RTL exists.

The Designer with the example project: the element list, the canvas and the run-time state.
The Designer with the example project: the element list, the canvas and the run-time state.

3. Menu: pages and items

A menu is a set of pages, and each page a list of items: numbers, enums, toggles, sub-pages, actions and an exit. The preview underneath runs the real navigation logic, the same one that is generated into the module.

The Menu page: the main menu's items and a live preview.
The Menu page: the main menu's items and a live preview.

4. Assets: fonts, bitmaps and the palette

Seven fixed-width fonts are built in. Your own come in as BDF files or PNG glyph sheets, and bitmaps the same way. Every glyph you keep costs ROM, which the budget on the Project page counts.

The Assets page with the built-in fonts and how many elements use each.
The Assets page with the built-in fonts and how many elements use each.

5. Export: the module and its testbench

The Export page shows the resource estimate, a block diagram of the module and every port before you write anything. The export itself, the RTL and the self-checking testbench, is a licensed feature; write to me for a trial.

The Export page: resource estimates and a preview of the module.
The Export page: resource estimates and a preview of the module.

What's coming next

Two follow-ups are on the way:

  • What it costs in an FPGA. Typical resource use for a few common overlay designs, from a couple of readouts to a full menu, taken from Yosys synthesis of the exported RTL.
  • On a real board. The generated module verified live on an FPGA, in a real video path driving a monitor.

Subscribe to the RSS feed to get them when they are out.

Working on something similar?

Write with what you are building; a short answer usually comes back the same day.