2.3.7 MIDI FSM
The midi
fsm module interprets incoming MIDI messages for Note On/Off events, and outputs the pitch
and velocity and pressed/depressed status of those events. The FSM receives bytes from the MIDI inter-
face serially via the byte line. When a new byte is ready the new
byte line should be driven high for a
single clock cycle. The FSM will ignore all MIDI events other than those which begin with the Note On
(0x9) or Note Off (0x8) nibble. The pitch and velocity bytes for these events follow from the serial line.
The pitch byte indicates which key on the keyboard was pressed, middle C being key 0x3C. The velocity
byte indicates how hard the key was pressed, with a “normal” key press being placed at 0x40. There are
other MIDI events which consist of multi byte frames similar to this. The MIDI FSM correctly ignores
the data bytes of unsupported MIDI events. The MIDI module also generates a pressed signal. A Note
Off event or Note On event with velocity zero will drive this line low, the line is driven high by a Note On
event with non-zero velocity. When a midi event has been processed, the FSM generates a single clock
cycle pulse on ready.
2.4 Note Control
The note control module manages note pressed and released events going to the Notes module for both the
keyboard playback and loop modes. The module exports the period, velocity and pressed status of a note
identified by the note
select bus to the notes module. The module drives the note ready line high when
the data is to be written. The finished note select line allows the notes module to identify a note, and then
indicate its availability to play new requests with a high or low signal on the finished line. Note control
contains a FIFO for handling incoming MIDI keyboard events. The FIFO is a Xilinx IP Core Syncronous
FIFO with a width of 17 (pitch,velocity and pressed) and a depth of 32. The note
control fsm handles
this FIFO to generate a keyboard
pitch, keyboard velocity, keyboard pressed and keyboard ready signal
for MIDI events. A small BRAM is used to provide a lookup table between the MIDI keyboard values
and the periods which notes expects. The keyboard
pitch combined with the pitch offset input is an index
into this rom, generating keyboard period. This FSM is also passed the finished note select and finished
wires to keep track of which notes are free. The FSM uses this information to correctly select notes
with the keyboard
note select and keyboard note select signals. A loop control fsm exists to control the
outputs when in loop mode. The module generates a parallel set of control signals, named loop pressed,
loop note select and loop note ready. The loop period and loop velocity are fixed at “Middle C” and the
“normal” velocity for MIDI of 0x40. The output of the note
control fsm and the loop control fsm are
multiplexed by the input signal loop.
2.4.1 Note Control FSM
The note
control fsm creates appropriate control signals destined for notes based on events arriving at
an external queue. When the external queue indicates it is no longer empty by pulling the queue
empty
line low, the FSM/Sequencer signals a pop by pulling queue pop high, then a clock cycle later latches
the output of the queue to the output lines period, velocity and pressed. If a key was just pressed, the
FSM enters a small sequencer to test if there are any notes available. The status of note availability
is being constantly updated into the finished
reg array. The input finished note select indexes into this
array, whose value is set to the input finished every clock cycle. The sequencer increments note
select
as another index into finished reg. If no finished notes are found, the FSM returns to testing for a non-
empty queue. If a note is found, the FSM stores the new period the note will be playing into the array
note
periods, then pulls note ready high. After this the FSM enters a sequencer to wait a configurable
number of new frame pulses before testing the queue again. If a key released event arrives, the FSM
follows an inverse process. The FSM enters a small sequencer to see if the period of the released key
matches any entry in note
period, which is also not finished in finished reg. If no note is found, the queue
10