source: PlatformSupport/CustomPeripherals/pcores/eeprom_v1_07_a/hdl/verilog/one_wire_io.v

Last change on this file was 1166, checked in by murphpo, 15 years ago

adding updated EEPROM core/driver with better clocking

File size: 4.3 KB
Line 
1//--------------------------------------------------------------------------
2//                                                                        --
3//  OneWireMaster                                                         --
4//   A synthesizable 1-wire master peripheral                             --
5//   Copyright 1999-2005 Dallas Semiconductor Corporation                 --
6//                                                                        --
7//--------------------------------------------------------------------------
8//                                                                        --
9//  Purpose:  Provides timing and control of Dallas 1-wire bus            --
10//            through a memory-mapped peripheral                          --
11//  File:     one_wire_io.v                                               --
12//  Date:     February 1, 2005                                            --
13//  Version:  v2.100                                                      --
14//  Authors:  Rick Downs and Charles Hill,                                --
15//            Dallas Semiconductor Corporation                            --
16//                                                                        --
17//  Note:     This source code is available for use without license.      --
18//            Dallas Semiconductor is not responsible for the             --
19//            functionality or utility of this product.                   --
20//                                                                        --
21//  Rev:      Significant changes to improve synthesis - English          --
22//            Ported to Verilog - Sandelin                                --
23//--------------------------------------------------------------------------
24
25module one_wire_io (
26  CLK, DDIR, DOUT, DQ_CONTROL, MR, DIN, DQ_IN, DATA_IN, DATA_OUT, 
27  DQ0_T, DQ1_T, DQ2_T, DQ3_T, DQ4_T, DQ5_T, DQ6_T, DQ7_T, 
28  DQ0_O, DQ1_O, DQ2_O, DQ3_O, DQ4_O, DQ5_O, DQ6_O, DQ7_O, 
29  DQ0_I, DQ1_I, DQ2_I, DQ3_I, DQ4_I, DQ5_I, DQ6_I, DQ7_I, DQ_SEL);
30
31  input        CLK;
32  input        DDIR;
33  input [7:0]  DOUT;
34  input        DQ_CONTROL;
35  input        MR;
36
37  output [7:0] DIN;
38  output       DQ_IN;
39   
40  input [7:0]  DATA_IN;
41  output [7:0] DATA_OUT;
42
43  output DQ0_T;
44  output DQ1_T;
45  output DQ2_T;
46  output DQ3_T;
47  output DQ4_T;
48  output DQ5_T;
49  output DQ6_T;
50  output DQ7_T;
51 
52  output DQ0_O;
53  output DQ1_O;
54  output DQ2_O;
55  output DQ3_O;
56  output DQ4_O;
57  output DQ5_O;
58  output DQ6_O;
59  output DQ7_O;
60 
61  input  DQ0_I;
62  input  DQ1_I;
63  input  DQ2_I;
64  input  DQ3_I;
65  input  DQ4_I;
66  input  DQ5_I;
67  input  DQ6_I;
68  input  DQ7_I;
69 
70  input  [2:0] DQ_SEL;
71   
72  reg         DQ_IN; 
73 
74  assign DATA_OUT = DOUT;
75  assign DIN      = DATA_IN;
76
77//assign DQ =DQ_CONTROL==1?1'bz:1'b0;
78
79  wire DQ_INTERNAL;
80
81//  IOBUF xIOBUF(
82//               .T  (DQ_CONTROL ),
83//               .I  (1'b0       ),
84//               .O  (DQ_INTERNAL),
85//               .IO (DQ         )
86//              );
87//  assign DQ_T = DQ_CONTROL;
88//  assign DQ_O = 1'b0;
89//  assign DQ_INTERNAL = DQ_I;
90
91   assign DQ0_T    = (DQ_SEL [2:0] == 0) ? DQ_CONTROL : 1'b1;
92   assign DQ1_T    = (DQ_SEL [2:0] == 1) ? DQ_CONTROL : 1'b1;
93   assign DQ2_T    = (DQ_SEL [2:0] == 2) ? DQ_CONTROL : 1'b1;
94   assign DQ3_T    = (DQ_SEL [2:0] == 3) ? DQ_CONTROL : 1'b1;
95   assign DQ4_T    = (DQ_SEL [2:0] == 4) ? DQ_CONTROL : 1'b1;
96   assign DQ5_T    = (DQ_SEL [2:0] == 5) ? DQ_CONTROL : 1'b1;
97   assign DQ6_T    = (DQ_SEL [2:0] == 6) ? DQ_CONTROL : 1'b1;
98   assign DQ7_T    = (DQ_SEL [2:0] == 7) ? DQ_CONTROL : 1'b1;
99
100   assign DQ0_O  = 1'b0;
101   assign DQ1_O  = 1'b0;
102   assign DQ2_O  = 1'b0;
103   assign DQ3_O  = 1'b0;
104   assign DQ4_O  = 1'b0;
105   assign DQ5_O  = 1'b0;
106   assign DQ6_O  = 1'b0;
107   assign DQ7_O  = 1'b0;
108
109   assign DQ_INTERNAL = (DQ_SEL [2:0] == 0) & DQ0_I
110                      | (DQ_SEL [2:0] == 1) & DQ1_I
111                      | (DQ_SEL [2:0] == 2) & DQ2_I
112                      | (DQ_SEL [2:0] == 3) & DQ3_I
113                      | (DQ_SEL [2:0] == 4) & DQ4_I
114                      | (DQ_SEL [2:0] == 5) & DQ5_I
115                      | (DQ_SEL [2:0] == 6) & DQ6_I
116                      | (DQ_SEL [2:0] == 7) & DQ7_I;
117
118  //
119  // Synchronize DQ_IN
120  //
121  always @(posedge MR or negedge CLK)
122    if (MR)
123      DQ_IN <= 1'b1;
124    else
125      DQ_IN <= DQ_INTERNAL;
126endmodule // one_wire_io
Note: See TracBrowser for help on using the repository browser.