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

Subversion Repositories can

[/] [can/] [tags/] [initial/] [rtl/] [verilog/] [can_registers.v] - Blame information for rev 161

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  can_registers.v                                             ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the CAN Protocal Controller            ////
7
////  http://www.opencores.org/projects/can/                      ////
8
////                                                              ////
9
////                                                              ////
10
////  Author(s):                                                  ////
11
////       Igor Mohor                                             ////
12
////       igorm@opencores.org                                    ////
13
////                                                              ////
14
////                                                              ////
15
////  All additional information is avaliable in the README.txt   ////
16
////  file.                                                       ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2002 Authors                                   ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE.  See the GNU Lesser General Public License for more ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
// CVS Revision History
46
//
47
// $Log: not supported by cvs2svn $
48
//
49
//
50
 
51
// synopsys translate_off
52
`include "timescale.v"
53
// synopsys translate_on
54
`include "can_defines.v"
55
 
56
module can_registers
57
(
58
  clk,
59
  rst,
60
  cs,
61
  rw,
62
  addr,
63
  data_in,
64
  data_out,
65
 
66
  /* Mode register */
67
  reset_mode,
68
  listen_only_mode,
69
  acceptance_filter_mode,
70
  sleep_mode,
71
 
72
  /* Bus Timing 0 register */
73
  baud_r_presc,
74
  sync_jump_width,
75
 
76
  /* Bus Timing 1 register */
77
  time_segment1,
78
  time_segment2,
79
  triple_sampling
80
 
81
);
82
 
83
parameter Tp = 1;
84
 
85
input         clk;
86
input         rst;
87
input         cs;
88
input         rw;
89
input   [7:0] addr;
90
input   [7:0] data_in;
91
 
92
output  [7:0] data_out;
93
reg     [7:0] data_out;
94
 
95
/* Mode register */
96
output        reset_mode;
97
output        listen_only_mode;
98
output        acceptance_filter_mode;
99
output        sleep_mode;
100
 
101
/* Bus Timing 0 register */
102
output  [5:0] baud_r_presc;
103
output  [1:0] sync_jump_width;
104
 
105
 
106
/* Bus Timing 1 register */
107
output  [3:0] time_segment1;
108
output  [2:0] time_segment2;
109
output        triple_sampling;
110
 
111
 
112
wire we_mode          = cs & (~rw) & (addr == 8'h0);
113
wire we_bus_timing_0  = cs & (~rw) & (addr == 8'h6) & reset_mode;
114
wire we_bus_timing_1  = cs & (~rw) & (addr == 8'h7) & reset_mode;
115
 
116
wire read = cs & rw;
117
 
118
/* Mode register */
119
wire   [7:0] mode;
120
can_register_asyn #(8, 8'h1) MODE_REG
121
( .data_in(data_in),
122
  .data_out(mode),
123
  .we(we_mode),
124
  .clk(clk),
125
  .rst(rst)
126
);
127
 
128
assign reset_mode = mode[0];
129
assign listen_only_mode = mode[1];
130
assign acceptance_filter_mode = mode[3];
131
assign sleep_mode = mode[4];
132
/* End Mode register */
133
 
134
 
135
/* Bus Timing 0 register */
136
wire   [7:0] bus_timing_0;
137
can_register #(8) BUS_TIMING_0_REG
138
( .data_in(data_in),
139
  .data_out(bus_timing_0),
140
  .we(we_bus_timing_0),
141
  .clk(clk)
142
);
143
 
144
assign baud_r_presc = bus_timing_0[5:0];
145
assign sync_jump_width = bus_timing_0[7:6];
146
/* End Bus Timing 0 register */
147
 
148
 
149
/* Bus Timing 1 register */
150
wire   [7:0] bus_timing_1;
151
can_register #(8) BUS_TIMING_1_REG
152
( .data_in(data_in),
153
  .data_out(bus_timing_1),
154
  .we(we_bus_timing_1),
155
  .clk(clk)
156
);
157
 
158
assign time_segment1 = bus_timing_1[3:0];
159
assign time_segment2 = bus_timing_1[6:4];
160
assign triple_sampling = bus_timing_1[7];
161
/* End Bus Timing 1 register */
162
 
163
 
164
 
165
 
166
 
167
 
168
 
169
 
170
 
171
 
172
 
173
 
174
 
175
// Reading data from registers
176
always @ ( addr or read or mode or bus_timing_0 or bus_timing_1
177
         )
178
begin
179
  if(read)  // read
180
    begin
181
      case(addr)
182
        8'h0  :  data_out <= mode;
183
        8'h6  :  data_out <= bus_timing_0;
184
        8'h7  :  data_out <= bus_timing_1;
185
 
186
        default: data_out <= 8'h0;
187
      endcase
188
    end
189
  else
190
    data_out <= 8'h0;
191
end
192
 
193
 
194
 
195
 
196
 
197
/*
198
module can_register
199
( data_in,
200
  data_out,
201
  we,
202
  clk,
203
  rst,
204
  rst_sync
205
);
206
 
207
parameter WIDTH = 8; // default parameter of the register width
208
parameter RESET_VALUE = 0;
209
*/
210
 
211
endmodule

powered by: WebSVN 2.1.0

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