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

Subversion Repositories usbhostslave

[/] [usbhostslave/] [trunk/] [RTL/] [slaveController/] [slaveDirectcontrol.v] - Blame information for rev 7

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

Line No. Rev Author Line
1 5 sfielding
 
2
//////////////////////////////////////////////////////////////////////
3
////                                                              ////
4
//// slaveDirectControl
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 7 sfielding
// $Id: slaveDirectcontrol.v,v 1.3 2004-12-31 14:40:44 sfielding Exp $
46 5 sfielding
//
47
// CVS Revision History
48
//
49
// $Log: not supported by cvs2svn $
50
//
51
`timescale 1ns / 1ps
52
`include "usbSerialInterfaceEngine_h.v"
53
 
54
module slaveDirectControl (clk, directControlEn, directControlLineState, rst, SCTxPortCntl, SCTxPortData, SCTxPortGnt, SCTxPortRdy, SCTxPortReq, SCTxPortWEn);
55
input   clk;
56
input   directControlEn;
57
input   [1:0]directControlLineState;
58
input   rst;
59
input   SCTxPortGnt;
60
input   SCTxPortRdy;
61
output  [7:0]SCTxPortCntl;
62
output  [7:0]SCTxPortData;
63
output  SCTxPortReq;
64
output  SCTxPortWEn;
65
 
66
wire    clk;
67
wire    directControlEn;
68
wire    [1:0]directControlLineState;
69
wire    rst;
70
reg     [7:0]SCTxPortCntl, next_SCTxPortCntl;
71
reg     [7:0]SCTxPortData, next_SCTxPortData;
72
wire    SCTxPortGnt;
73
wire    SCTxPortRdy;
74
reg     SCTxPortReq, next_SCTxPortReq;
75
reg     SCTxPortWEn, next_SCTxPortWEn;
76
 
77
// BINARY ENCODED state machine: slvDrctCntl
78
// State codes definitions:
79
`define START_SDC 3'b000
80
`define CHK_DRCT_CNTL 3'b001
81
`define DRCT_CNTL_WAIT_GNT 3'b010
82
`define DRCT_CNTL_CHK_LOOP 3'b011
83
`define DRCT_CNTL_WAIT_RDY 3'b100
84
`define IDLE_FIN 3'b101
85
`define IDLE_WAIT_GNT 3'b110
86
`define IDLE_WAIT_RDY 3'b111
87
 
88
reg [2:0]CurrState_slvDrctCntl, NextState_slvDrctCntl;
89
 
90
// Diagram actions (continuous assignments allowed only: assign ...)
91
// diagram ACTION
92
 
93
 
94
// Machine: slvDrctCntl
95
 
96
// NextState logic (combinatorial)
97
always @ (directControlEn or SCTxPortGnt or SCTxPortRdy or directControlLineState or SCTxPortCntl or SCTxPortData or SCTxPortWEn or SCTxPortReq or CurrState_slvDrctCntl)
98
begin
99
  NextState_slvDrctCntl <= CurrState_slvDrctCntl;
100
  // Set default values for outputs and signals
101
  next_SCTxPortCntl <= SCTxPortCntl;
102
  next_SCTxPortData <= SCTxPortData;
103
  next_SCTxPortWEn <= SCTxPortWEn;
104
  next_SCTxPortReq <= SCTxPortReq;
105
  case (CurrState_slvDrctCntl)  // synopsys parallel_case full_case
106
    `START_SDC:
107
    begin
108
      NextState_slvDrctCntl <= `CHK_DRCT_CNTL;
109
    end
110
    `CHK_DRCT_CNTL:
111
    begin
112
      if (directControlEn == 1'b1)
113
      begin
114
        NextState_slvDrctCntl <= `DRCT_CNTL_WAIT_GNT;
115
        next_SCTxPortReq <= 1'b1;
116
      end
117
      else
118
      begin
119
        NextState_slvDrctCntl <= `IDLE_WAIT_GNT;
120
        next_SCTxPortReq <= 1'b1;
121
      end
122
    end
123
    `DRCT_CNTL_WAIT_GNT:
124
    begin
125
      if (SCTxPortGnt == 1'b1)
126
      begin
127
        NextState_slvDrctCntl <= `DRCT_CNTL_WAIT_RDY;
128
      end
129
    end
130
    `DRCT_CNTL_CHK_LOOP:
131
    begin
132
      next_SCTxPortWEn <= 1'b0;
133
      if (directControlEn == 1'b0)
134
      begin
135
        NextState_slvDrctCntl <= `CHK_DRCT_CNTL;
136
        next_SCTxPortReq <= 1'b0;
137
      end
138
      else
139
      begin
140
        NextState_slvDrctCntl <= `DRCT_CNTL_WAIT_RDY;
141
      end
142
    end
143
    `DRCT_CNTL_WAIT_RDY:
144
    begin
145
      if (SCTxPortRdy == 1'b1)
146
      begin
147
        NextState_slvDrctCntl <= `DRCT_CNTL_CHK_LOOP;
148
        next_SCTxPortWEn <= 1'b1;
149
        next_SCTxPortData <= {6'b000000, directControlLineState};
150
        next_SCTxPortCntl <= `TX_DIRECT_CONTROL;
151
      end
152
    end
153
    `IDLE_FIN:
154
    begin
155
      next_SCTxPortWEn <= 1'b0;
156
      next_SCTxPortReq <= 1'b0;
157
      NextState_slvDrctCntl <= `CHK_DRCT_CNTL;
158
    end
159
    `IDLE_WAIT_GNT:
160
    begin
161
      if (SCTxPortGnt == 1'b1)
162
      begin
163
        NextState_slvDrctCntl <= `IDLE_WAIT_RDY;
164
      end
165
    end
166
    `IDLE_WAIT_RDY:
167
    begin
168
      if (SCTxPortRdy == 1'b1)
169
      begin
170
        NextState_slvDrctCntl <= `IDLE_FIN;
171
        next_SCTxPortWEn <= 1'b1;
172
        next_SCTxPortData <= 8'h00;
173
        next_SCTxPortCntl <= `TX_IDLE;
174
      end
175
    end
176
  endcase
177
end
178
 
179
// Current State Logic (sequential)
180
always @ (posedge clk)
181
begin
182
  if (rst)
183
    CurrState_slvDrctCntl <= `START_SDC;
184
  else
185
    CurrState_slvDrctCntl <= NextState_slvDrctCntl;
186
end
187
 
188
// Registered outputs logic
189
always @ (posedge clk)
190
begin
191
  if (rst)
192
  begin
193
    SCTxPortCntl <= 8'h00;
194
    SCTxPortData <= 8'h00;
195
    SCTxPortWEn <= 1'b0;
196
    SCTxPortReq <= 1'b0;
197
  end
198
  else
199
  begin
200
    SCTxPortCntl <= next_SCTxPortCntl;
201
    SCTxPortData <= next_SCTxPortData;
202
    SCTxPortWEn <= next_SCTxPortWEn;
203
    SCTxPortReq <= next_SCTxPortReq;
204
  end
205
end
206
 
207 2 sfielding
endmodule

powered by: WebSVN 2.1.0

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