




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 焊工安全知识培训课件书
- 2025年事业单位工勤技能-广东-广东铸造工五级(初级工)历年参考题库含答案解析
- 2025年事业单位工勤技能-广东-广东汽车驾驶与维修员一级(高级技师)历年参考题库含答案解析
- 2025年事业单位工勤技能-安徽-安徽水文勘测工二级(技师)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-北京-北京兽医防治员五级(初级工)历年参考题库含答案解析
- 烹调基础知识培训总结课件
- 2025年职业技能鉴定-铁路职业技能鉴定-铁路职业技能鉴定(铁路连结员)初级历年参考题库含答案解析(5套)
- 2025年职业技能鉴定-石雕工-石雕工(高级技师)历年参考题库含答案解析(5套)
- 2025年职业技能鉴定-灭火救援专业士兵-灭火救援专业士兵(高级)历年参考题库含答案解析(5套)
- 2025年职业技能鉴定-劳动关系协调员-劳动关系协调员高级技师(一级)历年参考题库含答案解析(5套)
- (2025年标准)职工转岗协议书
- 2026年色彩流行趋势报告
- 2025年江苏劳动保障协理员招聘考试(劳动保障相关业务知识)历年参考题库含答案详解(5套)
- 电梯转让协议书范本
- 2025年火电电力职业技能鉴定考试-风力发电运行检修员历年参考题库含答案解析(5套典型题)
- 2025湖南省低空经济发展集团有限公司招聘12人(第二次)笔试参考题库附带答案详解(10套)
- 医患沟通技巧试题及答案
- 牛仔裤廓形趋势报告
- 年产2000吨电子级超高纯石英晶体材料制造项目环评报告表
- 2025重庆对外建设集团招聘41人笔试参考题库附带答案详解(10套)
- 2025年秋季开学第一次全体教师大会上校长讲话-:想为、敢为、勤为、善为
评论
0/150
提交评论