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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [hostController/] [softransmit.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
//// softransmit
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: softransmit.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 "usbHostControl_h.v"
53
 
54
 
55
module SOFTransmit (clk, rst, sendPacketArbiterGnt, sendPacketArbiterReq, sendPacketRdy, sendPacketWEn, SOFEnable, SOFSent, SOFSyncEn, SOFTimer, SOFTimerClr);
56
input   clk;
57
input   rst;
58
input   sendPacketArbiterGnt;
59
input   sendPacketRdy;
60
input   SOFEnable;    // After host software asserts SOFEnable, must wait TBD time before asserting SOFSyncEn
61
input   SOFSyncEn;
62
input   [15:0]SOFTimer;
63
output  sendPacketArbiterReq;
64
output  sendPacketWEn;
65
output  SOFSent;    // single cycle pulse
66
output  SOFTimerClr;    // Single cycle pulse
67
 
68
wire    clk;
69
wire    rst;
70
wire    sendPacketArbiterGnt;
71
reg     sendPacketArbiterReq, next_sendPacketArbiterReq;
72
wire    sendPacketRdy;
73
reg     sendPacketWEn, next_sendPacketWEn;
74
wire    SOFEnable;
75
reg     SOFSent, next_SOFSent;
76
wire    SOFSyncEn;
77
wire    [15:0]SOFTimer;
78
reg     SOFTimerClr, next_SOFTimerClr;
79
 
80
// BINARY ENCODED state machine: SOFTx
81
// State codes definitions:
82
`define START_STX 3'b000
83
`define WAIT_SOF_NEAR 3'b001
84
`define WAIT_SP_GNT 3'b010
85
`define WAIT_SOF_NOW 3'b011
86
`define SOF_FIN 3'b100
87
 
88
reg [2:0]CurrState_SOFTx, NextState_SOFTx;
89
 
90
 
91
// Machine: SOFTx
92
 
93
// NextState logic (combinatorial)
94
always @ (SOFTimer or SOFSyncEn or SOFEnable or sendPacketArbiterGnt or sendPacketRdy or SOFSent or SOFTimerClr or sendPacketArbiterReq or sendPacketWEn or CurrState_SOFTx)
95
begin
96
  NextState_SOFTx <= CurrState_SOFTx;
97
  // Set default values for outputs and signals
98
  next_SOFSent <= SOFSent;
99
  next_SOFTimerClr <= SOFTimerClr;
100
  next_sendPacketArbiterReq <= sendPacketArbiterReq;
101
  next_sendPacketWEn <= sendPacketWEn;
102
  case (CurrState_SOFTx)  // synopsys parallel_case full_case
103
    `START_STX:
104
    begin
105
      NextState_SOFTx <= `WAIT_SOF_NEAR;
106
    end
107
    `WAIT_SOF_NEAR:
108
    begin
109
      if (SOFTimer >= `SOF_TX_TIME - `SOF_TX_MARGIN ||
110
        (SOFSyncEn == 1'b1 &&
111
        SOFEnable == 1'b1))
112
      begin
113
        NextState_SOFTx <= `WAIT_SP_GNT;
114
        next_sendPacketArbiterReq <= 1'b1;
115
      end
116
    end
117
    `WAIT_SP_GNT:
118
    begin
119
      if (sendPacketArbiterGnt == 1'b1 && sendPacketRdy == 1'b1)
120
      begin
121
        NextState_SOFTx <= `WAIT_SOF_NOW;
122
      end
123
    end
124
    `WAIT_SOF_NOW:
125
    begin
126
      if (SOFTimer >= `SOF_TX_TIME)
127
      begin
128
        NextState_SOFTx <= `SOF_FIN;
129
        next_sendPacketWEn <= 1'b1;
130
        next_SOFTimerClr <= 1'b1;
131
        next_SOFSent <= 1'b1;
132
      end
133
      else if (SOFEnable == 1'b0)
134
      begin
135
        NextState_SOFTx <= `SOF_FIN;
136
        next_SOFTimerClr <= 1'b1;
137
      end
138
    end
139
    `SOF_FIN:
140
    begin
141
      next_sendPacketWEn <= 1'b0;
142
      next_SOFTimerClr <= 1'b0;
143
      next_SOFSent <= 1'b0;
144
      NextState_SOFTx <= `WAIT_SOF_NEAR;
145
      next_sendPacketArbiterReq <= 1'b0;
146
    end
147
  endcase
148
end
149
 
150
// Current State Logic (sequential)
151
always @ (posedge clk)
152
begin
153
  if (rst)
154
    CurrState_SOFTx <= `START_STX;
155
  else
156
    CurrState_SOFTx <= NextState_SOFTx;
157
end
158
 
159
// Registered outputs logic
160
always @ (posedge clk)
161
begin
162
  if (rst)
163
  begin
164
    SOFSent <= 1'b0;
165
    SOFTimerClr <= 1'b0;
166
    sendPacketArbiterReq <= 1'b0;
167
    sendPacketWEn <= 1'b0;
168
  end
169
  else
170
  begin
171
    SOFSent <= next_SOFSent;
172
    SOFTimerClr <= next_SOFTimerClr;
173
    sendPacketArbiterReq <= next_sendPacketArbiterReq;
174
    sendPacketWEn <= next_sendPacketWEn;
175
  end
176
end
177
 
178 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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