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 2

Go to most recent revision | 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
    parameter AWIDTH = 8,
11
    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
  wire flop_en = ahb_hready_in & ahb_hsel;
53
 
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
  wb_arm_phase_fsm i_wb_arm_phase_fsm(
90
                                        .ahb_hclk       (ahb_hclk),
91
                                        .ahb_hreset     (ahb_hreset),
92
                                        .ahb_hsel       (ahb_hsel),
93
                                        .ahb_hready_in  (ahb_hready_in),
94
                                        .ahb_hready_out (ahb_hready_out),
95
                                        .ahb_data_phase (ahb_data_phase),
96
                                        .fsm_error      (fsm_error)
97
                                      );
98
 
99
 
100
  // -----------------------------
101
  // hresp encoder
102
  reg [1:0] enc_hresp;
103
 
104
  always @(*)
105
    casez( { ahb_htrans_r, fsm_error } )
106
      { 2'b??, 1'b1 }:  enc_hresp = 2'b01;
107
      { 2'b11, 1'b? }:  enc_hresp = 2'b01;    // burst not supported yet
108
      default:          enc_hresp = 2'b00;
109
    endcase
110
 
111
 
112
  // -----------------------------
113
  // wb_sel encoder
114
  reg [3:0] enc_wb_sel;
115
 
116
  always @(*)
117
    casez( { ahb_hsize_r, ahb_haddr_r[1:0] } )
118
      { 3'b010, 2'b?? }:  enc_wb_sel = 4'b1111;
119
      { 3'b001, 2'b0? }:  enc_wb_sel = 4'b0011;
120
      { 3'b001, 2'b1? }:  enc_wb_sel = 4'b1100;
121
      { 3'b000, 2'b00 }:  enc_wb_sel = 4'b0001;
122
      { 3'b000, 2'b01 }:  enc_wb_sel = 4'b0010;
123
      { 3'b000, 2'b10 }:  enc_wb_sel = 4'b0100;
124
      { 3'b000, 2'b11 }:  enc_wb_sel = 4'b1000;
125
      default:            enc_wb_sel = 4'b0000;
126
    endcase
127
 
128
 
129
  // -----------------------------
130
  // outputs
131
 
132
  assign ahb_hresp      = enc_hresp;
133
  assign ahb_hready_out = wb_ack_i;
134
  assign ahb_hsplit     = 0;
135
  assign wb_sel_o       = enc_wb_sel;
136
 
137
  assign wb_adr_o   = ahb_haddr_r;
138
  assign ahb_hrdata = wb_dat_i;
139
  assign wb_we_o    = ahb_hwrite_r & ( (ahb_htrans_r != 2'b00) | (ahb_htrans_r != 2'b01) );
140
  assign wb_cyc_o   = ahb_data_phase;
141
  assign wb_stb_o   = ahb_data_phase;
142
  assign wb_dat_o   = ahb_hwdata;
143
 
144
  assign wb_clk_o = ahb_hclk;
145
  assign wb_rst_o = ~ahb_hreset;
146
 
147
endmodule
148
 
149
 
150
 
151
 
152
 
153
 

powered by: WebSVN 2.1.0

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