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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [tags/] [rel_01_01/] [RTL/] [hostController/] [sendpacketarbiter.v] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// sendpacketarbiter
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
`include "usbConstants_h.v"
47
 
48
module sendPacketArbiter (clk, HC_PID, HC_SP_WEn, HCTxGnt, HCTxReq, rst, sendPacketPID, sendPacketWEnable, SOF_SP_WEn, SOFTxGnt, SOFTxReq);
49
input   clk;
50
input   [3:0]HC_PID;
51
input   HC_SP_WEn;
52
input   HCTxReq;
53
input   rst;
54
input   SOF_SP_WEn;
55
input   SOFTxReq;
56
output  HCTxGnt;
57
output  [3:0]sendPacketPID;
58
output  sendPacketWEnable;
59
output  SOFTxGnt;
60
 
61
wire    clk;
62
wire    [3:0]HC_PID;
63
wire    HC_SP_WEn;
64
reg     HCTxGnt, next_HCTxGnt;
65
wire    HCTxReq;
66
wire    rst;
67
reg     [3:0]sendPacketPID, next_sendPacketPID;
68
reg     sendPacketWEnable, next_sendPacketWEnable;
69
wire    SOF_SP_WEn;
70
reg     SOFTxGnt, next_SOFTxGnt;
71
wire    SOFTxReq;
72
 
73
// diagram signals declarations
74
reg muxSOFNotHC, next_muxSOFNotHC;
75
 
76
// BINARY ENCODED state machine: sendPktArb
77
// State codes definitions:
78
`define HC_ACT 2'b00
79
`define SOF_ACT 2'b01
80
`define SARB_WAIT_REQ 2'b10
81
`define START_SARB 2'b11
82
 
83
reg [1:0]CurrState_sendPktArb, NextState_sendPktArb;
84
 
85
// Diagram actions (continuous assignments allowed only: assign ...)
86
// hostController/SOFTransmit mux
87
always @(muxSOFNotHC or SOF_SP_WEn or HC_SP_WEn or HC_PID)
88
begin
89
if (muxSOFNotHC  == 1'b1)
90
begin
91
sendPacketWEnable <= SOF_SP_WEn;
92
sendPacketPID <= `SOF;
93
end
94
else
95
begin
96
sendPacketWEnable <= HC_SP_WEn;
97
sendPacketPID <= HC_PID;
98
end
99
end
100
 
101
 
102
// Machine: sendPktArb
103
 
104
// NextState logic (combinatorial)
105
always @ (HCTxReq or SOFTxReq or HCTxGnt or SOFTxGnt or muxSOFNotHC or CurrState_sendPktArb)
106
begin
107
  NextState_sendPktArb <= CurrState_sendPktArb;
108
  // Set default values for outputs and signals
109
  next_HCTxGnt <= HCTxGnt;
110
  next_SOFTxGnt <= SOFTxGnt;
111
  next_muxSOFNotHC <= muxSOFNotHC;
112
  case (CurrState_sendPktArb)  // synopsys parallel_case full_case
113
    `HC_ACT:
114
    begin
115
      if (HCTxReq == 1'b0)
116
      begin
117
        NextState_sendPktArb <= `SARB_WAIT_REQ;
118
        next_HCTxGnt <= 1'b0;
119
      end
120
    end
121
    `SOF_ACT:
122
    begin
123
      if (SOFTxReq == 1'b0)
124
      begin
125
        NextState_sendPktArb <= `SARB_WAIT_REQ;
126
        next_SOFTxGnt <= 1'b0;
127
      end
128
    end
129
    `SARB_WAIT_REQ:
130
    begin
131
      if (SOFTxReq == 1'b1)
132
      begin
133
        NextState_sendPktArb <= `SOF_ACT;
134
        next_SOFTxGnt <= 1'b1;
135
        next_muxSOFNotHC <= 1'b1;
136
      end
137
      else if (HCTxReq == 1'b1)
138
      begin
139
        NextState_sendPktArb <= `HC_ACT;
140
        next_HCTxGnt <= 1'b1;
141
        next_muxSOFNotHC <= 1'b0;
142
      end
143
    end
144
    `START_SARB:
145
    begin
146
      NextState_sendPktArb <= `SARB_WAIT_REQ;
147
    end
148
  endcase
149
end
150
 
151
// Current State Logic (sequential)
152
always @ (posedge clk)
153
begin
154
  if (rst)
155
    CurrState_sendPktArb <= `START_SARB;
156
  else
157
    CurrState_sendPktArb <= NextState_sendPktArb;
158
end
159
 
160
// Registered outputs logic
161
always @ (posedge clk)
162
begin
163
  if (rst)
164
  begin
165
    HCTxGnt <= 1'b0;
166
    SOFTxGnt <= 1'b0;
167
    muxSOFNotHC <= 1'b0;
168
  end
169
  else
170
  begin
171
    HCTxGnt <= next_HCTxGnt;
172
    SOFTxGnt <= next_SOFTxGnt;
173
    muxSOFNotHC <= next_muxSOFNotHC;
174
  end
175
end
176
 
177 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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