Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. LIBRARY IEEE;
  2. USE IEEE.std_logic_1164.ALL;
  3. USE IEEE.numeric_std.ALL;
  4. ENTITY gpio IS
  5. PORT (clk, reset : IN std_logic;
  6. bit21 : INOUT std_logic);
  7. END ENTITY gpio;
  8. ARCHITECTURE bhv OF gpio IS
  9. BEGIN
  10.  
  11. PROCESS(clk,reset)
  12. VARIABLE shouldWrite : INTEGER;
  13. BEGIN
  14. shouldWrite := 1;
  15.  
  16. -- MAIN LOOP
  17. IF falling_edge(clk) THEN
  18. IF bit21 = '0' THEN --Signal bit is off, no signal on all pins
  19. IF shouldWrite = 1 THEN --If the FPGA should be writing, go write
  20. -- WRITE LOOP (write to the io pins the value that needs to be send)
  21.  
  22.  
  23.  
  24. -- END WRITE LOOP (note that the pins should be off when leaving this loop.
  25. shouldWrite := 0; -- We have written this loop, preventing next loop from writing
  26. END IF;
  27. ELSE --Signal is on, so pi is sending something
  28. IF shouldWrite = 0 THEN--shouldWrite = 0 means we have to read
  29. --READ LOOP (read the pins and store in the variables)
  30. --Note, when making a read loop, check if the last an current read are the same. If so, ignore the output
  31.  
  32.  
  33.  
  34. --END READ LOOP
  35. shouldWrite := 1; -- we have read, so we need to write again
  36. END IF;
  37. END IF;
  38. -- CALCULATE LOOP (calculate using the variables), this loop cannot take too long, so dont have one big calc, but seperate it
  39.  
  40.  
  41.  
  42. -- END CALCULATE LOOP
  43.  
  44. END IF;
  45. END PROCESS;
  46.  
  47. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement