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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_00_07_alpha/] [RTL/] [hostController/] [hctxportarbiter.v] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 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 2 sfielding
//
45 5 sfielding
// $Id: hctxportarbiter.v,v 1.2 2004-12-18 14:36:09 sfielding Exp $
46 2 sfielding
//
47 5 sfielding
// CVS Revision History
48 2 sfielding
//
49 5 sfielding
// $Log: not supported by cvs2svn $
50 2 sfielding
//
51
`timescale 1ns / 1ps
52
 
53 5 sfielding
module HCTxPortArbiter (clk, directCntlCntl, directCntlData, directCntlGnt, directCntlReq, directCntlWEn, HCTxPortCntl, HCTxPortData, HCTxPortWEnable, rst, sendPacketCntl, sendPacketData, sendPacketGnt, sendPacketReq, sendPacketWEn, SOFCntlCntl, SOFCntlData, SOFCntlGnt, SOFCntlReq, SOFCntlWEn);
54 2 sfielding
input   clk;
55 5 sfielding
input   [7:0]directCntlCntl;
56
input   [7:0]directCntlData;
57 2 sfielding
input   directCntlReq;
58
input   directCntlWEn;
59
input   rst;
60 5 sfielding
input   [7:0]sendPacketCntl;
61
input   [7:0]sendPacketData;
62 2 sfielding
input   sendPacketReq;
63
input   sendPacketWEn;
64 5 sfielding
input   [7:0]SOFCntlCntl;
65
input   [7:0]SOFCntlData;
66
input   SOFCntlReq;
67
input   SOFCntlWEn;
68
output  directCntlGnt;
69
output  [7:0]HCTxPortCntl;
70
output  [7:0]HCTxPortData;
71 2 sfielding
output  HCTxPortWEnable;
72 5 sfielding
output  sendPacketGnt;
73 2 sfielding
output  SOFCntlGnt;
74
 
75
wire    clk;
76 5 sfielding
wire    [7:0]directCntlCntl;
77
wire    [7:0]directCntlData;
78 2 sfielding
reg     directCntlGnt, next_directCntlGnt;
79
wire    directCntlReq;
80
wire    directCntlWEn;
81 5 sfielding
reg     [7:0]HCTxPortCntl, next_HCTxPortCntl;
82
reg     [7:0]HCTxPortData, next_HCTxPortData;
83
reg     HCTxPortWEnable, next_HCTxPortWEnable;
84 2 sfielding
wire    rst;
85 5 sfielding
wire    [7:0]sendPacketCntl;
86
wire    [7:0]sendPacketData;
87 2 sfielding
reg     sendPacketGnt, next_sendPacketGnt;
88
wire    sendPacketReq;
89
wire    sendPacketWEn;
90 5 sfielding
wire    [7:0]SOFCntlCntl;
91
wire    [7:0]SOFCntlData;
92
reg     SOFCntlGnt, next_SOFCntlGnt;
93
wire    SOFCntlReq;
94
wire    SOFCntlWEn;
95 2 sfielding
 
96
 
97
// Constants
98
`define DIRECT_CTRL_MUX 2'b10
99
`define SEND_PACKET_MUX 2'b00
100
`define SOF_CTRL_MUX 2'b01
101
// diagram signals declarations
102
reg  [1:0]muxCntl, next_muxCntl;
103
 
104
// BINARY ENCODED state machine: HCTxArb
105
// State codes definitions:
106
`define START_HARB 3'b000
107
`define WAIT_REQ 3'b001
108
`define SEND_SOF 3'b010
109
`define SEND_PACKET 3'b011
110
`define DIRECT_CONTROL 3'b100
111
 
112 5 sfielding
reg [2:0]CurrState_HCTxArb, NextState_HCTxArb;
113 2 sfielding
 
114
// Diagram actions (continuous assignments allowed only: assign ...)
115
// SOFController/directContol/sendPacket mux
116
always @(muxCntl or SOFCntlWEn or SOFCntlData or SOFCntlCntl or
117 5 sfielding
directCntlWEn or directCntlData or directCntlCntl or
118
directCntlWEn or directCntlData or directCntlCntl or
119
sendPacketWEn or sendPacketData or sendPacketCntl)
120 2 sfielding
begin
121
case (muxCntl)
122 5 sfielding
`SOF_CTRL_MUX :
123
begin
124
HCTxPortWEnable <= SOFCntlWEn;
125
HCTxPortData <= SOFCntlData;
126
HCTxPortCntl <= SOFCntlCntl;
127
end
128
`DIRECT_CTRL_MUX :
129
begin
130
HCTxPortWEnable <= directCntlWEn;
131
HCTxPortData <= directCntlData;
132
HCTxPortCntl <= directCntlCntl;
133
end
134
`SEND_PACKET_MUX :
135
begin
136
HCTxPortWEnable <= sendPacketWEn;
137
HCTxPortData <= sendPacketData;
138
HCTxPortCntl <= sendPacketCntl;
139
end
140
default :
141
begin
142
HCTxPortWEnable <= 1'b0;
143
HCTxPortData <= 8'h00;
144
HCTxPortCntl <= 8'h00;
145
end
146
endcase
147
end
148
 
