Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LIBRARY IEEE;
- USE IEEE.std_logic_1164.ALL;
- USE IEEE.numeric_std.ALL;
- ENTITY gpio IS
- PORT (clk, reset : IN std_logic;
- bit21 : INOUT std_logic);
- END ENTITY gpio;
- ARCHITECTURE bhv OF gpio IS
- BEGIN
- PROCESS(clk,reset)
- VARIABLE shouldWrite : INTEGER;
- BEGIN
- shouldWrite := 1;
- -- MAIN LOOP
- IF falling_edge(clk) THEN
- IF bit21 = '0' THEN --Signal bit is off, no signal on all pins
- IF shouldWrite = 1 THEN --If the FPGA should be writing, go write
- -- WRITE LOOP (write to the io pins the value that needs to be send)
- -- END WRITE LOOP (note that the pins should be off when leaving this loop.
- shouldWrite := 0; -- We have written this loop, preventing next loop from writing
- END IF;
- ELSE --Signal is on, so pi is sending something
- IF shouldWrite = 0 THEN--shouldWrite = 0 means we have to read
- --READ LOOP (read the pins and store in the variables)
- --Note, when making a read loop, check if the last an current read are the same. If so, ignore the output
- --END READ LOOP
- shouldWrite := 1; -- we have read, so we need to write again
- END IF;
- END IF;
- -- CALCULATE LOOP (calculate using the variables), this loop cannot take too long, so dont have one big calc, but seperate it
- -- END CALCULATE LOOP
- END IF;
- END PROCESS;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement