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

Subversion Repositories ahb2wishbone

[/] [ahb2wishbone/] [trunk/] [src/] [ahb2wb.v] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 toomuch
 
2
// Copyright (c) 2007 TooMuch Semiconductor Solutions Pvt Ltd.
3
 
4
 
5
//File name             :       ahb2wb.v
6
//Designer              :       Manish Agarwal
7
//Date                  :       18 May, 2007
8
//Description   :       AHB WISHBONE BRIDGE :- This design will connect AHB master interface with Wishbone slave.
9
//                                      This design will perform only single read-write operation.
10
//Revision              :       1.0
11
 
12
 
13
//******************************************************************************************************
14
 
15
`timescale 1 ns/1 ns
16
 
17
module ahb2wb(
18
        adr_o, dat_o, dat_i, ack_i, cyc_o,
19
        we_o, stb_o, hclk, hresetn, haddr, htrans, hwrite, hsize, hburst,
20
        hsel, hwdata, hrdata, hresp, hready, clk_i, rst_i
21
        );
22
 
23
 
24
//parameter declaration
25
        parameter AWIDTH = 16;
26
        parameter DWIDTH = 32;
27
 
28
 
29
//**************************************
30
// input ports
31
//**************************************
32
 
33
 //wishbone ports               
34
        input [DWIDTH-1:0]dat_i;                                         // data input from wishbone slave
35
        input ack_i;                                                                    // acknowledment from wishbone slave
36
        input clk_i;
37
        input rst_i;
38
 
39
 //AHB ports    
40
        input hclk;                                                                     // clock
41
        input hresetn;                                                                  // active low reset
42
        input [DWIDTH-1:0]hwdata;                                                // data bus             
43
        input hwrite;                                                                   // write/read enable
44
        input [2:0]hburst;                                                               // burst type
45
        input [2:0]hsize;                                                                // data size
46
        input [1:0]htrans;                                                               // type of transfer
47
        input hsel;                                                                             // slave select 
48
        input [AWIDTH-1:0]haddr;                                         // address bus  
49
 
50
 
51
//**************************************
52
// output ports
53
//**************************************
54
 
55
 //wishbone ports
56
        output [AWIDTH-1:0]adr_o;                                                // address to wishbone slave 
57
        output [DWIDTH-1:0]dat_o;                                                // data output for wishbone slave
58
        output cyc_o;                                                                   // signal to indicate valid bus cycle
59
        output we_o;                                                                    // write enable
60
        output stb_o;                                                                   // strobe to indicate valid data transfer cycle
61
 
62
 
63
 // AHB ports
64
        output [DWIDTH-1:0]hrdata;                                               // data output for wishbone slave
65
        output [1:0]hresp;                                                               // response signal from slave
66
        output hready;                                                                  // slave ready
67
 
68
 
69
//**************************************
70
// inout ports
71
//**************************************
72
 
73
 
74
//**********************************************************************************
75
 
76
 
77
// datatype declaration
78
        reg [DWIDTH-1:0]hrdata;
79
        reg hready;
80
        reg [1:0]hresp;
81
        reg stb_o;
82
        wire we_o;
83
        reg cyc_o;
84
        wire [AWIDTH-1:0]adr_o;
85
        reg [DWIDTH-1:0]dat_o;
86
 
87
// local memory registers
88
        reg [AWIDTH-1 : 0]addr_temp;
89
        reg hwrite_temp;                                                                // to hold write enable signal temporarily
90
 
91
//*******************************************************************
92
// AHB WISHBONE BRIDGE logic
93
//*******************************************************************
94
 
95
        assign #2 we_o = hwrite_temp;
96
        assign #2 adr_o = addr_temp;
97
 
98
        always @ (posedge hclk ) begin
99
                if (!hresetn) begin
100
                        hresp  <= 2'b00;
101
                        cyc_o <= 'b0;
102
                        stb_o <= 'b0;
103 5 toomuch
                        addr_temp <= 'bx;
104
                        hwrite_temp <= 'bx;
105
                        dat_o <='bx;
106 2 toomuch
                end
107
                else if(hready & hsel) begin
108
                        case (hburst)
109
                                // single transfer
110
                                3'b000  :       begin
111
                                                                case (htrans)
112
                                                                        // idle transfer type
113
                                                                        2'b00 : begin
114
                                                                                                cyc_o <= 'b0;
115
                                                                                                hresp <= 2'b00;                 // ok response
116
                                                                                                stb_o <= 'b0;
117
 
118
                                                                                        end
119
 
120
                                                                        // busy transfer type
121
                                                                        2'b01 : begin
122
                                                                                                hresp <= 2'b00;                 // ok response
123
                                                                                                stb_o <= 'b0;
124
                                                                                                cyc_o <= 'b1;
125
                                                                                        end
126
 
127
                                                                        // Non-Sequential
128
                                                                        2'b10 : begin
129
                                                                                                cyc_o <= 'b1;
130
                                                                                                stb_o <= 'b1;
131
                                                                                                addr_temp <= haddr;
132
                                                                                                hwrite_temp <= hwrite;                  // control signal stored that was received in address phase
133
                                                                                        end
134
                                                                endcase
135
                                                        end
136
 
137
                                default :       cyc_o <= 'b0;
138
                        endcase
139
                end
140
                else if (!hsel & hready) begin
141
                        cyc_o <= 'b0;                                   //invalid bus transfer
142
                end
143
 
144
        end
145
 
146
 
147
// combinational logic - asynchronous read/write
148
        always@(hwrite_temp or hwdata or dat_i or ack_i or hresetn or stb_o ) begin
149
 
150
                if (!hresetn) begin
151 5 toomuch
                        hready <= 'b1;
152 2 toomuch
                end
153
                else begin
154
                        if (stb_o)
155
                                hready = ack_i;
156
 
157
                        if ( hwrite_temp )
158
                                dat_o = hwdata;
159
                        else if (!hwrite_temp)
160
                                hrdata = dat_i;
161
                end
162
 
163
        end
164
 
165
endmodule
166
 
167
 

powered by: WebSVN 2.1.0

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