OpenCores
URL https://opencores.org/ocsvn/ps2_host_controller/ps2_host_controller/trunk

Subversion Repositories ps2_host_controller

[/] [ps2_host_controller/] [trunk/] [hdl/] [ps2_host_tx.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tesla
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  ps2_host_tx.v                                               ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  Transmitter part, sending bits down the ps2_data line       ////
7
////                                                              ////
8
////  Author:                                                     ////
9
////      - Piotr Foltyn, piotr.foltyn@gmail.com                  ////
10
////                                                              ////
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2011 Author                                    ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
// synopsys translate_off
39
`include "timescale.v"
40
// synopsys translate_on
41
 
42
module ps2_host_tx(
43
  input  wire sys_clk,
44
  input  wire sys_rst,
45
  input  wire ps2_clk_posedge,
46
  inout  wire ps2_data,
47
  input  wire [7:0] tx_data,
48
  input  wire send_req,
49
  output wire busy
50
);
51
 
52
reg [11:0] frame;
53
wire frame_is_zero = ~|frame;
54
always @(posedge sys_clk)
55
begin
56
  if (sys_rst | (~send_req & frame_is_zero)) begin
57
    frame <= 0;
58
  end
59
  else if (frame_is_zero) begin
60
    frame <= {2'b00, tx_data[0], tx_data[1], tx_data[2], tx_data[3],
61
                     tx_data[4], tx_data[5], tx_data[6], tx_data[7], ~^tx_data, 1'b1};
62
  end
63
  else begin
64
    frame <= (ps2_clk_posedge) ? {frame[10:0], 1'b0} : frame;
65
  end
66
end
67
 
68
// Send data down the line.
69
assign ps2_data = ((~|frame[10:0]) | frame[0]) ? 1'bz : frame[11];
70
 
71
// Keep high until all bits transmitted and ACK received
72
assign busy = ~frame_is_zero;
73
 
74
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.