Math device

This is the specification for the math device of the Bedrock computer system.

This document is aimed at people who are implementing the Bedrock system from scratch. For people who are learning about or writing program for the Bedrock system, the math device manual will generally be more useful.

Concepts

Cartesian point

The cartesian point is a pair of signed 16 bit coordinates representing a two-dimensional point in the cartesian coordinate system. The x coordinate represents the signed distance from the origin along the horizontal axis, and the y coordinate represents the signed distance from the origin along the vertical axis. The initial value of each coordinate is zero.

Polar point

The polar point is a pair of unsigned 16 bit coordinates representing a two-dimensional point in the polar coordinate system. The r coordinate represents the unsigned distance from the origin, and the t coordinate represents the angle anti-clockwise around the origin from the positive horizontal axis. The angle unit is 1/65536 of a full turn. The initial value of each coordinate is zero.

x operand

The x operand is the x coordinate of the cartesian point interpreted as an unsigned 16 bit value.

y operand

The y operand is the y coordinate of the cartesian point interpreted as an unsigned 16 bit value.

Ports

Port Name Description Read Write
0x20 x coordinate Horizontal coordinate.
0x21 grouped grouped
0x22 y coordinate Vertical coordinate.
0x23 grouped grouped
0x24 r coordinate Radial coordinate.
0x25 grouped grouped
0x26 t coordinate Angular coordinate.
0x27 grouped grouped
0x28 Product Product of multiplication.
0x29 grouped grouped
0x2A grouped grouped
0x2B grouped grouped
0x2C Quotient Quotient of division.
0x2D grouped grouped
0x2E Remainder Remainder of division.
0x2F grouped grouped

x coordinate

Reading from this port group will return the x coordinate of the polar point after conversion to the cartesian coordinate system. If the coordinate exceeds the range of a signed 16 bit integer, the value returned will be zero. The x coordinate is calculated by taking the signed floor of cos(\frac{2 \pi t}{65536}) \times r, where the cosine function takes an angle in radians.

Writing to this port group will set the x coordinate of the cartesian point to the value written.

y coordinate

Reading from this port group will return the y coordinate of the polar point after conversion to the cartesian coordinate system. If the coordinate exceeds the range of a signed 16 bit integer, the value returned will be zero. The y coordinate is calculated by taking the signed floor of sin(\frac{2 \pi t}{65536}) \times r, where the sine function takes an angle in radians.

Writing to this port group will set the y coordinate of the cartesian point to the value written.

r coordinate

Reading from this port group will return the r coordinate of the cartesian point after conversion to the polar coordinate system. The r coordinate is calculated by taking the unsigned floor of \sqrt{x^2 + y^2}.

Writing to this port group will set the r coordinate of the polar point to the value written.

t coordinate

Reading from this port group will return the t coordinate of the cartesian point after conversion to the polar coordinate system. The t coordinate is calculated by taking the unsigned floor of atan2(y,x) \times \frac{65536}{2\pi}.

Writing to this port group will set the t coordinate of the polar point to the value written.

Product

Reading from this port group will return the product of the multiplication of the x operand by the y operand.

Quotient

Reading from this port group will return the quotient of the division of the x operand by the y operand. If the y operand is zero, the value zero will be returned.

Remainder

Reading from this port group will return the remainder of the division of the x operand by the y operand. If the y operand is zero, the value zero will be returned.

Wake behaviour

This device will never send a wake request to the system device.