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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [slaveController/] [sctxportarbiter.v] - Blame information for rev 9

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

Line No. Rev Author Line
1 5 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// SCTxPortArbiter
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 SCTxPortArbiter (clk, directCntlCntl, directCntlData, directCntlGnt, directCntlReq, directCntlWEn, rst, SCTxPortCntl, SCTxPortData, SCTxPortRdyIn, SCTxPortRdyOut, SCTxPortWEnable, sendPacketCntl, sendPacketData, sendPacketGnt, sendPacketReq, sendPacketWEn);
48
input   clk;
49
input   [7:0]directCntlCntl;
50
input   [7:0]directCntlData;
51
input   directCntlReq;
52
input   directCntlWEn;
53
input   rst;
54
input   SCTxPortRdyIn;
55
input   [7:0]sendPacketCntl;
56
input   [7:0]sendPacketData;
57
input   sendPacketReq;
58
input   sendPacketWEn;
59
output  directCntlGnt;
60
output  [7:0]SCTxPortCntl;
61
output  [7:0]SCTxPortData;
62
output  SCTxPortRdyOut;
63
output  SCTxPortWEnable;
64
output  sendPacketGnt;
65
 
66
wire    clk;
67
wire    [7:0]directCntlCntl;
68
wire    [7:0]directCntlData;
69
reg     directCntlGnt, next_directCntlGnt;
70
wire    directCntlReq;
71
wire    directCntlWEn;
72
wire    rst;
73
reg     [7:0]SCTxPortCntl, next_SCTxPortCntl;
74
reg     [7:0]SCTxPortData, next_SCTxPortData;
75
wire    SCTxPortRdyIn;
76
reg     SCTxPortRdyOut, next_SCTxPortRdyOut;
77
reg     SCTxPortWEnable, next_SCTxPortWEnable;
78
wire    [7:0]sendPacketCntl;
79
wire    [7:0]sendPacketData;
80
reg     sendPacketGnt, next_sendPacketGnt;
81
wire    sendPacketReq;
82
wire    sendPacketWEn;
83
 
84
// diagram signals declarations
85
reg muxDCEn, next_muxDCEn;
86
 
87
// BINARY ENCODED state machine: SCTxArb
88
// State codes definitions:
89
`define SARB1_WAIT_REQ 2'b00
90
`define SARB_SEND_PACKET 2'b01
91
`define SARB_DC 2'b10
92
`define START_SARB 2'b11
93
 
94
reg [1:0]CurrState_SCTxArb, NextState_SCTxArb;
95
 
96
// Diagram actions (continuous assignments allowed only: assign ...)
97
// SOFController/directContol/sendPacket mux
98
always @(SCTxPortRdyIn)
99
begin
100
SCTxPortRdyOut <= SCTxPortRdyIn;
101
end
102
always @(muxDCEn or
103
directCntlWEn or directCntlData or directCntlCntl or
104
directCntlWEn or directCntlData or directCntlCntl or
105
sendPacketWEn or sendPacketData or sendPacketCntl)
106
begin
107
if (muxDCEn == 1'b1)
108
begin
109
SCTxPortWEnable <= directCntlWEn;
110
SCTxPortData <= directCntlData;
111
SCTxPortCntl <= directCntlCntl;
112
end
113
else
114
begin
115
SCTxPortWEnable <= sendPacketWEn;
116
SCTxPortData <= sendPacketData;
117
SCTxPortCntl <= sendPacketCntl;
118
end
119
end
120
 
121
 
122
// Machine: SCTxArb
123
 
124
// NextState logic (combinatorial)
125
always @ (sendPacketReq or directCntlReq or sendPacketGnt or muxDCEn or directCntlGnt or CurrState_SCTxArb)
126
begin
127
  NextState_SCTxArb <= CurrState_SCTxArb;
128
  // Set default values for outputs and signals
129
  next_sendPacketGnt <= sendPacketGnt;
130
  next_muxDCEn <= muxDCEn;
131
  next_directCntlGnt <= directCntlGnt;
132
  case (CurrState_SCTxArb)  // synopsys parallel_case full_case
133
    `SARB1_WAIT_REQ:
134
    begin
135
      if (sendPacketReq == 1'b1)
136
      begin
137
        NextState_SCTxArb <= `SARB_SEND_PACKET;
138
        next_sendPacketGnt <= 1'b1;
139
        next_muxDCEn <= 1'b0;
140
      end
141
      else if (directCntlReq == 1'b1)
142
      begin
143
        NextState_SCTxArb <= `SARB_DC;
144
        next_directCntlGnt <= 1'b1;
145
        next_muxDCEn <= 1'b1;
146
      end
147
    end
148
    `SARB_SEND_PACKET:
149
    begin
150
      if (sendPacketReq == 1'b0)
151
      begin
152
        NextState_SCTxArb <= `SARB1_WAIT_REQ;
153
        next_sendPacketGnt <= 1'b0;
154
      end
155
    end
156
    `SARB_DC:
157
    begin
158
      if (directCntlReq == 1'b0)
159
      begin
160
        NextState_SCTxArb <= `SARB1_WAIT_REQ;
161
        next_directCntlGnt <= 1'b0;
162
      end
163
    end
164
    `START_SARB:
165
    begin
166
      NextState_SCTxArb <= `SARB1_WAIT_REQ;
167
    end
168
  endcase
169
end
170
 
171
// Current State Logic (sequential)
172
always @ (posedge clk)
173
begin
174
  if (rst)
175
    CurrState_SCTxArb <= `START_SARB;
176
  else
177
    CurrState_SCTxArb <= NextState_SCTxArb;
178
end
179
 
180
// Registered outputs logic
181
always @ (posedge clk)
182
begin
183
  if (rst)
184
  begin
185
    sendPacketGnt <= 1'b0;
186
    directCntlGnt <= 1'b0;
187
    muxDCEn <= 1'b0;
188
  end
189
  else
190
  begin
191
    sendPacketGnt <= next_sendPacketGnt;
192
    directCntlGnt <= next_directCntlGnt;
193
    muxDCEn <= next_muxDCEn;
194
  end
195
end
196
 
197 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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