Wishbone Monitor Controller Accelerator

Description

Wishbone Monitor Controller Acclereator is a small address-generator which can (when used properly) fasten up various common video memory operations. The core is 100% Wishbone compatible with the WishboneTK extensions. It incorporates 2 Wishbone interfaces. A salve interface for accessing it's internal registers and to generating access cycles to the pixel memory and one master interface for the pixel memory. The data width on the two interfaces should be the same but address might not.

Accelerator functions

Many 8-bit systems has very limited address space. It's common that they can't access more than 64k of memory but often the available address spaces for video buffer is even much smaller. There are two ways to overcome this:

Both implementations are quite common in various places. For this core I'm planning to use the second approach with a little twist. You can imagine the indirect addressing of a frame buffer as having a cursor on it. Writes will overwrite values under the cursor and reads will return the value under the cursor. Writes to the index register will alter the cursor position, reads will return cursor location. That fits seamlessly to the way many algorithm thinks about the display. However there is one drawback: you need two accesses in average to reach a pixel. First you have to set the cursor position by writing the index register and then you can access the requested memory position. The first approach (Paging) excels in this. It can provide the same information at the same time.

The important thing is that while paging provides two type of information in one cycle (what and where) indirect addressing provides only one.

Many algorithms uses relative addressing which is quite time-consuming to implement in SW. they would say things like, write to the pixel to the left, or up; Go two rows down, etc. The accelerator part of the design will do such post-modification of the cursor automatically by HW. It will have a set of modify registers (a small bunch of RAM). It will also has a separate address space of (lets say) 256 locations, used for indirect frame-buffer access. A write operation on this address space will identify a post-modify register and provide the information to be written to the frame-buffer. After the write completes, the cursor location will be incremented/decremented by the value in the addressed post-modify register. Read operation can work the very same way only returning data instead of writing it to the frame-buffer.

Let's have an example! Let's say we would like to implement an algorithm of scrolling the screen up by one line. With direct access the code for that would be something like this:

   mov  R1, frame_buffer_addr
   mov  R2, frame_buffer_addr+xres/8
   mov  R3, frame_buffer_size-xres/8
loop:
   mov  R4,[R2]
   mov  [R1],R4
   inc  R1
   inc  R2
   dec  R3
   jnz  loop

The same thing with indirect addressing:

   mov  R1, 0
   mov  R2, xres/8
   mov  R3, frame_buffer_size-xres/8
loop:
   mov  [cursor_reg],R2
   mov  R4,[pixel_reg]
   mov  [cursor_reg],R3
   mov  [pixel_reg],R4
   inc  R1
   inc  R2
   dec  R3
   jnz  loop

And finally the same thing with the accelerator functions:

   mov  R1, -xres/8
   mov  [cursor_post_inc_reg1],R1
   mov  R1, 1+xres/8
   mov  [cursor_post_inc_reg2],R1
   mov  R1, frame_buffer_addr
   mov  [cursor_reg],R1
   mov  R2, frame_buffer_size-xres/8
loop:
   mov  R1,[cursor_post_inc_reg1] ; will modify cursor position to the upper byte
   mov  [cursor_post_inc_reg2],R2 ; will modify cursor position to the lower-right pixel
   dec  R2
   jnz  loop

As you can see for this particular algorithm this approach is faster than even the direct access method to the frame-buffer. Hence the pompous word, accelerator.

If you think about the most common functions you will find that this approach fastens at least the following operations

Of course there is a downside:

Programming information

As discussed above the accelerator maintains and updates a cursor register. That register is large enough to address all possible locations in the pixel memory, that is it has video_addr_width number of bits. This register can be read or written by asserting the cur_stb_i pin in a valid Wishbone cycle.

Each location in the accelerator memory functions as an increment value to the cursor. Thus each location has the same size as the cursor register itself. If data_width is less than video_addr_width such a location cannot be updated in one access. In that case the lower data_width bits of the location written or read directly form the data bus of the master Wishbone bus when the ACC_STB_I signal is asserted. The upper part of the location is written to/from the extension register. That register can be accessed by asserting the EXT_STB_I signal. Pixel memory accesses are performed upon the assertion of the MEM_STB_I signal. The accelerator location is selected by the address bits, the pixel memory location will be the current value of the cursor register, and the cursor register is updated with the value read from the accelerator location.

The accelerator has 2**accel_size locations.

Wishbone datasheet

DescriptionSpecification
General Description Monitor controller accelerator.
Supported cycles Slave read/write
Slave block read/write
Slave rmw
Master read/write
Master block read/write
Master rmw
Data port size Configurable on slave side, same on the master side
Data port granularity Bus size
Data port maximum operand size Bus size
Data transfer ordering Little endien
Data transfer sequencing n/a
Supported signal list and cross reference to equivalent Wishbone signals
Signal nameWishbone equiv.
Common signals for all ports
CLK_I CLK_I
RST_I RST_I
Signals to connect to master
CYC_I CYC_I
CUR_STB_I STB_I
EXT_STB_I STB_I
ACC_STB_I STB_I
MEM_STB_I STB_I
WE_I WE_I
ACK_O ACK_O
SEL_I(..) SEL_I()
ADR_I(..) ADR_I()
DAT_I(..) DAT_I()
DAT_O(..) DAT_O()
Signals to connect to the pixel memory
V_CYC_O CYC_O
V_STB_O STB_O
V_WE_O WE_O
V_ACK_I ACK_I
V_ADR_O(..) ADR_O()
v_SEL_o(..) SEL_O()
V_DAT_I(..) DAT_I()
V_DAT_O(..) DAT_O()

Parameter description

Parameter nameDescription
accel_size Address size of the accelerator memory
video_addr_width Address size of the pixel memory
data_width Data size of the interfaces

Signal description

Signal nameDescription
Signals to connect to master
CYC_I Wishbone cycle signal. High value frames blocks of access
CUR_STB_I Wishbone strobe signal. High value indicates cycle to the cursor register
EXT_STB_I Wishbone strobe signal. High value indicates cycle to the extension register
ACC_STB_I Wishbone strobe signal. High value indicates cycle to the accelerator memory
MEM_STB_I Wishbone strobe signal. High value indicates cycle to the pixel memory
WE_I Wishbone write enable signal. High indicates data flowing from master to slave
ACK_O Wishbone acknowledge signal. High indicates that slave finished operation sucessfully
ACK_OI WhisboneTK acknowledge chain input signal
ADR_I(accel_size-1..0) Wishbone address bus signals
SEL_I(data_width/8-1..0) Wishbone byte-selection signals
DAT_I(data_width-1..0) Wishbone data bus input (to slave direction) signals
DAT_O(data_width-1..0) Wishbone data bus output (to master direction) signals
DAT_OI(cpu_dat_width-1..0) WhisboneTK data bus chain input signal
Signals to connect to the pixel memory
V_CYC_O Wishbone cycle signal. High value frames blocks of access
V_STB_O Wishbone strobe signal. High value indicates cycle to this particular device
V_WE_O Wishbone write enable signal. High indicates data flowing from master to slave
V_ACK_I Wishbone acknowledge signal. High indicates that slave finished operation sucessfully
V_ADR_O(video_addr_width-2..0) Wishbone address bus signals
V_SEL_O(data_width/8-1..0) Wishbone byte-selection signals
V_DAT_I(data_width-1..0) Wishbone data bus input (to slave direction) signals
V_DAT_O(data_width-1..0) Wishbone data bus output (to master direction) signals

Author & Maintainer

Andras Tantos