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

Subversion Repositories i2cslave

[/] [i2cslave/] [trunk/] [rtl/] [registerInterface.v] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sfielding
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// registerInterface.v                                          ////
4
////                                                              ////
5
//// This file is part of the i2cSlave opencores effort.
6
//// <http://www.opencores.org/cores//>                           ////
7
////                                                              ////
8
//// Module Description:                                          ////
9
//// You will need to modify this file to implement your 
10
//// interface.
11
//// Add your control and status bytes/bits to module inputs and outputs,
12
//// and also to the I2C read and write process blocks  
13
////                                                              ////
14
//// To Do:                                                       ////
15
//// 
16
////                                                              ////
17
//// Author(s):                                                   ////
18
//// - Steve Fielding, sfielding@base2designs.com                 ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
////                                                              ////
22
//// Copyright (C) 2008 Steve Fielding and OPENCORES.ORG          ////
23
////                                                              ////
24
//// This source file may be used and distributed without         ////
25
//// restriction provided that this copyright statement is not    ////
26
//// removed from the file and that any derivative work contains  ////
27
//// the original copyright notice and the associated disclaimer. ////
28
////                                                              ////
29
//// This source file is free software; you can redistribute it   ////
30
//// and/or modify it under the terms of the GNU Lesser General   ////
31
//// Public License as published by the Free Software Foundation; ////
32
//// either version 2.1 of the License, or (at your option) any   ////
33
//// later version.                                               ////
34
////                                                              ////
35
//// This source is distributed in the hope that it will be       ////
36
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
37
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
38
//// PURPOSE. See the GNU Lesser General Public License for more  ////
39
//// details.                                                     ////
40
////                                                              ////
41
//// You should have received a copy of the GNU Lesser General    ////
42
//// Public License along with this source; if not, download it   ////
43
//// from <http://www.opencores.org/lgpl.shtml>                   ////
44
////                                                              ////
45
//////////////////////////////////////////////////////////////////////
46
//
47
`include "i2cSlave_define.v"
48
 
49
 
50
module registerInterface (
51
  clk,
52
  addr,
53
  dataIn,
54
  writeEn,
55
  dataOut,
56
  myReg0,
57
  myReg1,
58
  myReg2,
59
  myReg3,
60
  myReg4,
61
  myReg5,
62
  myReg6,
63
  myReg7
64
 
65
);
66
input clk;
67
input [7:0] addr;
68
input [7:0] dataIn;
69
input writeEn;
70
output [7:0] dataOut;
71
output [7:0] myReg0;
72
output [7:0] myReg1;
73
output [7:0] myReg2;
74
output [7:0] myReg3;
75
input [7:0] myReg4;
76
input [7:0] myReg5;
77
input [7:0] myReg6;
78
input [7:0] myReg7;
79
 
80
reg [7:0] dataOut;
81
reg [7:0] myReg0;
82
reg [7:0] myReg1;
83
reg [7:0] myReg2;
84
reg [7:0] myReg3;
85
 
86
// --- I2C Read
87
always @(posedge clk) begin
88
  case (addr)
89
    8'h00: dataOut <= myReg0;
90
    8'h01: dataOut <= myReg1;
91
    8'h02: dataOut <= myReg2;
92
    8'h03: dataOut <= myReg3;
93
    8'h04: dataOut <= myReg4;
94
    8'h05: dataOut <= myReg5;
95
    8'h06: dataOut <= myReg6;
96
    8'h07: dataOut <= myReg7;
97
    default: dataOut <= 8'h00;
98
  endcase
99
end
100
 
101
// --- I2C Write
102
always @(posedge clk) begin
103
  if (writeEn == 1'b1) begin
104
    case (addr)
105
      8'h00: myReg0 <= dataIn;
106
      8'h01: myReg1 <= dataIn;
107
      8'h02: myReg2 <= dataIn;
108
      8'h03: myReg3 <= dataIn;
109
    endcase
110
  end
111
end
112
 
113
endmodule
114
 
115
 
116
 

powered by: WebSVN 2.1.0

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