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

Subversion Repositories wb_to_amba

[/] [wb_to_amba/] [trunk/] [src/] [wb_arm_slave_top.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 qaztronic
//
2
//
3
//
4
 
5
`timescale 1ns / 100ps
6
 
7
module
8
  wb_arm_slave_top
9
  #(
10 3 qaztronic
    parameter AWIDTH = 32,
11 2 qaztronic
    parameter DWIDTH = 32
12
  )
13
  (
14
    // -----------------------------
15
    // AHB interface
16
    input               ahb_hclk,
17
    input               ahb_hreset,
18
    output [DWIDTH-1:0] ahb_hrdata,
19
    output [1:0]        ahb_hresp,
20
    output              ahb_hready_out,
21
    output [15:0]       ahb_hsplit,
22
    input  [DWIDTH-1:0] ahb_hwdata,
23
    input  [AWIDTH-1:0] ahb_haddr,
24
    input  [2:0]        ahb_hsize,
25
    input               ahb_hwrite,
26
    input  [2:0]        ahb_hburst,
27
    input  [1:0]        ahb_htrans,
28
    input  [3:0]        ahb_hprot,
29
    input               ahb_hsel,
30
    input               ahb_hready_in,
31
 
32
 
33
    // -----------------------------
34
    // Data WISHBONE interface
35
 
36
    input                                 wb_ack_i,     // normal termination
37
    input                                 wb_err_i,     // termination w/ error
38
    input                                 wb_rty_i,     // termination w/ retry
39
    input        [DWIDTH-1:0] wb_dat_i,  // input data bus
40
    output                              wb_cyc_o,       // cycle valid output
41
    output [AWIDTH-1:0]  wb_adr_o,       // address bus outputs
42
    output                              wb_stb_o,       // strobe output
43
    output                              wb_we_o,        // indicates write transfer
44
    output [3:0]             wb_sel_o,   // byte select outputs
45
    output [DWIDTH-1:0]  wb_dat_o,       // output data bus
46
    output                        wb_clk_o,     // clock input
47
    output                        wb_rst_o      // reset input
48
  );
49
 
50
  // -----------------------------
51
  //  ahb_haddr & control flops
52 3 qaztronic
  wire flop_en = ahb_hready_in & ahb_hsel & ~ahb_data_phase;
53 2 qaztronic
 
54
  reg [AWIDTH-1:0] ahb_haddr_r;
55
  always @ (posedge ahb_hclk)
56
    if ( flop_en )
57
      ahb_haddr_r <= ahb_haddr;
58
 
59
 
60
  reg [1:0] ahb_htrans_r;
61
  always @ (posedge ahb_hclk)
62
    if ( flop_en )
63
      ahb_htrans_r <= ahb_htrans;
64
 
65
 
66
  reg ahb_hwrite_r;
67
  always @ (posedge ahb_hclk)
68
    if ( flop_en )
69
      ahb_hwrite_r <= ahb_hwrite;
70
 
71
 
72
  reg [2:0] ahb_hsize_r;
73
  always @ (posedge ahb_hclk)
74
    if ( flop_en )
75
      ahb_hsize_r <= ahb_hsize;
76
 
77
 
78
  reg [2:0] ahb_hburst_r;
79
  always @ (posedge ahb_hclk)
80
    if ( flop_en )
81
      ahb_hburst_r <= ahb_hburst;
82
 
83
 
84
  // -----------------------------
85
  //  wb_arm_phase_fsm
86
  wire ahb_data_phase;
87
  wire fsm_error;
88
 
89 3 qaztronic
  wb_arm_phase_fsm
90
    i_wb_arm_phase_fsm(
91
      .ahb_hclk       (ahb_hclk),
92
      .ahb_hreset     (ahb_hreset),
93
      .ahb_hsel       (ahb_hsel),
94
      .ahb_hready_in  (ahb_hready_in),
95
      .ahb_hready_out (ahb_hready_out),
96
      .ahb_htrans     (ahb_htrans),
97
      .ahb_data_phase (ahb_data_phase),
98
      .fsm_error      (fsm_error)
99
    );
100 2 qaztronic
 
101
 
102
  // -----------------------------
103
  // hresp encoder
104
  reg [1:0] enc_hresp;
105
 
106
  always @(*)
107
    casez( { ahb_htrans_r, fsm_error } )
108
      { 2'b??, 1'b1 }:  enc_hresp = 2'b01;
109
      { 2'b11, 1'b? }:  enc_hresp = 2'b01;    // burst not supported yet
110
      default:          enc_hresp = 2'b00;
111
    endcase
112
 
113
 
114
  // -----------------------------
115
  // wb_sel encoder
116
  reg [3:0] enc_wb_sel;
117
 
118
  always @(*)
119
    casez( { ahb_hsize_r, ahb_haddr_r[1:0] } )
120
      { 3'b010, 2'b?? }:  enc_wb_sel = 4'b1111;
121
      { 3'b001, 2'b0? }:  enc_wb_sel = 4'b0011;
122
      { 3'b001, 2'b1? }:  enc_wb_sel = 4'b1100;
123
      { 3'b000, 2'b00 }:  enc_wb_sel = 4'b0001;
124
      { 3'b000, 2'b01 }:  enc_wb_sel = 4'b0010;
125
      { 3'b000, 2'b10 }:  enc_wb_sel = 4'b0100;
126
      { 3'b000, 2'b11 }:  enc_wb_sel = 4'b1000;
127
      default:            enc_wb_sel = 4'b0000;
128
    endcase
129
 
130
 
131
  // -----------------------------
132
  // outputs
133
 
134
  assign ahb_hresp      = enc_hresp;
135
  assign ahb_hready_out = wb_ack_i;
136
  assign ahb_hsplit     = 0;
137
  assign wb_sel_o       = enc_wb_sel;
138
 
139
  assign wb_adr_o   = ahb_haddr_r;
140
  assign ahb_hrdata = wb_dat_i;
141
  assign wb_we_o    = ahb_hwrite_r & ( (ahb_htrans_r != 2'b00) | (ahb_htrans_r != 2'b01) );
142
  assign wb_cyc_o   = ahb_data_phase;
143
  assign wb_stb_o   = ahb_data_phase;
144
  assign wb_dat_o   = ahb_hwdata;
145
 
146
  assign wb_clk_o = ahb_hclk;
147
  assign wb_rst_o = ~ahb_hreset;
148
 
149
endmodule
150
 
151
 
152
 
153
 
154
 
155
 

powered by: WebSVN 2.1.0

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