3
\$\begingroup\$

Writing a value to RAM is a small part of my project, everything is working, but I cannot explain one thing related to RAM/digital timing.

I will write a description in regards to picture I added.

  • macc_out goes to data_in of the RAM
  • address_ram is the address of the RAM cell
  • out_temp is the output of the RAM
  • write_en_ram is write_en of the RAM

As far as I had the idea of RAM, it writes straight on the rising edge of the clock. So data seen on data_in on the rising edge of clock will be written to the RAM. Even if data_in changes on the same clock as write_goes high, the the old data will be written. First case Then why in my case RAM writes -36 and not -10.

second Now I tried to change data_in value with a clock value (0/1) and now it does as it should do. What's happening? ram_in is data_in of RAM in this case.

macc_out == ram_in == data_in

\$\endgroup\$
2
  • 1
    \$\begingroup\$ "As far as I had the idea of RAM, it writes straight on the rising edge of the clock": This is not universal. It depends what you wrote in your code, so it would be very helpful to see your actual code. \$\endgroup\$
    – The Photon
    Mar 3, 2012 at 18:25
  • \$\begingroup\$ I am not near my code at the moment. But they all are combinational logic assignments. macc_out depends on counter's value, write_en_ram depends on state \$\endgroup\$ Mar 3, 2012 at 19:26

1 Answer 1

1
\$\begingroup\$

Since your clock signal isn't shown, I assume that it's related to the change in the other signals.

Based on that, the first one seems to work correctly in that the write only works on the rising edge of the clock and the logic high of the *write_en* signal. So, that's why you see the data only being written in one cycle after the enable signal goes high.

As for the second sim, seems like the clock signal is connected directly to the *ram_in* signal. This would explain it. The data is latched on the rising edge of the clock. In this case, the only data that is ever latched is 0. At the rising edge, the *ram_io* is always 0.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.