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_rx.v] - Diff between revs 2 and 4

Show entire file | Details | Blame | View Log

Rev 2 Rev 4
Line 42... Line 42...
module ps2_host_rx(
module ps2_host_rx(
  input  wire sys_clk,
  input  wire sys_clk,
  input  wire sys_rst,
  input  wire sys_rst,
  input  wire ps2_clk_negedge,
  input  wire ps2_clk_negedge,
  input  wire ps2_data,
  input  wire ps2_data,
  output wire [7:0] rx_data,
  output reg [7:0] rx_data,
  output wire ready,
  output reg ready,
  output wire error
  output reg error
);
);
 
 
// Read in 11 bit long frame. 12th bit marks end of frame.
// Read in 11 bit long frame.
reg [11:0] frame;
reg [11:0] frame;
always @(posedge sys_clk)
always @(posedge sys_clk)
begin
begin
  if (sys_rst | ready) begin
  if (sys_rst | ready) begin
    frame <= 1;
    frame <= 1;
Line 59... Line 59...
  else begin
  else begin
    frame <= (ps2_clk_negedge) ? {frame[10:0], ps2_data} : frame;
    frame <= (ps2_clk_negedge) ? {frame[10:0], ps2_data} : frame;
  end
  end
end
end
 
 
// Return rx_data in most significant bit first order.
 
assign rx_data = {frame[2], frame[3], frame[4], frame[5],
 
                  frame[6], frame[7], frame[8], frame[9]};
 
 
 
// 12th bit marks end of frame.
// 12th bit marks end of frame.
assign ready = frame[11];
always @(posedge sys_clk)
 
begin
 
  ready <= (sys_rst) ? 0 : frame[11];
 
end
 
 
 
// Return rx_data in most significant bit first order.
 
always @(posedge sys_clk)
 
begin
 
  if (sys_rst) begin
 
    rx_data <= 0;
 
  end
 
  else begin
 
    rx_data <= (frame[11]) ? {frame[2], frame[3], frame[4], frame[5],
 
                              frame[6], frame[7], frame[8], frame[9]} : rx_data;
 
  end
 
end
 
 
// Check that 1st bit is 0, odd parity bit is correct and last bit is 1.
// Check that 1st bit is 0, odd parity bit is correct and last bit is 1.
assign error = ~(~frame[10] & (~frame[1] == ^frame[9:2]) & frame[0]);
always @(posedge sys_clk)
 
begin
 
  if (sys_rst) begin
 
    error <= 0;
 
  end
 
  else begin
 
    error <= (frame[11]) ? ~(~frame[10] & (~frame[1] == ^frame[9:2]) & frame[0]) : error;
 
  end
 
end
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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