Forum Discussion

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

Modelsim to look at i2c data

I want to view the i2c data being sent to the DE2 boards audio CODEC. I have a few files that have been generated from SOPC builder eg slow clock, i2c controller, audio config.

I tried just generating 50MHz on the CLK signal (system) and running simulation whilst viewing i2c_sdat but got nothing.

I've followed the tutorial from the altera website and can successfully simulate basic logic designs ok but it doesn't go any further than that.

Any tips?

6 Replies

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

    --- Quote Start ---

    I'm guessing i'd create a trigger from the ack... i'll have a look

    --- Quote End ---

    You'll want to add the I2C SCL and SDA to your signal tap as signals, and then use a faster clock, eg., 10MHz to capture multiple samples per bit period.

    You'll have to tweak things a little, eg., lets say you have a 100kHz I2C clock and you want to capture 20 periods, that's 20/100kHz = 200us. Sampling this at 10MHz produces 2000 samples for each bit in your signal tap entry. Since you're observing two signals, you need about 4k of sample RAM.

    If your design does not contain a 10MHz clock, you can use a PLL to create one from say the 50MHz oscillator on your design. Or, if you have plenty of on-chip RAM, just use the 50MHz directly.

    Cheers,

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

    --- Quote Start ---

    I want to view the i2c data being sent to the DE2 boards audio CODEC. I have a few files that have been generated from SOPC builder eg slow clock, i2c controller, audio config.

    I tried just generating 50MHz on the CLK signal (system) and running simulation whilst viewing i2c_sdat but got nothing.

    --- Quote End ---

    A simulation only does what you ask, so did you ...

    1) Have some logic to generate an I2C transaction, eg., a NIOS processor with a program that performs an I2C read or write, or an Avalon-MM BFM that accesses the I2C control registers?

    2) Do you have an I2C slave that acts like the CODEC? At a minimum, something that will generate an I2C ACK so that the I2C controller is fooled into thinking there is a device on the I2C bus.

    It might sound like a lot of work to setup your first simulation, and it can be, but once you have it working, simulating new components is a lot faster. So, take the time now and learn how. Ask questions when you get stuck and you'll get help.

    Cheers,

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

    Dave, thanks for your reply.

    Maybe its a little more involved than i thought but i dont see why it should be.

    I already have the program performing an i2c write (to initialise the codec) and it all works fine on the de2 board. What would be the best way then to view the serial i2c data?

    Can i just generate the ack by drawing in the waveform?

    I really dont expect to get this handed to me on a plate but i'm quite stuck on where to start.

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

    --- Quote Start ---

    I already have the program performing an i2c write (to initialise the codec) and it all works fine on the de2 board. What would be the best way then to view the serial i2c data?

    --- Quote End ---

    To view the I2C data on the hardware, you can read the I2C parallel data register. Of course, if that's not working, you might want to look at the serial data stream, and in that case, you can use the SignalTap II logic analyzer (it gets embedded inside the FPGA).

    --- Quote Start ---

    Can i just generate the ack by drawing in the waveform?

    --- Quote End ---

    It depends what you want out of your simulation. If I was simply interested in checking that an I2C controller worked, then a simple ACK would work fine. However, if you are trying to check a more complex communication sequence with an I2C device, then you need a model of the CODEC. I think in your case, just using SignalTap would be sufficient for you to see what is going on.

    Cheers,

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

    Thanks, thats cleared a few things up. Yeah i simply just want to view what the controller is writing for educational purposes and to put in my report.

    Signaltap looks great. I'm guessing i'd create a trigger from the ack... i'll have a look

    cheers