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

Subversion Repositories ahb_m_wishbone_s

[/] [ahb_m_wishbone_s/] [trunk/] [rtl/] [AHB2WB.v] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 mohamedtar
module AHB2WB(
2
 
3
//AHB MASTER SIDE
4
input        HCLK,
5
input        HRESETn,
6
input [31:0] HADDR,
7
input [31:0] HWDATA,
8
input        HWRITE,
9
input        HSEL,
10
input [1:0]  HTRANS,
11
input [2:0]  HSIZE,
12
input        HREADY,
13
 
14
output [31:0] HRDATA,
15
output        HRESP,
16
output        HREADYOUT,
17
 
18
//WISHBONE SLAVE SIDE
19
output        wb_clk_o,
20
output        wb_rst_o,
21
output [31:0] wb_adr_o,
22
output [31:0] wb_dat_o,
23
output [3:0]  wb_sel_o,
24
output        wb_we_o,
25
output        wb_stb_o,
26
output        wb_cyc_o,
27
 
28
input [31:0]  wb_dat_i,
29
input         wb_ack_i
30
 
31
);
32
 
33
/*
34
Notes!!
35
1- No burst transfer
36
2- 32-bit only
37
3- HREADY is low by default only activated according to the ack_i
38
hence the core shouldn't be the default peripheral upon reset and should only be addressed during R/W
39
4- One cycle delay for the AHB master as the AHB data is available only during the second cyle whereas in the WB side it should
40
be available in the first cycle
41
*/
42
 
43
 //register AHB signals
44
reg [31:0] rHADDR;
45
reg        rHWRITE;
46
reg [1:0]  rHTRANS;
47
reg [2:0]  rHSIZE;
48
reg        rHSEL;
49
 
50
//high priority pull down HREADYOUT before master latches false data
51
reg _pull_down_HREADYOUT;
52
 
53
//helpful signals
54
wire master_wants_read;
55
wire master_wants_write;
56
 
57
//for use in HREADYOUT
58
reg  r_wb_cyc_o;
59
 
60
 always @(posedge HCLK or negedge HRESETn) begin
61
 
62
   if(!HRESETn) begin
63
           rHADDR <= 0;
64
           rHWRITE <= 0;
65
           rHTRANS <= 0;
66
           rHSIZE <= 0;
67
           rHSEL  <= 0;
68
   end
69
 
70
   else if(HREADY) begin
71
 
72
           rHADDR <= HADDR;
73
           rHWRITE <= HWRITE;
74
           rHTRANS <= HTRANS;
75
           rHSIZE <= HSIZE;
76
           rHSEL  <= HSEL;
77
   end
78
 
79
 
80
 end
81
 
82
assign master_wants_read = rHSEL   & rHTRANS[1] & ~rHWRITE;
83
assign master_wants_write = rHSEL   & rHTRANS[1] & rHWRITE;
84
 
85
assign  wb_stb_o = master_wants_read | master_wants_write;
86
assign  wb_cyc_o = wb_stb_o;
87
assign  wb_we_o = master_wants_write;
88
assign  wb_dat_o = HWDATA;
89
assign  wb_adr_o = rHADDR;
90
assign  wb_sel_o = {4{wb_stb_o&wb_cyc_o}};
91
assign  wb_clk_o = HCLK;
92
assign  wb_rst_o =!HRESETn;
93
 
94
always @(posedge HCLK or negedge HRESETn) begin
95
 
96
  if(!HRESETn) r_wb_cyc_o <= 0;
97
 
98
  else if((r_wb_cyc_o==1)&&(HREADYOUT==1)) r_wb_cyc_o <= 0;
99
 
100
  else if(wb_cyc_o) r_wb_cyc_o <= wb_cyc_o;
101
 
102
  else   r_wb_cyc_o <= 0;
103
 
104
 
105
 
106
end
107
 
108
assign HREADYOUT = (r_wb_cyc_o&wb_ack_i)?(1):(0);
109
assign HRDATA = wb_dat_i;
110
assign HRESP = 0;
111
 
112
 
113 3 mohamedtar
endmodule

powered by: WebSVN 2.1.0

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