149
 
150
// Machine: HCTxArb
151
 
152
// NextState logic (combinatorial)
153
always @ (SOFCntlReq or sendPacketReq or directCntlReq or SOFCntlGnt or sendPacketGnt or directCntlGnt or muxCntl or CurrState_HCTxArb)
154
begin
155
  NextState_HCTxArb = CurrState_HCTxArb;
156
  // Set default values for outputs and signals
157
  next_SOFCntlGnt <= SOFCntlGnt;
158
  next_sendPacketGnt <= sendPacketGnt;
159
  next_directCntlGnt <= directCntlGnt;
160
  next_muxCntl <= muxCntl;
161
  case (CurrState_HCTxArb)  // synopsys parallel_case full_case
162
    `START_HARB:
163 2 sfielding
    begin
164 5 sfielding
      NextState_HCTxArb = `WAIT_REQ;
165 2 sfielding
    end
166 5 sfielding
    `WAIT_REQ:
167 2 sfielding
    begin
168 5 sfielding
      if (SOFCntlReq == 1'b1)
169
      begin
170
        NextState_HCTxArb = `SEND_SOF;
171
        next_SOFCntlGnt <= 1'b1;
172
        next_muxCntl <= `SOF_CTRL_MUX;
173
      end
174
      else if (sendPacketReq == 1'b1)
175
      begin
176
        NextState_HCTxArb = `SEND_PACKET;
177
        next_sendPacketGnt <= 1'b1;
178
        next_muxCntl <= `SEND_PACKET_MUX;
179
      end
180
      else if (directCntlReq == 1'b1)
181
      begin
182
        NextState_HCTxArb = `DIRECT_CONTROL;
183
        next_directCntlGnt <= 1'b1;
184
        next_muxCntl <= `DIRECT_CTRL_MUX;
185
      end
186 2 sfielding
    end
187 5 sfielding
    `SEND_SOF:
188 2 sfielding
    begin
189 5 sfielding
      if (SOFCntlReq == 1'b0)
190
      begin
191
        NextState_HCTxArb = `WAIT_REQ;
192
        next_SOFCntlGnt <= 1'b0;
193
      end
194 2 sfielding
    end
195 5 sfielding
    `SEND_PACKET:
196 2 sfielding
    begin
197 5 sfielding
      if (sendPacketReq == 1'b0)
198
      begin
199
        NextState_HCTxArb = `WAIT_REQ;
200
        next_sendPacketGnt <= 1'b0;
201
      end
202 2 sfielding
    end
203 5 sfielding
    `DIRECT_CONTROL:
204
    begin
205
      if (directCntlReq == 1'b0)
206
      begin
207
        NextState_HCTxArb = `WAIT_REQ;
208
        next_directCntlGnt <= 1'b0;
209
      end
210
    end
211
  endcase
212 2 sfielding
end
213
 
214
// Current State Logic (sequential)
215
always @ (posedge clk)
216 5 sfielding
begin
217
  if (rst)
218
    CurrState_HCTxArb = `START_HARB;
219
  else
220
    CurrState_HCTxArb = NextState_HCTxArb;
221 2 sfielding
end
222
 
223
// Registered outputs logic
224
always @ (posedge clk)
225 5 sfielding
begin
226
  if (rst)
227
  begin
228
    SOFCntlGnt = 1'b0;
229
    sendPacketGnt = 1'b0;
230
    directCntlGnt = 1'b0;
231
    muxCntl = 2'b00;
232
  end
233
  else
234
  begin
235
    SOFCntlGnt = next_SOFCntlGnt;
236
    sendPacketGnt = next_sendPacketGnt;
237
    directCntlGnt = next_directCntlGnt;
238
    muxCntl = next_muxCntl;
239
  end
240 2 sfielding
end
241
 
242
endmodule

powered by: WebSVN 2.1.0

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