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

Subversion Repositories pit

[/] [pit/] [trunk/] [rtl/] [verilog/] [pit_top.v] - Blame information for rev 4

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

Line No. Rev Author Line
1 2 rehayes
////////////////////////////////////////////////////////////////////////////////
2
//
3
//  WISHBONE revB.2 compliant Programable Interrupt Timer - Top-level
4
//
5
//  Author: Bob Hayes
6
//          rehayes@opencores.org
7
//
8
//  Downloaded from: http://www.opencores.org/projects/pit.....
9
//
10
////////////////////////////////////////////////////////////////////////////////
11
// Copyright (c) 2009, Robert Hayes
12
//
13
// All rights reserved.
14
//
15
// Redistribution and use in source and binary forms, with or without
16
// modification, are permitted provided that the following conditions are met:
17
//     * Redistributions of source code must retain the above copyright
18
//       notice, this list of conditions and the following disclaimer.
19
//     * Redistributions in binary form must reproduce the above copyright
20
//       notice, this list of conditions and the following disclaimer in the
21
//       documentation and/or other materials provided with the distribution.
22
//     * Neither the name of the <organization> nor the
23
//       names of its contributors may be used to endorse or promote products
24
//       derived from this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY Robert Hayes ''AS IS'' AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
// DISCLAIMED. IN NO EVENT SHALL Robert Hayes BE LIABLE FOR ANY
30
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
////////////////////////////////////////////////////////////////////////////////
37
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
38
 
39
module pit_top #(parameter ARST_LVL = 1'b0,      // asynchronous reset level
40
                 parameter PRE_COUNT_SIZE = 15,  // Prescale Counter size
41
                 parameter COUNT_SIZE = 16,      // Main counter size
42
                 parameter DECADE_CNTR = 1'b1,   // Prescale rollover decode
43
                 parameter NO_PRESCALE = 1'b0,   // Remove prescale function
44
                 parameter DWIDTH = 16)          // Data bus width
45
  (
46
  // Wishbone Signals
47
  output [DWIDTH-1:0] wb_dat_o,     // databus output
48
  output              wb_ack_o,     // bus cycle acknowledge output
49
  input               wb_clk_i,     // master clock input
50
  input               wb_rst_i,     // synchronous active high reset
51
  input               arst_i,       // asynchronous reset
52
  input         [2:0] wb_adr_i,     // lower address bits
53
  input  [DWIDTH-1:0] wb_dat_i,     // databus input
54
  input               wb_we_i,      // write enable input
55
  input               wb_stb_i,     // stobe/core select signal
56
  input               wb_cyc_i,     // valid bus cycle input
57
  input         [1:0] wb_sel_i,     // Select byte in word bus transaction
58
  // PIT IO Signals
59
  output              pit_o,        // PIT output pulse
60
  output              pit_irq_o,    // PIT interrupt request signal output
61
  output              cnt_flag_o,   // PIT Flag Out
62
  output              cnt_sync_o,   // PIT Master Enable for Slave PIT's
63
  input               ext_sync_i    // Counter enable from Master PIT
64
  );
65
 
66
  wire [COUNT_SIZE-1:0] mod_value;     // Main Counter Modulo
67
  wire [COUNT_SIZE-1:0] cnt_n;         // PIT Counter Value
68
  wire                  async_rst_b;   // Asyncronous reset
69
  wire                  sync_reset;    // Syncronous reset
70
  wire           [ 3:0] write_regs;    // Control register write strobes
71
  wire                  prescale_out;  //
72
  wire                  pit_flg_clr;   // Clear PIT Rollover Status Bit
73
  wire                  pit_slave;     // PIT in Slave Mode, ext_sync_i selected
74
  wire           [ 3:0] pit_pre_scl;   // Prescaler modulo
75
  wire                  counter_sync;  // 
76
 
77
  // Wishbone Bus interface
78
  pit_wb_bus #(.ARST_LVL(ARST_LVL),
79
               .DWIDTH(DWIDTH))
