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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [rtl/] [verilog/] [periph/] [template_periph_16b.v] - Blame information for rev 103

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 olivier.gi
//----------------------------------------------------------------------------
2
// Copyright (C) 2001 Authors
3
//
4 66 olivier.gi
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions
6
// are met:
7
//     * Redistributions of source code must retain the above copyright
8
//       notice, this list of conditions and the following disclaimer.
9
//     * Redistributions in binary form must reproduce the above copyright
10
//       notice, this list of conditions and the following disclaimer in the
11
//       documentation and/or other materials provided with the distribution.
12
//     * Neither the name of the authors nor the names of its contributors
13
//       may be used to endorse or promote products derived from this software
14
//       without specific prior written permission.
15 2 olivier.gi
//
16 66 olivier.gi
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26
// THE POSSIBILITY OF SUCH DAMAGE
27 2 olivier.gi
//
28
//----------------------------------------------------------------------------
29
//
30
// *File Name: template_periph_16b.v
31
// 
32
// *Module Description:
33
//                       16 bit peripheral template.
34
//
35
// *Author(s):
36
//              - Olivier Girard,    olgirard@gmail.com
37
//
38
//----------------------------------------------------------------------------
39 17 olivier.gi
// $Rev: 103 $
40
// $LastChangedBy: olivier.girard $
41
// $LastChangedDate: 2011-03-05 15:44:48 +0100 (Sat, 05 Mar 2011) $
42
//----------------------------------------------------------------------------
43 103 olivier.gi
`ifdef OMSP_NO_INCLUDE
44
`else
45 23 olivier.gi
`include "openMSP430_defines.v"
46 103 olivier.gi
`endif
47 2 olivier.gi
 
48
module  template_periph_16b (
49
 
50
// OUTPUTs
51
    per_dout,                       // Peripheral data output
52
 
53
// INPUTs
54
    mclk,                           // Main system clock
55
    per_addr,                       // Peripheral address
56
    per_din,                        // Peripheral data input
57
    per_en,                         // Peripheral enable (high active)
58
    per_wen,                        // Peripheral write enable (high active)
59
    puc                             // Main system reset
60
);
61
 
62
// OUTPUTs
63
//=========
64
output       [15:0] per_dout;       // Peripheral data output
65
 
66
// INPUTs
67
//=========
68
input               mclk;           // Main system clock
69
input         [7:0] per_addr;       // Peripheral address
70
input        [15:0] per_din;        // Peripheral data input
71
input               per_en;         // Peripheral enable (high active)
72
input         [1:0] per_wen;        // Peripheral write enable (high active)
73
input               puc;            // Main system reset
74
 
75
 
76
//=============================================================================
77
// 1)  PARAMETER DECLARATION
78
//=============================================================================
79
 
80
// Register addresses
81
parameter           CNTRL1     = 9'h190;
82
parameter           CNTRL2     = 9'h192;
83
parameter           CNTRL3     = 9'h194;
84
parameter           CNTRL4     = 9'h196;
85
 
86
 
87
// Register one-hot decoder
88
parameter           CNTRL1_D   = (512'h1 << CNTRL1);
89
parameter           CNTRL2_D   = (512'h1 << CNTRL2);
90
parameter           CNTRL3_D   = (512'h1 << CNTRL3);
91
parameter           CNTRL4_D   = (512'h1 << CNTRL4);
92
 
93
 
94
//============================================================================
95
// 2)  REGISTER DECODER
96
//============================================================================
97
 
98
// Register address decode
99
reg  [511:0]  reg_dec;
100
always @(per_addr)
101
  case ({per_addr,1'b0})
102
    CNTRL1 :     reg_dec  =  CNTRL1_D;
103
    CNTRL2 :     reg_dec  =  CNTRL2_D;
104
    CNTRL3 :     reg_dec  =  CNTRL3_D;
105
    CNTRL4 :     reg_dec  =  CNTRL4_D;
106
    default:     reg_dec  =  {512{1'b0}};
107
  endcase
108
 
109
// Read/Write probes
110
wire         reg_write =  |per_wen   & per_en;
111
wire         reg_read  = ~|per_wen   & per_en;
112
 
113
// Read/Write vectors
114
wire [511:0] reg_wr    = reg_dec & {512{reg_write}};
115
wire [511:0] reg_rd    = reg_dec & {512{reg_read}};
116
 
117
 
118
//============================================================================
119
// 3) REGISTERS
120
//============================================================================
121
 
122
// CNTRL1 Register
123
//-----------------   
124
reg  [15:0] cntrl1;
125
 
126
wire        cntrl1_wr = reg_wr[CNTRL1];
127
 
128
always @ (posedge mclk or posedge puc)
129
  if (puc)            cntrl1 <=  16'h0000;
130
  else if (cntrl1_wr) cntrl1 <=  per_din;
131
 
132
 
133
// CNTRL2 Register
134
//-----------------   
135
reg  [15:0] cntrl2;
136
 
137
wire        cntrl2_wr = reg_wr[CNTRL2];
138
 
139
always @ (posedge mclk or posedge puc)
140
  if (puc)            cntrl2 <=  16'h0000;
141
  else if (cntrl2_wr) cntrl2 <=  per_din;
142
 
143
 
144
// CNTRL3 Register
145
//-----------------   
146
reg  [15:0] cntrl3;
147
 
148
wire        cntrl3_wr = reg_wr[CNTRL3];
149
 
150
always @ (posedge mclk or posedge puc)
151
  if (puc)            cntrl3 <=  16'h0000;
152
  else if (cntrl3_wr) cntrl3 <=  per_din;
153
 
154
 
155
// CNTRL4 Register
156
//-----------------   
157
reg  [15:0] cntrl4;
158
 
159
wire        cntrl4_wr = reg_wr[CNTRL4];
160
 
161
always @ (posedge mclk or posedge puc)
162
  if (puc)            cntrl4 <=  16'h0000;
163
  else if (cntrl4_wr) cntrl4 <=  per_din;
164
 
165
 
166
//============================================================================
167
// 4) DATA OUTPUT GENERATION
168
//============================================================================
169
 
170
// Data output mux
171
wire [15:0] cntrl1_rd  = cntrl1  & {16{reg_rd[CNTRL1]}};
172
wire [15:0] cntrl2_rd  = cntrl2  & {16{reg_rd[CNTRL2]}};
173
wire [15:0] cntrl3_rd  = cntrl3  & {16{reg_rd[CNTRL3]}};
174
wire [15:0] cntrl4_rd  = cntrl4  & {16{reg_rd[CNTRL4]}};
175
 
176
wire [15:0] per_dout   =  cntrl1_rd  |
177
                          cntrl2_rd  |
178
                          cntrl3_rd  |
179
                          cntrl4_rd;
180
 
181
 
182
endmodule // template_periph_16b
183
 
184 103 olivier.gi
`ifdef OMSP_NO_INCLUDE
185
`else
186 33 olivier.gi
`include "openMSP430_undefines.v"
187 103 olivier.gi
`endif

powered by: WebSVN 2.1.0

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