Forum Discussion

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

ROM outputting values incorrectly

Hello,

I am working on a project for my Electrical and Computer Engineering class at my college. I am supposed to save the patterns to make each number from 0 to 255 display on 7-segment displays into a ROM. (For example, the pattern for 136 would be 11111001 10110000 10000011, where the first bit is just a placeholder, and the rest of the bits are for segments 6-0 of a 7-segment display).

I have inputted all patterns into a .mif file and checked that they are the proper patterns for each input. I have run simulations to make sure everything is working as intended and outputs for all numbers are correct. However, it seems that the output for each input is behind one (as in, if I input 1, the pattern outputted is what is intended for 0).

I am not sure what's going wrong. If anyone has an idea, please help.

My class uses version 9.1 sp2.

3 Replies

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

    You should post some code.

    Probably it's only a matter of reading the data out of ROM before latching to the 7-seg registers.

    If you do it on the same clock edge, you'd latch on the display the previous data.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you inferred the ROM from HDL code, it can be expected to behave exactly as described in the code.

    If it's a ROM MegaFunction, please consider that addresses are registered on rising edge of the clock. Data output will either appear shortly after the new address takes effect (unregistered mode) after the next clock edge (registered mode). Check the MegaFunction settings for output registering.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    If it's a ROM MegaFunction, please consider that addresses are registered on rising edge of the clock. Data output will either appear shortly after the new address takes effect (unregistered mode) after the next clock edge (registered mode).

    --- Quote End ---

    Thank you, FvM! Since we set the MegaFunction to be registered for the output, I messed around with the clock's frequency in simulations and realized it was doing just what you were describing. I imagine once I can test it on hardware everything will be set. Thanks again!