80
    wishbone(
81
    .wb_dat_o     ( wb_dat_o ),
82
    .wb_ack_o     ( wb_ack_o ),
83
    .wb_clk_i     ( wb_clk_i ),
84
    .wb_rst_i     ( wb_rst_i ),
85
    .arst_i       ( arst_i ),
86
    .wb_adr_i     ( wb_adr_i ),
87
    .wb_dat_i     ( wb_dat_i ),
88
    .wb_we_i      ( wb_we_i ),
89
    .wb_stb_i     ( wb_stb_i ),
90
    .wb_cyc_i     ( wb_cyc_i ),
91
    .wb_sel_i     ( wb_sel_i ),
92
 
93
    // outputs
94
    .write_regs   ( write_regs ),
95
    .sync_reset   ( sync_reset ),
96
    // inputs    
97
    .async_rst_b  ( async_rst_b ),
98
    .irq_source   ( cnt_flag_o ),
99
    .read_regs    (               // in  -- status register bits
100
                   { cnt_n,
101
                     mod_value,
102
                     {pit_slave, DECADE_CNTR, NO_PRESCALE, 1'b0, pit_pre_scl,
103
                      5'b0, cnt_flag_o, pit_ien, cnt_sync_o}
104
                   }
105
                  )
106
  );
107
 
108
// -----------------------------------------------------------------------------
109
  pit_regs #(.ARST_LVL(ARST_LVL),
110
             .COUNT_SIZE(COUNT_SIZE),
111
             .NO_PRESCALE(NO_PRESCALE),
112
             .DWIDTH(DWIDTH))
113
    regs(
114
    // outputs
115
    .mod_value    ( mod_value ),
116
    .pit_pre_scl  ( pit_pre_scl ),
117
    .pit_slave    ( pit_slave ),
118
    .pit_flg_clr  ( pit_flg_clr ),
119
    .pit_ien      ( pit_ien ),
120
    .cnt_sync_o   ( cnt_sync_o ),
121
    .pit_irq_o    ( pit_irq_o ),
122
    // inputs
123
    .async_rst_b  ( async_rst_b ),
124
    .sync_reset   ( sync_reset ),
125
    .bus_clk      ( wb_clk_i ),
126
    .write_bus    ( wb_dat_i ),
127
    .write_regs   ( write_regs ),
128
    .cnt_flag_o   ( cnt_flag_o )
129
  );
130
 
131
// -----------------------------------------------------------------------------
132
  pit_prescale #(.COUNT_SIZE(PRE_COUNT_SIZE),
133
                 .DECADE_CNTR(DECADE_CNTR),
134
                 .NO_PRESCALE(NO_PRESCALE))
135
    prescale(
136
    // outputs
137
    .prescale_out      ( prescale_out ),
138
    .counter_sync      ( counter_sync ),
139
    // inputs
140
    .async_rst_b       ( async_rst_b ),
141
    .sync_reset        ( sync_reset ),
142
    .bus_clk           ( wb_clk_i ),
143
    .cnt_sync_o        ( cnt_sync_o ),
144
    .ext_sync_i        ( ext_sync_i ),
145
    .pit_slave         ( pit_slave ),
146
    .divisor           ( pit_pre_scl )
147
  );
148
 
149
// -----------------------------------------------------------------------------
150
  pit_count #(.COUNT_SIZE(COUNT_SIZE))
151
    counter(
152
    // outputs
153
    .cnt_n             ( cnt_n ),
154
    .cnt_flag_o        ( cnt_flag_o ),
155
    .pit_o             ( pit_o ),
156
    // inputs
157
    .async_rst_b       ( async_rst_b ),
158
    .sync_reset        ( sync_reset ),
159
    .bus_clk           ( wb_clk_i ),
160
    .counter_sync      ( counter_sync ),
161
    .prescale_out      ( prescale_out ),
162
    .pit_flg_clr       ( pit_flg_clr ),
163
    .mod_value         ( mod_value )
164
  );
165
 
166
endmodule // pit_top

powered by: WebSVN 2.1.0

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