发一个PS2接口的VHDL代码.doc_第1页
发一个PS2接口的VHDL代码.doc_第2页
发一个PS2接口的VHDL代码.doc_第3页
发一个PS2接口的VHDL代码.doc_第4页
发一个PS2接口的VHDL代码.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

发一个PS2接口的VHDL代码贴子发表于:2008/11/16 17:05:47- Hi Emacs, this is -*- mode: vhdl -*- Unidirectional PS2 InteRFace (device - host)- For connect mouse/keyboard- The PS/2 mouse and keyboard implement a bidirectional synchronous serial - protocol. The bus is idle when both lines are high (open-collector). - THIS A *UNIDIRECTIONAL* INTERFACE (DEVICE - HOST)- Javier Valcarce Garc韆, - $Id$-library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;use work.utils.all;entity interface_ps2 is port ( reset : in std_logic; clk : in std_logic; - faster than kbclk kbdata : in std_logic; kbclk : in std_logic; newdata : out std_logic; - one clock cycle pulse, notify a new byte has arrived do : out std_logic_vector(7 downto 0) );end interface_ps2;-architecture behavioral of interface_ps2 is signal st : std_logic; signal sh : std_logic; signal s1 : std_logic; signal s2 : std_logic; signal kbclk_fe : std_logic; signal shift9 : std_logic_vector(8 downto 0); signal error : std_logic; begin- Edge detector- process (reset, clk) begin if reset = 1 then s1 = 0; s2 = 0; elsif rising_edge(clk) then s2 = s1; s1 = kbclk; end if; end process; kbclk_fe = 1 when s1 = 0 and s2 = 1 else 0;- 9-bit shift register to store received data - 11-bit frame, LSB first: 1 start bit, 8 data bits, 1 parity bit, 1 stop bit- process (reset, clk) begin if reset = 1 then shift9 = 000000000; elsif rising_edge(clk) then if sh = 1 then shift9(7 downto 0) = shift9(8 downto 1); shift9(8) = kbdata; end if; end if; end process;- Output register- process (reset, clk) begin if reset = 1 then do = 00000000; elsif rising_edge(clk) then if st = 1 then do = shift9(7 downto 0); end if; end if; end process; - parity error detector (XOR gate) The parity bit is at shift9(8)- error = not (shift9(0) xor shift9(1) xor shift9(2) xor shift9(3) xor shift9(4) xor shift9(5) xor shift9(6) xor shift9(7) xor shift9(8);- Control Unit- CTL : block type state_type is (idle, start, bit_1a, bit_1b, bit_2a, bit_2b, bit_3a, bit_3b, bit_4a, bit_4b, bit_5a, bit_5b, bit_6a, bit_6b, bit_7a, bit_7b, bit_8a, bit_8b, bit_9a, bit_9b, stop, store, notify); signal state : state_type; signal op : std_logic_vector(2 downto 0); begin - 2 procesos para separar la parte secuencial de la combinacional, de - esta forma las salidas no son registros (registered outputs) y por - tanto no hay un ciclo de reloj de espera process (reset, clk) begin if reset = 1 then state if kbclk_fe = 1 and kbdata = 0 then state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then state state if kbclk_fe = 1 then if kbdata = 1 then state = stop; else state if error = 0 then state = store; else state state state = idle; end case; end if; end process;- 13 u髍denes para la ruta de datos:- Agrupamos todas las u髍denes en el vector op para que el c骴igo quede m醩- compacto y legible sh = op(2

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论