VHDL state machines and clock [closed]

Usually in cases when you need to execute N repetitive actions in one state (like you described, waiting N ns, writting to N addresses.) it is often used a counter in it. Hope the following example may clarify it a bit:

process(clk, rst)
if (rst = '1') then
index <= 0; -- memory address
current_s <= write_memory ;
currentValue <= (others => '0');
elsif rising_edge(clk) then
   case curresnt_s is 
   when write_memory =>
      if index < ADDRESS_SIZE then
        index <= index + 1; 
        memory(index) <= currentValue;
        curresnt_s  <= done;
      end if;
   when done => null;
   end case;
end case;

In this code memory would be an array of std_logic_vector; You could use the same idea to wait for 100ns. if you know your clock runs at 10ns period, you could count to 10 in some state before changing to other.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top