1 |
408 |
julius |
|
2 |
|
|
// File : ../RTL/hostController/sofcontroller.v
|
3 |
|
|
// Generated : 11/10/06 05:37:21
|
4 |
|
|
// From : ../RTL/hostController/sofcontroller.asf
|
5 |
|
|
// By : FSM2VHDL ver. 5.0.0.9
|
6 |
|
|
|
7 |
|
|
//////////////////////////////////////////////////////////////////////
|
8 |
|
|
//// ////
|
9 |
|
|
//// sofcontroller
|
10 |
|
|
//// ////
|
11 |
|
|
//// This file is part of the usbhostslave opencores effort.
|
12 |
|
|
//// http://www.opencores.org/cores/usbhostslave/ ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// Module Description: ////
|
15 |
|
|
////
|
16 |
|
|
//// ////
|
17 |
|
|
//// To Do: ////
|
18 |
|
|
////
|
19 |
|
|
//// ////
|
20 |
|
|
//// Author(s): ////
|
21 |
|
|
//// - Steve Fielding, sfielding@base2designs.com ////
|
22 |
|
|
//// ////
|
23 |
|
|
//////////////////////////////////////////////////////////////////////
|
24 |
|
|
//// ////
|
25 |
|
|
//// Copyright (C) 2004 Steve Fielding and OPENCORES.ORG ////
|
26 |
|
|
//// ////
|
27 |
|
|
//// This source file may be used and distributed without ////
|
28 |
|
|
//// restriction provided that this copyright statement is not ////
|
29 |
|
|
//// removed from the file and that any derivative work contains ////
|
30 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
31 |
|
|
//// ////
|
32 |
|
|
//// This source file is free software; you can redistribute it ////
|
33 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
34 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
35 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
36 |
|
|
//// later version. ////
|
37 |
|
|
//// ////
|
38 |
|
|
//// This source is distributed in the hope that it will be ////
|
39 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
40 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
41 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
42 |
|
|
//// details. ////
|
43 |
|
|
//// ////
|
44 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
45 |
|
|
//// Public License along with this source; if not, download it ////
|
46 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
47 |
|
|
//// ////
|
48 |
|
|
//////////////////////////////////////////////////////////////////////
|
49 |
|
|
//
|
50 |
|
|
`include "timescale.v"
|
51 |
|
|
`include "usbhostslave_serialinterfaceengine_h.v"
|
52 |
|
|
|
53 |
|
|
module SOFController (HCTxPortCntl, HCTxPortData, HCTxPortGnt, HCTxPortRdy, HCTxPortReq, HCTxPortWEn, SOFEnable, SOFTimerClr, SOFTimer, clk, rst);
|
54 |
|
|
input HCTxPortGnt;
|
55 |
|
|
input HCTxPortRdy;
|
56 |
|
|
input SOFEnable;
|
57 |
|
|
input SOFTimerClr;
|
58 |
|
|
input clk;
|
59 |
|
|
input rst;
|
60 |
|
|
output [7:0] HCTxPortCntl;
|
61 |
|
|
output [7:0] HCTxPortData;
|
62 |
|
|
output HCTxPortReq;
|
63 |
|
|
output HCTxPortWEn;
|
64 |
|
|
output [15:0] SOFTimer;
|
65 |
|
|
|
66 |
|
|
reg [7:0] HCTxPortCntl, next_HCTxPortCntl;
|
67 |
|
|
reg [7:0] HCTxPortData, next_HCTxPortData;
|
68 |
|
|
wire HCTxPortGnt;
|
69 |
|
|
wire HCTxPortRdy;
|
70 |
|
|
reg HCTxPortReq, next_HCTxPortReq;
|
71 |
|
|
reg HCTxPortWEn, next_HCTxPortWEn;
|
72 |
|
|
wire SOFEnable;
|
73 |
|
|
wire SOFTimerClr;
|
74 |
|
|
reg [15:0] SOFTimer, next_SOFTimer;
|
75 |
|
|
wire clk;
|
76 |
|
|
wire rst;
|
77 |
|
|
|
78 |
|
|
// BINARY ENCODED state machine: sofCntl
|
79 |
|
|
// State codes definitions:
|
80 |
|
|
`define START_SC 3'b000
|
81 |
|
|
`define WAIT_SOF_EN 3'b001
|
82 |
|
|
`define WAIT_SEND_RESUME 3'b010
|
83 |
|
|
`define INC_TIMER 3'b011
|
84 |
|
|
`define SC_WAIT_GNT 3'b100
|
85 |
|
|
`define CLR_WEN 3'b101
|
86 |
|
|
|
87 |
|
|
reg [2:0] CurrState_sofCntl;
|
88 |
|
|
reg [2:0] NextState_sofCntl;
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
//--------------------------------------------------------------------
|
92 |
|
|
// Machine: sofCntl
|
93 |
|
|
//--------------------------------------------------------------------
|
94 |
|
|
//----------------------------------
|
95 |
|
|
// Next State Logic (combinatorial)
|
96 |
|
|
//----------------------------------
|
97 |
|
|
always @ (SOFTimerClr or SOFTimer or SOFEnable or HCTxPortRdy or HCTxPortGnt or HCTxPortReq or HCTxPortWEn or HCTxPortData or HCTxPortCntl or CurrState_sofCntl)
|
98 |
|
|
begin : sofCntl_NextState
|
99 |
|
|
NextState_sofCntl <= CurrState_sofCntl;
|
100 |
|
|
// Set default values for outputs and signals
|
101 |
|
|
next_HCTxPortReq <= HCTxPortReq;
|
102 |
|
|
next_HCTxPortWEn <= HCTxPortWEn;
|
103 |
|
|
next_HCTxPortData <= HCTxPortData;
|
104 |
|
|
next_HCTxPortCntl <= HCTxPortCntl;
|
105 |
|
|
next_SOFTimer <= SOFTimer;
|
106 |
|
|
case (CurrState_sofCntl)
|
107 |
|
|
`START_SC:
|
108 |
|
|
NextState_sofCntl <= `WAIT_SOF_EN;
|
109 |
|
|
`WAIT_SOF_EN:
|
110 |
|
|
if (SOFEnable == 1'b1)
|
111 |
|
|
begin
|
112 |
|
|
NextState_sofCntl <= `SC_WAIT_GNT;
|
113 |
|
|
next_HCTxPortReq <= 1'b1;
|
114 |
|
|
end
|
115 |
|
|
`WAIT_SEND_RESUME:
|
116 |
|
|
if (HCTxPortRdy == 1'b1)
|
117 |
|
|
begin
|
118 |
|
|
NextState_sofCntl <= `CLR_WEN;
|
119 |
|
|
next_HCTxPortWEn <= 1'b1;
|
120 |
|
|
next_HCTxPortData <= 8'h00;
|
121 |
|
|
next_HCTxPortCntl <= `TX_RESUME_START;
|
122 |
|
|
end
|
123 |
|
|
`INC_TIMER:
|
124 |
|
|
begin
|
125 |
|
|
next_HCTxPortReq <= 1'b0;
|
126 |
|
|
if (SOFTimerClr == 1'b1)
|
127 |
|
|
next_SOFTimer <= 16'h0000;
|
128 |
|
|
else
|
129 |
|
|
next_SOFTimer <= SOFTimer + 1'b1;
|
130 |
|
|
if (SOFEnable == 1'b0)
|
131 |
|
|
begin
|
132 |
|
|
NextState_sofCntl <= `WAIT_SOF_EN;
|
133 |
|
|
next_SOFTimer <= 16'h0000;
|
134 |
|
|
end
|
135 |
|
|
end
|
136 |
|
|
`SC_WAIT_GNT:
|
137 |
|
|
if (HCTxPortGnt == 1'b1)
|
138 |
|
|
NextState_sofCntl <= `WAIT_SEND_RESUME;
|
139 |
|
|
`CLR_WEN:
|
140 |
|
|
begin
|
141 |
|
|
next_HCTxPortWEn <= 1'b0;
|
142 |
|
|
NextState_sofCntl <= `INC_TIMER;
|
143 |
|
|
end
|
144 |
|
|
endcase
|
145 |
|
|
end
|
146 |
|
|
|
147 |
|
|
//----------------------------------
|
148 |
|
|
// Current State Logic (sequential)
|
149 |
|
|
//----------------------------------
|
150 |
|
|
always @ (posedge clk)
|
151 |
|
|
begin : sofCntl_CurrentState
|
152 |
|
|
if (rst)
|
153 |
|
|
CurrState_sofCntl <= `START_SC;
|
154 |
|
|
else
|
155 |
|
|
CurrState_sofCntl <= NextState_sofCntl;
|
156 |
|
|
end
|
157 |
|
|
|
158 |
|
|
//----------------------------------
|
159 |
|
|
// Registered outputs logic
|
160 |
|
|
//----------------------------------
|
161 |
|
|
always @ (posedge clk)
|
162 |
|
|
begin : sofCntl_RegOutput
|
163 |
|
|
if (rst)
|
164 |
|
|
begin
|
165 |
|
|
SOFTimer <= 16'h0000;
|
166 |
|
|
HCTxPortCntl <= 8'h00;
|
167 |
|
|
HCTxPortData <= 8'h00;
|
168 |
|
|
HCTxPortWEn <= 1'b0;
|
169 |
|
|
HCTxPortReq <= 1'b0;
|
170 |
|
|
end
|
171 |
|
|
else
|
172 |
|
|
begin
|
173 |
|
|
SOFTimer <= next_SOFTimer;
|
174 |
|
|
HCTxPortCntl <= next_HCTxPortCntl;
|
175 |
|
|
HCTxPortData <= next_HCTxPortData;
|
176 |
|
|
HCTxPortWEn <= next_HCTxPortWEn;
|
177 |
|
|
HCTxPortReq <= next_HCTxPortReq;
|
178 |
|
|
end
|
179 |
|
|
end
|
180 |
|
|
|
181 |
|
|
endmodule
|