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

Subversion Repositories wisbone_2_ahb

[/] [wisbone_2_ahb/] [tags/] [t3/] [src/] [ahbmas_wbslv_top.v] - Blame information for rev 11

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             :       ahbmas_wbslv_top.v
6
//Designer              :       Ravi S Gupta
7
//Date                  :       23 May, 2007
8
//Description   :       Wishbone to AHB interface protocol converter
9
//Revision              :       1.0
10
 
11
 
12
//******************************************************************************************************
13
`timescale 1 ns / 1 ns
14
//DEFINES
15
//TOP MODULE
16
 
17
module AHBMAS_WBSLV_TOP (
18
 
19
  hclk,hresetn,
20
// AHB Master Interface (Connect to AHB Slave) 
21
  haddr,htrans,hwrite,hsize,
22
  hburst,hwdata,hrdata,hready,hresp,
23
 
24
// WISHBONE Slave Interface (Connect to WB Master)
25
  data_o, data_i, addr_i,clk_i,rst_i,
26
  cyc_i, stb_i, sel_i, we_i, ack_o
27
);
28
 
29
 
30
//PARAMETER
31
        parameter AWIDTH = 32,DWIDTH = 32;//Address Width,Data Width
32
 
33
//INPUTS AND OUTPUTS    
34
// --------------------------------------
35
//Top level ports for AHB 
36
input hresetn;           //AHB Clk 
37
input hclk;              //AHB Active Low Reset
38
 
39
// AHB Master Interface (Connect to AHB Slave)
40
input [DWIDTH-1:0]hrdata;                //Read data bus
41
 
42
//Transfer Response     from AHB Slave
43
input [1:0]hresp;
44
input hready;
45
 
46
//Address and Control Signals
47
output [AWIDTH-1:0]haddr;                //Address
48
output hwrite;                                  //Write/Read Control 
49
output [2:0]hsize;                               //Size of Data Control
50
output [2:0]hburst;                              //Burst Control
51
output [31:0]hwdata;                     //Write data bus
52
output [1:0]htrans;                              //Transfer type
53
 
54
 
55
// --------------------------------------
56
// WISHBONE Slave Interface (Connect to WB Master)
57
output  [DWIDTH-1:0]             data_o;   //Wishbobe Data Ouput
58
output                                  ack_o;     //Wishbone Acknowledge
59
 
60
input   [DWIDTH-1:0]             data_i;   //Wishbone Data Input
61
input   [AWIDTH-1:0]             addr_i;   //Wishbone Address Input
62
input                                   cyc_i;    //Wishbone Cycle Input
63
input                                   stb_i;     //Wishbone Strobe Input
64
input   [3:0]                    sel_i;     //Wishbone Selection Input
65
input                                   we_i;      //Wishbone Write/Read Control
66
input                                   clk_i;     //Wishbone Clk Input 
67
input                                   rst_i;     //Wishbone Active High Reset Input 
68
 
69
// datatype declaration
70
reg [AWIDTH-1:0]haddr;
71
wire hwrite;
72
reg [2:0]hsize;
73
reg [2:0]hburst;
74
reg [31:0]hwdata;
75
reg [1:0]htrans;
76
reg     [DWIDTH-1:0]data_o;
77
reg     ack_o;
78
 
79
//SIGNAL DECLARATIONS
80
        reg flag;
81
        reg hready_temp;
82
 
83
//*******************************************************************
84
// WISHBONE logic Write and Read Operation
85
//*******************************************************************
86
 
87
//ASSIGN STATEMENTS
88
assign #2 hwrite = we_i;
89
 
90
//Sysncronous Reset
91
always @ (posedge clk_i)
92
        begin
93
        //      hready_temp <= hready;
94
                if (rst_i) begin
95
                        hsize = 3'b010;         //Size of Data Control
96
                        hburst = 3'b000;                //Burst Control
97
                //      hready_temp <= 'b1;
98
                        flag <= 'b1;
99
                end
100
 
101
//Write Operation : Wait for a valid Cycle, Strobe and Active High Write enable signal
102
                else if (cyc_i & stb_i) begin
103
                                if (we_i) begin //Write Cycle: No Need To Check for hready signal for data to be send out
104
                                        hwdata <= data_i;
105
                                        end
106
//Read Operation : Wait for a valid Cycle, Strobe and Active Low Write enable signal
107
                        else begin              //      Read Cycle
108
                                if (hready) begin
109
                                        if(flag) begin
110
                                                flag <= #2 'b0;
111
                                                end
112
                                        else begin
113
                                                flag <= #2 'b1;
114
                                                end
115
                                end
116
 
117
                        end
118
                end
119
                //else begin
120
                //wb_ack_o<='b0;
121
                //hwdata <= data_i;//when stb goes active low send asyncronously the data
122
                //end
123
end
124
 
125
always @ (we_i or stb_i or addr_i or flag or hready or hrdata) begin
126
        if(we_i) begin
127
                if (hready) begin
128
                        haddr <= addr_i;
129
                end
130
        end
131
        else begin
132
                if (flag) begin
133
                        haddr <= addr_i;          //During Flag set Accept Address
134
                        end
135
                else begin
136
                        data_o <= #2 hrdata;      //During Flag reset Accept Data
137
                        end
138
        end
139
end
140
 
141
//Logic for Acknowledge from Wishbone Slave
142
always @(we_i or addr_i or hrdata or hready or flag )  begin
143
        if (rst_i) begin
144
                ack_o<='b0;
145
                end
146
        else if (we_i)
147
                ack_o <= hready;
148
        else
149
                ack_o<=!flag & hready;
150
        end
151
 
152
//Logic for Transfer Type 
153
always @(cyc_i or stb_i) begin
154
        if (rst_i) begin
155
                htrans<=2'b00;
156
                end
157
        else if (cyc_i) begin
158
                if (stb_i) begin
159
                        htrans <= 2'b10;        //Transfer type Non Sequential
160
                end
161
                else begin
162
                        htrans <= 2'b01;        //Transfer type Busy
163
                end
164
        end
165
        else begin
166
        htrans<=2'b00;  //Transfer type Idle 
167
        end
168
end
169
 
170
 
171
endmodule

powered by: WebSVN 2.1.0

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