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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [hostController/] [sofcontroller.v] - Blame information for rev 5

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

Line No. Rev Author Line
1 5 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// sofcontroller
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
// $Id: sofcontroller.v,v 1.2 2004-12-18 14:36:11 sfielding Exp $
46
//
47
// CVS Revision History
48
//
49
// $Log: not supported by cvs2svn $
50
//
51
`timescale 1ns / 1ps
52
`include "usbSerialInterfaceEngine_h.v"
53
 
54
module SOFController (clk, HCTxPortCntl, HCTxPortData, HCTxPortGnt, HCTxPortRdy, HCTxPortReq, HCTxPortWEn, rst, SOFEnable, SOFTimer, SOFTimerClr);
55
input   clk;
56
input   HCTxPortGnt;
57
input   HCTxPortRdy;
58
input   rst;
59
input   SOFEnable;
60
input   SOFTimerClr;
61
output  [7:0]HCTxPortCntl;
62
output  [7:0]HCTxPortData;
63
output  HCTxPortReq;
64
output  HCTxPortWEn;
65
output  [15:0]SOFTimer;
66
 
67
wire    clk;
68
reg     [7:0]HCTxPortCntl, next_HCTxPortCntl;
69
reg     [7:0]HCTxPortData, next_HCTxPortData;
70
wire    HCTxPortGnt;
71
wire    HCTxPortRdy;
72
reg     HCTxPortReq, next_HCTxPortReq;
73
reg     HCTxPortWEn, next_HCTxPortWEn;
74
wire    rst;
75
wire    SOFEnable;
76
reg     [15:0]SOFTimer, next_SOFTimer;
77
wire    SOFTimerClr;
78
 
79
// BINARY ENCODED state machine: sofCntl
80
// State codes definitions:
81
`define START_SC 3'b000
82
`define WAIT_SOF_EN 3'b001
83
`define WAIT_SEND_RESUME 3'b010
84
`define INC_TIMER 3'b011
85
`define SC_WAIT_GNT 3'b100
86
`define CLR_WEN 3'b101
87
 
88
reg [2:0]CurrState_sofCntl, NextState_sofCntl;
89
 
90
 
91
// Machine: sofCntl
92
 
93
// NextState logic (combinatorial)
94
always @ (SOFTimerClr or SOFEnable or HCTxPortRdy or SOFTimer or HCTxPortGnt or HCTxPortCntl or HCTxPortData or HCTxPortWEn or HCTxPortReq or CurrState_sofCntl)
95
begin
96
  NextState_sofCntl <= CurrState_sofCntl;
97
  // Set default values for outputs and signals
98
  next_SOFTimer <= SOFTimer;
99
  next_HCTxPortCntl <= HCTxPortCntl;
100
  next_HCTxPortData <= HCTxPortData;
101
  next_HCTxPortWEn <= HCTxPortWEn;
102
  next_HCTxPortReq <= HCTxPortReq;
103
  case (CurrState_sofCntl)  // synopsys parallel_case full_case
104
    `START_SC:
105
    begin
106
      NextState_sofCntl <= `WAIT_SOF_EN;
107
    end
108
    `WAIT_SOF_EN:
109
    begin
110
      if (SOFEnable == 1'b1)
111
      begin
112
        NextState_sofCntl <= `SC_WAIT_GNT;
113
        next_HCTxPortReq <= 1'b1;
114
      end
115
    end
116
    `WAIT_SEND_RESUME:
117
    begin
118
      if (HCTxPortRdy == 1'b1)
119
      begin
120
        NextState_sofCntl <= `CLR_WEN;
121
        next_HCTxPortWEn <= 1'b1;
122
        next_HCTxPortData <= 8'h00;
123
        next_HCTxPortCntl <= `TX_RESUME_START;
124
      end
125
    end
126
    `INC_TIMER:
127
    begin
128
      next_HCTxPortReq <= 1'b0;
129
      if (SOFTimerClr == 1'b1)
130
      next_SOFTimer <= 16'h0000;
131
      else
132
      next_SOFTimer <= SOFTimer + 1'b1;
133
      if (SOFEnable == 1'b0)
134
      begin
135
        NextState_sofCntl <= `WAIT_SOF_EN;
136
        next_SOFTimer <= 16'h0000;
137
      end
138
    end
139
    `SC_WAIT_GNT:
140
    begin
141
      if (HCTxPortGnt == 1'b1)
142
      begin
143
        NextState_sofCntl <= `WAIT_SEND_RESUME;
144
      end
145
    end
146
    `CLR_WEN:
147
    begin
148
      next_HCTxPortWEn <= 1'b0;
149
      NextState_sofCntl <= `INC_TIMER;
150
    end
151
  endcase
152
end
153
 
154
// Current State Logic (sequential)
155
always @ (posedge clk)
156
begin
157
  if (rst)
158
    CurrState_sofCntl <= `START_SC;
159
  else
160
    CurrState_sofCntl <= NextState_sofCntl;
161
end
162
 
163
// Registered outputs logic
164
always @ (posedge clk)
165
begin
166
  if (rst)
167
  begin
168
    SOFTimer <= 16'h0000;
169
    HCTxPortCntl <= 8'h00;
170
    HCTxPortData <= 8'h00;
171
    HCTxPortWEn <= 1'b0;
172
    HCTxPortReq <= 1'b0;
173
  end
174
  else
175
  begin
176
    SOFTimer <= next_SOFTimer;
177
    HCTxPortCntl <= next_HCTxPortCntl;
178
    HCTxPortData <= next_HCTxPortData;
179
    HCTxPortWEn <= next_HCTxPortWEn;
180
    HCTxPortReq <= next_HCTxPortReq;
181
  end
182
end
183
 
184 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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