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

Subversion Repositories pit

[/] [pit/] [trunk/] [rtl/] [sys_verilog/] [pit_top.sv] - Blame information for rev 21

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

Line No. Rev Author Line
1 21 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) 2011, 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  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 SINGLE_CYCLE = 1'b0,  // No bus wait state added
45
                 parameter DWIDTH = 16)          // Data bus width
46
  (
47
  // Wishbone Signals
48
  output [DWIDTH-1:0] wb_dat_o,     // databus output
49
  output              wb_ack_o,     // bus cycle acknowledge output
50
  input               wb_clk_i,     // master clock input
51
  input               wb_rst_i,     // synchronous active high reset
52
  input               arst_i,       // asynchronous reset
53
  input         [2:0] wb_adr_i,     // lower address bits
54
  input  [DWIDTH-1:0] wb_dat_i,     // databus input
55
  input               wb_we_i,      // write enable input
56
  input               wb_stb_i,     // stobe/core select signal
57
  input               wb_cyc_i,     // valid bus cycle input
58
  input         [1:0] wb_sel_i,     // Select byte in word bus transaction
59
  // PIT IO Signals
60
  output              pit_o,        // PIT output pulse
61
  output              pit_irq_o,    // PIT interrupt request signal output
62
  output              cnt_flag_o,   // PIT Flag Out
63
  output              cnt_sync_o,   // PIT Master Enable for Slave PIT's
64
  input               ext_sync_i    // Counter enable from Master PIT
65
  );
66
 
67
  logic [COUNT_SIZE-1:0] mod_value;     // Main Counter Modulo
68
  logic [COUNT_SIZE-1:0] cnt_n;         // PIT Counter Value
69
  logic                  async_rst_b;   // Asyncronous reset
70
  logic                  sync_reset;    // Syncronous reset
71
  logic           [ 3:0] write_regs;    // Control register write strobes
72
  logic                  prescale_out;  //
73
  logic                  pit_flg_clr;   // Clear PIT Rollover Status Bit
74
  logic                  pit_slave;     // PIT in Slave Mode, ext_sync_i selected
75
  logic           [ 3:0] pit_pre_scl;   // Prescaler modulo
76
  logic                  counter_sync;  //
77
 
78
  // Wishbone Bus interface
79
  pit_wb_bus #(.ARST_LVL(ARST_LVL),
80
               .SINGLE_CYCLE(SINGLE_CYCLE),
81
               .DWIDTH(DWIDTH))
82
    wishbone(*,
83
    .irq_source   ( cnt_flag_o ),
84
    .read_regs    (               // in  -- status register bits
85
                   { cnt_n,
86
                     mod_value,
87
                     {pit_slave, DECADE_CNTR, NO_PRESCALE, 1'b0, pit_pre_scl,
88
                      5'b0, cnt_flag_o, pit_ien, cnt_sync_o}
89
                   }
90
                  )
91
  );
92
 
93
// -----------------------------------------------------------------------------
94
  pit_regs #(.ARST_LVL(ARST_LVL),
95
             .COUNT_SIZE(COUNT_SIZE),
96
             .NO_PRESCALE(NO_PRESCALE),
97
             .DWIDTH(DWIDTH))
98
    regs(*,
99
    .bus_clk      ( wb_clk_i ),
100
    .write_bus    ( wb_dat_i )
101
  );
102
 
103
// -----------------------------------------------------------------------------
104
  pit_prescale #(.COUNT_SIZE(PRE_COUNT_SIZE),
105
                 .DECADE_CNTR(DECADE_CNTR),
106
                 .NO_PRESCALE(NO_PRESCALE))
107
    prescale(*,
108
    .bus_clk      ( wb_clk_i ),
109
    .divisor      ( pit_pre_scl )
110
  );
111
 
112
// -----------------------------------------------------------------------------
113
  pit_count #(.COUNT_SIZE(COUNT_SIZE))
114
    counter(*,
115
    .bus_clk      ( wb_clk_i )
116
  );
117
 
118
endmodule // pit_top

powered by: WebSVN 2.1.0

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