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

Subversion Repositories pit

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

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 24 rehayes
module pit_top #(parameter D_WIDTH = 16,
40
                 parameter ARST_LVL = 1'b0,      // asynchronous reset level
41
                 parameter SINGLE_CYCLE = 1'b0,  // Add a wait state to bus transcation
42 21 rehayes
                 parameter PRE_COUNT_SIZE = 15,  // Prescale Counter size
43
                 parameter COUNT_SIZE = 16,      // Main counter size
44
                 parameter DECADE_CNTR = 1'b1,   // Prescale rollover decode
45 24 rehayes
                 parameter NO_PRESCALE = 1'b0)   // Remove prescale function
46 21 rehayes
  (
47
  // Wishbone Signals
48 24 rehayes
  wishbone_if.slave          wb,        // Wishbone interface instance
49
  output logic [D_WIDTH-1:0] wb_dat_o,  // databus output - Pseudo Register
50
  output logic               wb_ack,    // bus cycle acknowledge output
51
  input  logic               wb_stb,    // stobe/core select signal
52 21 rehayes
  // PIT IO Signals
53
  output              pit_o,        // PIT output pulse
54
  output              pit_irq_o,    // PIT interrupt request signal output
55
  output              cnt_flag_o,   // PIT Flag Out
56
  output              cnt_sync_o,   // PIT Master Enable for Slave PIT's
57
  input               ext_sync_i    // Counter enable from Master PIT
58
  );
59
 
60
  logic [COUNT_SIZE-1:0] mod_value;     // Main Counter Modulo
61
  logic [COUNT_SIZE-1:0] cnt_n;         // PIT Counter Value
62
  logic                  async_rst_b;   // Asyncronous reset
63
  logic                  sync_reset;    // Syncronous reset
64
  logic           [ 3:0] write_regs;    // Control register write strobes
65
  logic                  prescale_out;  //
66
  logic                  pit_flg_clr;   // Clear PIT Rollover Status Bit
67
  logic                  pit_slave;     // PIT in Slave Mode, ext_sync_i selected
68
  logic           [ 3:0] pit_pre_scl;   // Prescaler modulo
69
  logic                  counter_sync;  //
70 22 rehayes
  logic                  pit_flag;      //
71 21 rehayes
 
72
  // Wishbone Bus interface
73 24 rehayes
  pit_wb_bus #(.ARST_LVL    (ARST_LVL),
74
               .D_WIDTH     (D_WIDTH))
75 22 rehayes
    wishbone(
76 24 rehayes
    // Wishbone Signals
77
    .wb           ( wb ),
78
    .wb_stb       ( wb_stb ),
79
    .wb_ack       ( wb_ack ),
80
    .irq_source   ( cnt_flag_o ),
81
    .read_regs    (               // in  -- status register bits
82
                   { cnt_n,
83
                     mod_value,
84
                     {pit_slave, DECADE_CNTR, NO_PRESCALE, 1'b0, pit_pre_scl,
85
                      5'b0, cnt_flag_o, pit_ien, cnt_sync_o}
86
                   }
87
                  ),
88 22 rehayes
    .*);
89 21 rehayes
 
90
// -----------------------------------------------------------------------------
91 24 rehayes
  pit_regs #(.COUNT_SIZE(COUNT_SIZE),
92 21 rehayes
             .NO_PRESCALE(NO_PRESCALE),
93 24 rehayes
             .D_WIDTH(D_WIDTH))
94 22 rehayes
    regs(
95 24 rehayes
      .bus_clk      ( wb.wb_clk ),
96
      .write_bus    ( wb.wb_dat ),
97 22 rehayes
      .*);
98 21 rehayes
 
99
// -----------------------------------------------------------------------------
100
  pit_prescale #(.COUNT_SIZE(PRE_COUNT_SIZE),
101
                 .DECADE_CNTR(DECADE_CNTR),
102
                 .NO_PRESCALE(NO_PRESCALE))
103 22 rehayes
    prescale(
104 24 rehayes
    .bus_clk      ( wb.wb_clk ),
105 22 rehayes
    .divisor      ( pit_pre_scl ),
106
    .*);
107 21 rehayes
 
108
// -----------------------------------------------------------------------------
109
  pit_count #(.COUNT_SIZE(COUNT_SIZE))
110 22 rehayes
    counter(
111 24 rehayes
    .bus_clk      ( wb.wb_clk ),
112 22 rehayes
    .*);
113 21 rehayes
 
114
endmodule // pit_top

powered by: WebSVN 2.1.0

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