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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [hostController/] [hctxportarbiter.v] - Blame information for rev 20

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

Line No. Rev Author Line
1 20 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// hctxPortArbiter
5
////                                                              ////
6
//// This file is part of the usbhostslave opencores effort.
7
//// http://www.opencores.org/cores/usbhostslave/                 ////
8
////                                                              ////
9
//// Module Description:                                          ////
10
//// 
11
////                                                              ////
12
//// To Do:                                                       ////
13
//// 
14
////                                                              ////
15
//// Author(s):                                                   ////
16
//// - Steve Fielding, sfielding@base2designs.com                 ////
17
////                                                              ////
18
//////////////////////////////////////////////////////////////////////
19
////                                                              ////
20
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG          ////
21
////                                                              ////
22
//// This source file may be used and distributed without         ////
23
//// restriction provided that this copyright statement is not    ////
24
//// removed from the file and that any derivative work contains  ////
25
//// the original copyright notice and the associated disclaimer. ////
26
////                                                              ////
27
//// This source file is free software; you can redistribute it   ////
28
//// and/or modify it under the terms of the GNU Lesser General   ////
29
//// Public License as published by the Free Software Foundation; ////
30
//// either version 2.1 of the License, or (at your option) any   ////
31
//// later version.                                               ////
32
////                                                              ////
33
//// This source is distributed in the hope that it will be       ////
34
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
35
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
36
//// PURPOSE. See the GNU Lesser General Public License for more  ////
37
//// details.                                                     ////
38
////                                                              ////
39
//// You should have received a copy of the GNU Lesser General    ////
40
//// Public License along with this source; if not, download it   ////
41
//// from http://www.opencores.org/lgpl.shtml                     ////
42
////                                                              ////
43
//////////////////////////////////////////////////////////////////////
44
//
45
`timescale 1ns / 1ps
46
 
47
module HCTxPortArbiter (clk, directCntlCntl, directCntlData, directCntlGnt, directCntlReq, directCntlWEn, HCTxPortCntl, HCTxPortData, HCTxPortWEnable, rst, sendPacketCntl, sendPacketData, sendPacketGnt, sendPacketReq, sendPacketWEn, SOFCntlCntl, SOFCntlData, SOFCntlGnt, SOFCntlReq, SOFCntlWEn);
48
input   clk;
49
input   [7:0]directCntlCntl;
50
input   [7:0]directCntlData;
51
input   directCntlReq;
52
input   directCntlWEn;
53
input   rst;
54
input   [7:0]sendPacketCntl;
55
input   [7:0]sendPacketData;
56
input   sendPacketReq;
57
input   sendPacketWEn;
58
input   [7:0]SOFCntlCntl;
59
input   [7:0]SOFCntlData;
60
input   SOFCntlReq;
61
input   SOFCntlWEn;
62
output  directCntlGnt;
63
output  [7:0]HCTxPortCntl;
64
output  [7:0]HCTxPortData;
65
output  HCTxPortWEnable;
66
output  sendPacketGnt;
67
output  SOFCntlGnt;
68
 
69
wire    clk;
70
wire    [7:0]directCntlCntl;
71
wire    [7:0]directCntlData;
72
reg     directCntlGnt, next_directCntlGnt;
73
wire    directCntlReq;
74
wire    directCntlWEn;
75
reg     [7:0]HCTxPortCntl, next_HCTxPortCntl;
76
reg     [7:0]HCTxPortData, next_HCTxPortData;
77
reg     HCTxPortWEnable, next_HCTxPortWEnable;
78
wire    rst;
79
wire    [7:0]sendPacketCntl;
80
wire    [7:0]sendPacketData;
81
reg     sendPacketGnt, next_sendPacketGnt;
82
wire    sendPacketReq;
83
wire    sendPacketWEn;
84
wire    [7:0]SOFCntlCntl;
85
wire    [7:0]SOFCntlData;
86
reg     SOFCntlGnt, next_SOFCntlGnt;
87
wire    SOFCntlReq;
88
wire    SOFCntlWEn;
89
 
90
 
91
// Constants
92
`define DIRECT_CTRL_MUX 2'b10
93
`define SEND_PACKET_MUX 2'b00
94
`define SOF_CTRL_MUX 2'b01
95
// diagram signals declarations
96
reg  [1:0]muxCntl, next_muxCntl;
97
 
