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

Subversion Repositories pit

[/] [pit/] [trunk/] [rtl/] [verilog/] [pit_wb_bus.v] - Blame information for rev 9

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 - Bus interface
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_wb_bus #(parameter ARST_LVL = 1'b0,    // asynchronous reset level
40
                    parameter DWIDTH = 16)
41
  (
42
  // Wishbone Signals
43
  output reg  [DWIDTH-1:0] wb_dat_o,     // databus output
44
  output reg               wb_ack_o,     // bus cycle acknowledge output
45
  input                    wb_clk_i,     // master clock input
46
  input                    wb_rst_i,     // synchronous active high reset
47
  input                    arst_i,       // asynchronous reset
48
  input             [ 2:0] wb_adr_i,     // lower address bits
49
  input       [DWIDTH-1:0] wb_dat_i,     // databus input
50
  input                    wb_we_i,      // write enable input
51
  input                    wb_stb_i,     // stobe/core select signal
52
  input                    wb_cyc_i,     // valid bus cycle input
53
  input              [1:0] wb_sel_i,     // Select byte in word bus transaction
54
  // PIT Control Signals
55
  output reg        [ 3:0] write_regs,   // Decode write control register
56
  output                   async_rst_b,  //
57
  output                   sync_reset,   //
58
  input                    irq_source,   //
59
  input             [47:0] read_regs     // status register bits
60
  );
61
 
62
 
63
  // registers
64
 
65
  // Wires
66
  wire   eight_bit_bus;
67
 
68
  //
69
  // module body
70
  //
71
 
72
  // generate internal resets
73
  assign eight_bit_bus = (DWIDTH == 8);
74
 
75
  assign async_rst_b = arst_i ^ ARST_LVL;
76
  assign sync_reset = wb_rst_i;
77
 
78
  // generate wishbone signals
79 9 rehayes
  wire wb_wacc = wb_cyc_i & wb_stb_i & wb_we_i & wb_ack_o;
80 2 rehayes
 
81
  // generate acknowledge output signal
82
  always @(posedge wb_clk_i)
83
    wb_ack_o <=  wb_cyc_i & wb_stb_i & ~wb_ack_o; // because timing is always honored
84
 
85
  // assign data read bus -- DAT_O
86
  always @(posedge wb_clk_i)
87
    case ({eight_bit_bus, wb_adr_i}) // synopsys parallel_case
88
      // 8 bit Bus, 8 bit Granularity
89
      4'b1_000: wb_dat_o <= read_regs[ 7: 0];  // 8 bit read address 0
90
      4'b1_001: wb_dat_o <= read_regs[15: 8];  // 8 bit read address 1
91
      4'b1_010: wb_dat_o <= read_regs[23:16];  // 8 bit read address 2
92
      4'b1_011: wb_dat_o <= read_regs[31:24];  // 8 bit read address 3
93
      4'b1_100: wb_dat_o <= read_regs[39:32];  // 8 bit read address 4
94
      4'b1_101: wb_dat_o <= read_regs[47:40];  // 8 bit read address 5
95
      // 16 bit Bus, 16 bit Granularity
96
      4'b0_000: wb_dat_o <= read_regs[15: 0];  // 16 bit read access address 0
97
      4'b0_001: wb_dat_o <= read_regs[31:16];
98
      4'b0_010: wb_dat_o <= read_regs[47:32];
99
    endcase
100
 
101
  // generate wishbone write register strobes -- one hot if 8 bit bus
102
  always @*
103
    begin
104
      write_regs = 0;
105
      if (wb_wacc)
106
        case ({eight_bit_bus, wb_adr_i}) // synopsys parallel_case
107
           // 8 bit Bus, 8 bit Granularity
108
           4'b1_000 : write_regs = 4'b0001;
109
           4'b1_001 : write_regs = 4'b0010;
110
           4'b1_010 : write_regs = 4'b0100;
111
           4'b1_011 : write_regs = 4'b1000;
112
           // 16 bit Bus, 16 bit Granularity
113
           4'b0_000 : write_regs = 4'b0011;
114
           4'b0_001 : write_regs = 4'b1100;
115
           default: ;
116
        endcase
117
    end
118
 
119
 
120
endmodule  // pit_wb_bus

powered by: WebSVN 2.1.0

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