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

Subversion Repositories ts7300_opencore

[/] [ts7300_opencore/] [trunk/] [wb32_bridge.v] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 joff
/* Copyright 2005-2006, Technologic Systems
2
 * All Rights Reserved.
3
 *
4
 * Author(s): Jesse Off <joff@embeddedARM.com>
5
 */
6
 
7
/*
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License v2 as published by
10
 *  the Free Software Foundation.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 */
21
 
22
 
23
module wb32_bridge(
24
  wb_clk_i,
25
  wb_rst_i,
26
 
27
  wb16_adr_i,
28
  wb16_dat_i,
29
  wb16_dat_o,
30
  wb16_cyc_i,
31
  wb16_stb_i,
32
  wb16_we_i,
33
  wb16_ack_o,
34
 
35
  wbm_adr_o,
36
  wbm_dat_o,
37
  wbm_dat_i,
38
  wbm_cyc_o,
39
  wbm_stb_o,
40
  wbm_we_o,
41
  wbm_ack_i,
42
  wbm_sel_o
43
);
44
 
45
input wb_clk_i, wb_rst_i;
46
input [22:0] wb16_adr_i;
47
input [15:0] wb16_dat_i;
48
output [15:0] wb16_dat_o;
49
input wb16_cyc_i, wb16_stb_i, wb16_we_i;
50
output wb16_ack_o;
51
 
52
output [21:0] wbm_adr_o;
53
output [3:0] wbm_sel_o;
54
input [31:0] wbm_dat_i;
55
output [31:0] wbm_dat_o;
56
output wbm_cyc_o, wbm_stb_o, wbm_we_o;
57
input wbm_ack_i;
58
 
59
reg [15:0] datlatch;
60
reg wb16_ack_o, wbm_cyc_o, wbm_stb_o;
61
 
62
assign wb16_dat_o = wb16_adr_i[0] ? datlatch : wbm_dat_i[15:0];
63
always @(wb16_adr_i or wb16_we_i or wb16_cyc_i or wb16_stb_i or wbm_ack_i) begin
64
  wb16_ack_o = 1'b0;
65
  wbm_cyc_o = 1'b0;
66
  wbm_stb_o = 1'b0;
67
  if (wb16_cyc_i && wb16_stb_i) begin
68
    if (!wb16_we_i && wb16_adr_i[0]) begin
69
      wb16_ack_o = 1'b1;
70
    end else if (wb16_we_i && !wb16_adr_i[0]) begin
71
      wb16_ack_o = 1'b1;
72
    end else begin
73
      wbm_cyc_o = 1'b1;
74
      wbm_stb_o = 1'b1;
75
      wb16_ack_o = wbm_ack_i;
76
    end
77
  end
78
end
79
 
80
assign wbm_dat_o = {wb16_dat_i, datlatch};
81
assign wbm_we_o = wb16_we_i;
82
assign wbm_adr_o = wb16_adr_i[22:1];
83
assign wbm_sel_o = 4'b1111;
84
always @(posedge wb_clk_i) begin
85
  if (wbm_ack_i && wbm_stb_o && wbm_cyc_o && !wbm_we_o)
86
    datlatch <= wbm_dat_i[31:16];
87
 
88
  if (wb16_cyc_i && wb16_stb_i && wb16_we_i && !wb16_adr_i[0])
89
    datlatch <= wb16_dat_i;
90
end
91
 
92
endmodule

powered by: WebSVN 2.1.0

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