98
// BINARY ENCODED state machine: HCTxArb
99
// State codes definitions:
100
`define START_HARB 3'b000
101
`define WAIT_REQ 3'b001
102
`define SEND_SOF 3'b010
103
`define SEND_PACKET 3'b011
104
`define DIRECT_CONTROL 3'b100
105
 
106
reg [2:0]CurrState_HCTxArb, NextState_HCTxArb;
107
 
108
// Diagram actions (continuous assignments allowed only: assign ...)
109
// SOFController/directContol/sendPacket mux
110
always @(muxCntl or SOFCntlWEn or SOFCntlData or SOFCntlCntl or
111
directCntlWEn or directCntlData or directCntlCntl or
112
directCntlWEn or directCntlData or directCntlCntl or
113
sendPacketWEn or sendPacketData or sendPacketCntl)
114
begin
115
case (muxCntl)
116
`SOF_CTRL_MUX :
117
begin
118
HCTxPortWEnable <= SOFCntlWEn;
119
HCTxPortData <= SOFCntlData;
120
HCTxPortCntl <= SOFCntlCntl;
121
end
122
`DIRECT_CTRL_MUX :
123
begin
124
HCTxPortWEnable <= directCntlWEn;
125
HCTxPortData <= directCntlData;
126
HCTxPortCntl <= directCntlCntl;
127
end
128
`SEND_PACKET_MUX :
129
begin
130
HCTxPortWEnable <= sendPacketWEn;
131
HCTxPortData <= sendPacketData;
132
HCTxPortCntl <= sendPacketCntl;
133
end
134
default :
135
begin
136
HCTxPortWEnable <= 1'b0;
137
HCTxPortData <= 8'h00;
138
HCTxPortCntl <= 8'h00;
139
end
140
endcase
141
end
142
 
143
 
144
// Machine: HCTxArb
145
 
146
// NextState logic (combinatorial)
147
always @ (SOFCntlReq or sendPacketReq or directCntlReq or SOFCntlGnt or sendPacketGnt or directCntlGnt or muxCntl or CurrState_HCTxArb)
148
begin
149
  NextState_HCTxArb <= CurrState_HCTxArb;
150
  // Set default values for outputs and signals
151
  next_SOFCntlGnt <= SOFCntlGnt;
152
  next_sendPacketGnt <= sendPacketGnt;
153
  next_directCntlGnt <= directCntlGnt;
154
  next_muxCntl <= muxCntl;
155
  case (CurrState_HCTxArb)  // synopsys parallel_case full_case
156
    `START_HARB:
157
    begin
158
      NextState_HCTxArb <= `WAIT_REQ;
159
    end
160
    `WAIT_REQ:
161
    begin
162
      if (SOFCntlReq == 1'b1)
163
      begin
164
        NextState_HCTxArb <= `SEND_SOF;
165
        next_SOFCntlGnt <= 1'b1;
166
        next_muxCntl <= `SOF_CTRL_MUX;
167
      end
168
      else if (sendPacketReq == 1'b1)
169
      begin
170
        NextState_HCTxArb <= `SEND_PACKET;
171
        next_sendPacketGnt <= 1'b1;
172
        next_muxCntl <= `SEND_PACKET_MUX;
173
      end
174
      else if (directCntlReq == 1'b1)
175
      begin
176
        NextState_HCTxArb <= `DIRECT_CONTROL;
177
        next_directCntlGnt <= 1'b1;
178
        next_muxCntl <= `DIRECT_CTRL_MUX;
179
      end
180
    end
181
    `SEND_SOF:
182
    begin
183
      if (SOFCntlReq == 1'b0)
184
      begin
185
        NextState_HCTxArb <= `WAIT_REQ;
186
        next_SOFCntlGnt <= 1'b0;
187
      end
188
    end
189
    `SEND_PACKET:
190
    begin
191
      if (sendPacketReq == 1'b0)
192
      begin
193
        NextState_HCTxArb <= `WAIT_REQ;
194
        next_sendPacketGnt <= 1'b0;
195
      end
196
    end
197
    `DIRECT_CONTROL:
198
    begin
199
      if (directCntlReq == 1'b0)
200
      begin
201
        NextState_HCTxArb <= `WAIT_REQ;
202
        next_directCntlGnt <= 1'b0;
203
      end
204
    end
205
  endcase
206
end
207
 
208
// Current State Logic (sequential)
209
always @ (posedge clk)
210
begin
211
  if (rst)
212
    CurrState_HCTxArb <= `START_HARB;
213
  else
214
    CurrState_HCTxArb <= NextState_HCTxArb;
215
end
216
 
217
// Registered outputs logic
218
always @ (posedge clk)
219
begin
220
  if (rst)
221
  begin
222
    SOFCntlGnt <= 1'b0;
223
    sendPacketGnt <= 1'b0;
224
    directCntlGnt <= 1'b0;
225
    muxCntl <= 2'b00;
226
  end
227
  else
228
  begin
229
    SOFCntlGnt <= next_SOFCntlGnt;
230
    sendPacketGnt <= next_sendPacketGnt;
231
    directCntlGnt <= next_directCntlGnt;
232
    muxCntl <= next_muxCntl;
233
  end
234
end
235
 
236 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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