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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [fpga/] [xilinx_diligent_s3board/] [rtl/] [verilog/] [openmsp430/] [periph/] [template_periph_16b.v] - Blame information for rev 28

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
// This source file may be used and distributed without restriction provided
5
// that this copyright statement is not removed from the file and that any
6
// derivative work contains the original copyright notice and the associated
7
// disclaimer.
8
//
9
// This source file is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU Lesser General Public License as published
11
// by the Free Software Foundation; either version 2.1 of the License, or
12
// (at your option) any later version.
13
//
14
// This source is distributed in the hope that it will be useful, but WITHOUT
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17
// License for more details.
18
//
19
// You should have received a copy of the GNU Lesser General Public License
20
// along with this source; if not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
//
23
//----------------------------------------------------------------------------
24
//
25
// *File Name: template_periph_16b.v
26
// 
27
// *Module Description:
28
//                       16 bit peripheral template.
29
//
30
// *Author(s):
31
//              - Olivier Girard,    olgirard@gmail.com
32
//
33
//----------------------------------------------------------------------------
34 17 olivier.gi
// $Rev: 23 $
35
// $LastChangedBy: olivier.girard $
36
// $LastChangedDate: 2009-08-30 18:39:26 +0200 (Sun, 30 Aug 2009) $
37
//----------------------------------------------------------------------------
38 23 olivier.gi
`include "timescale.v"
39
`include "openMSP430_defines.v"
40 2 olivier.gi
 
41
module  template_periph_16b (
42
 
43
// OUTPUTs
44
    per_dout,                       // Peripheral data output
45
 
46
// INPUTs
47
    mclk,                           // Main system clock
48
    per_addr,                       // Peripheral address
49
    per_din,                        // Peripheral data input
50
    per_en,                         // Peripheral enable (high active)
51
    per_wen,                        // Peripheral write enable (high active)
52
    puc                             // Main system reset
53
);
54
 
55
// OUTPUTs
56
//=========
57
output       [15:0] per_dout;       // Peripheral data output
58
 
59
// INPUTs
60
//=========
61
input               mclk;           // Main system clock
62
input         [7:0] per_addr;       // Peripheral address
63
input        [15:0] per_din;        // Peripheral data input
64
input               per_en;         // Peripheral enable (high active)
65
input         [1:0] per_wen;        // Peripheral write enable (high active)
66
input               puc;            // Main system reset
67
 
68
 
69
//=============================================================================
70
// 1)  PARAMETER DECLARATION
71
//=============================================================================
72
 
73
// Register addresses
74
parameter           CNTRL1     = 9'h190;
75
parameter           CNTRL2     = 9'h192;
76
parameter           CNTRL3     = 9'h194;
77
parameter           CNTRL4     = 9'h196;
78
 
79
 
80
// Register one-hot decoder
81
parameter           CNTRL1_D   = (512'h1 << CNTRL1);
82
parameter           CNTRL2_D   = (512'h1 << CNTRL2);
83
parameter           CNTRL3_D   = (512'h1 << CNTRL3);
84
parameter           CNTRL4_D   = (512'h1 << CNTRL4);
85
 
86
 
87
//============================================================================
88
// 2)  REGISTER DECODER
89
//============================================================================
90
 
91
// Register address decode
92
reg  [511:0]  reg_dec;
93
always @(per_addr)
94
  case ({per_addr,1'b0})
95
    CNTRL1 :     reg_dec  =  CNTRL1_D;
96
    CNTRL2 :     reg_dec  =  CNTRL2_D;
97
    CNTRL3 :     reg_dec  =  CNTRL3_D;
98
    CNTRL4 :     reg_dec  =  CNTRL4_D;
99
    default:     reg_dec  =  {512{1'b0}};
100
  endcase
101
 
102
// Read/Write probes
103
wire         reg_write =  |per_wen   & per_en;
104
wire         reg_read  = ~|per_wen   & per_en;
105
 
106
// Read/Write vectors
107
wire [511:0] reg_wr    = reg_dec & {512{reg_write}};
108
wire [511:0] reg_rd    = reg_dec & {512{reg_read}};
109
 
110
 
111
//============================================================================
112
// 3) REGISTERS
113
//============================================================================
114
 
115
// CNTRL1 Register
116
//-----------------   
117
reg  [15:0] cntrl1;
118
 
119
wire        cntrl1_wr = reg_wr[CNTRL1];
120
 
121
always @ (posedge mclk or posedge puc)
122
  if (puc)            cntrl1 <=  16'h0000;
123
  else if (cntrl1_wr) cntrl1 <=  per_din;
124
 
125
 
126
// CNTRL2 Register
127
//-----------------   
128
reg  [15:0] cntrl2;
129
 
130
wire        cntrl2_wr = reg_wr[CNTRL2];
131
 
132
always @ (posedge mclk or posedge puc)
133
  if (puc)            cntrl2 <=  16'h0000;
134
  else if (cntrl2_wr) cntrl2 <=  per_din;
135
 
136
 
137
// CNTRL3 Register
138
//-----------------   
139
reg  [15:0] cntrl3;
140
 
141
wire        cntrl3_wr = reg_wr[CNTRL3];
142
 
143
always @ (posedge mclk or posedge puc)
144
  if (puc)            cntrl3 <=  16'h0000;
145
  else if (cntrl3_wr) cntrl3 <=  per_din;
146
 
147
 
148
// CNTRL4 Register
149
//-----------------   
150
reg  [15:0] cntrl4;
151
 
152
wire        cntrl4_wr = reg_wr[CNTRL4];
153
 
154
always @ (posedge mclk or posedge puc)
155
  if (puc)            cntrl4 <=  16'h0000;
156
  else if (cntrl4_wr) cntrl4 <=  per_din;
157
 
158
 
159
//============================================================================
160
// 4) DATA OUTPUT GENERATION
161
//============================================================================
162
 
163
// Data output mux
164
wire [15:0] cntrl1_rd  = cntrl1  & {16{reg_rd[CNTRL1]}};
165
wire [15:0] cntrl2_rd  = cntrl2  & {16{reg_rd[CNTRL2]}};
166
wire [15:0] cntrl3_rd  = cntrl3  & {16{reg_rd[CNTRL3]}};
167
wire [15:0] cntrl4_rd  = cntrl4  & {16{reg_rd[CNTRL4]}};
168
 
169
wire [15:0] per_dout   =  cntrl1_rd  |
170
                          cntrl2_rd  |
171
                          cntrl3_rd  |
172
                          cntrl4_rd;
173
 
174
 
175
endmodule // template_periph_16b
176
 
177
 
178
 
179
 
180
 
181
 

powered by: WebSVN 2.1.0

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