1
\$\begingroup\$

I need to read data from a SRAM in one step (something like READ_RAM(addr) that returns the value stored in the SRAM at the "addr" address). Is it possible create a function/procedure that integrates a Finite State Machine?

\$\endgroup\$
1
\$\begingroup\$

A FSM is a sequential piece of circuitry, and functions are combinational only, so a function cannot represent by itself a FSM. However, the combinational paths of the FSM can be represented with functions. Typical examples are coding the next state or the outputs based on the current state and inputs. It is a very clean way of coding a FSM.

A procedure, on the other hand, can contain sequential statements, but when they do they are mostly used for testbenches using wait statements, which are not synthesizable.

\$\endgroup\$
  • \$\begingroup\$ I have also created a SRAM controller entity but the controller needs signal like Memory Request and after the start of the reading I need to wait X clock cycles before the data is available. How can I wait that the reading is ended? \$\endgroup\$ – Oceanic815 May 29 '13 at 17:21
  • \$\begingroup\$ There are many ways to do this. If your latency is constant, after starting the read then have a counter count up to X (or X-1), and when it reaches this value grab the data output by your SRAM controller. If the latency is not constant, the controller must have some kind of validdata signal that you can poll. \$\endgroup\$ – apalopohapa May 29 '13 at 17:29
  • \$\begingroup\$ I have a MemReady signal but how can I wait on this signal? The WAIT statement cannot be synthesized and the READ_RAM operations are executed in a process so I can't use a clock counter variable. \$\endgroup\$ – Oceanic815 May 29 '13 at 17:35
  • \$\begingroup\$ You can use a FSM (coded as a process). When you are waiting for MemReady you enter a state, call it something like st_waitingForMemReady, and to get out of that state you check the value of MemReady. Something like if MemReady = '1' then next_state <= st_doneReading; end if; \$\endgroup\$ – apalopohapa May 29 '13 at 17:40
  • \$\begingroup\$ The problem is that I can't exit from the current clock cycle of the process without that I have read the RAM. If I exit from this clock cycle I lose the current pixel and pass to the next. \$\endgroup\$ – Oceanic815 May 29 '13 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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