Since quartus demands many files for compiling a project, all the project files are available for download in a zip file. All the files you'll need to compile & program are there.
Since the software for this project won't fit all on one page I'll only explain the main keyboard entity & architecture. If you have any lasting questions about the software just go to the forums and ask!
The Keyboard Input Entity
Below is the entire code for accepting generic keyboard input. Two handshaking signals, scan_code and read exist so that characters are not read twice.
------------« Begin Code »------------
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.all; USE IEEE.STD_LOGIC_ARITH.all; USE IEEE.STD_LOGIC_UNSIGNED.all; ENTITY key IS PORT( keyboard_clk, keyboard_data, clock_25Mhz , reset, read : IN STD_LOGIC; scan_code : OUT STD_LOGIC_VECTOR(7 DOWNTO 0); scan_ready : OUT STD_LOGIC); END key; ARCHITECTURE a OF key IS ... .... ..... BEGIN PROCESS (read, ready_set) BEGIN IF read = '1' THEN scan_ready <= '0'; ELSIF ready_set'EVENT and ready_set = '1' THEN scan_ready <= '1'; END IF; END PROCESS; ... .... ..... PROCESS BEGIN WAIT UNTIL (KEYBOARD_CLK_filtered'EVENT AND KEYBOARD_CLK_filtered='1'); IF RESET='1' THEN INCNT <= "0000"; READ_CHAR <= '0'; ELSE IF KEYBOARD_DATA='0' AND READ_CHAR='0' THEN READ_CHAR<= '1'; ready_set<= '0'; ELSE -- Shift in next 8 data bits to assemble a scan code IF READ_CHAR = '1' THEN IF INCNT < "1001" THEN -- If less than 9-bits keep shifting in data from keyboard INCNT <= INCNT + 1; SHIFTIN(7 DOWNTO 0) <= SHIFTIN(8 DOWNTO 1); SHIFTIN(8) <= KEYBOARD_DATA; ready_set <= '0'; -- End of scan code character, so set flags and exit loop ELSE scan_code <= SHIFTIN(7 DOWNTO 0); READ_CHAR <='0'; ready_set <= '1'; INCNT <= "0000"; END IF; END IF; END IF; END IF; END PROCESS; END a;
------------« End Code »------------
The Keyboard SoftwareA lot of the code was skipped over but you can download the entire project above in the zip. Only the important parts of the code are shown above. The entity, the handshaking process & the process that gets the serial data input. The last process is the most important to understand to see how character input really works with keyboards. Again, the entire project is available for download, so I highly recommend just opening that up and looking through what was done.