Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

Found this peice of code to study.

Seeing it's semi-undocumented and the first peice of FPGA im trying to implement, I was wondering If anyone could share some pointers.

It's a MIDI input, so it basically takes 8 bit binary numbers and converts them to numerical values.

I have a question slashed out, maybe if someone would like to bare with me, it would be much appreciated. "it has been a steep couple of days" :)

10 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Your code is incomplete.

    The top-level design entity MIDI contains another component called UART. You need the code for that component too.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Do I need to initialise uart to get MIDI data from USB or MIDI connector? Or in other words can this be hacked to just grab the numbers, or is it really goint to work bidirectional or something? I did a quick search for sk synth rather than midi, and found this http://www.sk-electronics.com/svn/repos/sk-synth/trunk/vhdl/uart.vhdl

    But actually for just masking some values its a bit much code? Or how does it fit in?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Trying to understand how to interface to a MIDI interface by starting with some random piece of code you found on the internet is not going to help.

    I have not used the MIDI interface, but it looks like an interface with a standardized hardware interface, and a signalling protocol.

    To interface to an FPGA I/O pins, you need to determine whether you need logic-level translators. Once you have it interfaced to an FPGA, you need to review the timing diagrams for the protocol and determine whether the interface is synchronous or asynchronous. Once you have that information you can write a state machine for decoding the protocol, and then simulate it in Modelsim to confirm that it works. Once your simulation works, you can interface to a MIDI instrument, and use SignalTap II to trace the hardware interface signals to confirm that they operate like your simulation assumes.

    At that point you will have a functional MIDI interface.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    That was the plan to sort of mold it into submission. I can always hook it up to my usb midi controller.

    And then use leds to see if i have changed a parameter by counting it.

    As far as i know all it has to do is mask the binaries it gets via serial interface to show the stuff it finds by comparisson.

    "status-data byte". I can always shut the total process down if it has to interface to another application, or work past it.

    But do I even need the part that does the uart, using quartus for the pinouts?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I can always hook it up to my usb midi controller.

    --- Quote End ---

    I'd recommend starting with that. However, you need to be careful with how you connect your MIDI signals to the FPGA. If the MIDI logic level is incompatible with the FPGA logic level, then you could damage either interface. Eg., if MIDI uses 5V logic levels, then you need to ensure your FPGA can receive and generate 5V levels.

    Once you have the MIDI signals connected to the FPGA, you can generate MIDI commands on the PC-side of things, and use the FPGA SignalTap II logic analyzer to trace the MIDI traffic. You can then create a HDL model that generates those same waveforms and use it as the stimulus to develop a MIDI controller component (or to interface to the code you posted above).

    --- Quote Start ---

    But do I even need the part that does the uart, using quartus for the pinouts?

    --- Quote End ---

    I've no idea. If you do not understand the code, and you cannot compile the code, its not worth anyone's time.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I see, so much to learn.. Got sidetracked in learning VHDL for a bit, but the SignalTap looks promising :D

    About the 5v logic I need to look up indeed, you got me weery of the supposed usb ports, but I guess ittl be fine seeing theres a lot of care put into the layout of the board.

    "I shure hope all isnt lost, yust got started :)"
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I see, so much to learn.

    --- Quote End ---

    Yes, there's always new things to learn :)

    --- Quote Start ---

    Got sidetracked in learning VHDL for a bit

    --- Quote End ---

    You'll continue to need to learn VHDL. As you are learning, you need to understand that there are parts of the language designed for synthesis and other parts for use only in simulation.

    --- Quote Start ---

    but the SignalTap looks promising :D

    --- Quote End ---

    SignalTap is a useful tool. However, if you have not done your "homework" first and looked at the MIDI protocol, the captured traces will be meaningless. So you first need to find documentation on the MIDI protocol and its timing diagrams, and then you can use SignalTap II to trace how your USB-to-MIDI controller operates.

    --- Quote Start ---

    About the 5v logic I need to look up indeed, you got me weery of the supposed usb ports, but I guess ittl be fine seeing theres a lot of care put into the layout of the board.

    --- Quote End ---

    This doesn't make sense. Your comments above imply that you have a USB-to-MIDI adapter. If that is true, then you do not care about the USB-end of things, since the adapter already takes care of that. What you do care about, it the MIDI connector on the end, and how you plan on interfacing that to your FPGA.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    I see, so much to learn.. Got sidetracked in learning VHDL for a bit, but the SignalTap looks promising :D

    --- Quote End ---

    Just so you understand, signaltap is meant as a debug tool, not a verification tool. Verification should be done as much as possible in simulation. If you are designing with the intention to use signaltap, you need to re-assess your design goals.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    There website www.midi.org has further information and example schematics for old school MIDI interfaces. Looks like the input is a current loop into an optoisolater. The isolator output goes to a uart. As I recall the uart baud rate isn't one of the standard ones.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I have a breadboard with that circuit using a scrap pc900v optocoupler :). And then the standard midi leads connected.

    Was just looking to spark some life into the usb port and power it on the FPGA side. So ill start with that.