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

Subversion Repositories spacewire

[/] [spacewire/] [trunk/] [rtl/] [SPW_CODEC.v] - Blame information for rev 27

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 btltz
//File name=Module name=SPW_CODEC  2005-2-18      btltz@mail.china.com      btltz from CASIC  
2
//Description:   SpaceWire Coder/Decoder,     Approximate area: ?
3
//Abbreviations: COMI -- Communication Memory Interface
4
//               HOCI -- Host Control Inerface
5
//               PRCI -- Protocol Command Interface
6
//   \_______________________||__________________________/
7
//    |_____Encoding_________||_______Transmission______|
8
//    |DS -- (Data/Strobe)   ||SE --(Single Ended)      | 
9
//    |TS -- (Three of six)  ||DE --(Differential Ended)|
10
//    |HS -- High Speed      ||FO --(Fibre Optic)       | 
11
//    |______________________||_________________________|
12
//Origin:        SpaceWire Std - Draft-1 of ECSS(European Cooperation for Space Standardization),ESTEC,ESA
13
//--     TODO:   Make the rtl faster
14
////////////////////////////////////////////////////////////////////////////////////
15
//
16
/*synthesis translate off*/
17
`timescale 1ns/100ps
18
/*synthesis translate on */
19
`define gFreq  80  //the frequence of the global clock input to the CODEC as the system clk
20
                   //You may need to change it to meet your own board. 
21
                   //This set could affect the Module"Tx_ClkGen".You could open that module for more details.
22
`define ErrorReset  6'b000001
23
`define ErrorWait   6'b000010
24
`define Ready       6'b000100
25
`define Started     6'b001000
26
`define Connecting  6'b010000
27
`define Run         6'b100000
28
`define reset   1  // WISHBONE standard reset
29
 
30
module SPW_CODEC  #(parameter DW=8)
31
                (output Do, So,  //Transmitter data out & strobe out
32
                 input  Di, Si,   //Receiver data in & strobe in          
33
 
34
                                          output [5:0] PPUstate,
35
                                          output LINK_ERR_o,
36
                                          output reg err_int_o,
37
                                        //  output nor_int_o,                 
38
   //Transmitter & ack signals           
39
                      output tx_drvclk_o,
40
                      output rdbuf_o,
41
                                          input Tx_type_i,
42
                 input [DW-1:0] data_i,  //data to send 
43
                                          input Txbuf_Empty,
44
 
45
        //Receiver & ack signals 
46
                      output Rx_DLL_LOCKED,
47
                      output rx_drvclk_o,
48
                      output wrbuf_o,
49
                 output Rx_type_o,  //Type of character received
50
                 output [DW-1:0] data_o,  //data received  
51
                                          input Rxbuf_Full,
52
 
53
   //time & control input & output
54
                 output [5:0] TIMEout,
55
                                          output [1:0] CtrlFlg_o,
56
                 output  TICK_OUT,
57
                 //+                              
58
                 input [5:0] TIMEin,
59
                                          input[1:0] CtrlFlg_i,
60
                                          input TICK_IN,
61
   //status and Control(Link Enable) 
62
                 output active,   //indicate the Codec is active
63
                 input lnk_start,lnk_dis,  // enable Codec or disable Codec 
64
                 input AUTOSTART,   //AUTOSTART input 
65
   //reset ,global clock in                
66
                 input reset,
67
                 input clk10,gclk    /* synthesis syn_isclock = 1 */
68
                  );
69
               //  parameter DW = 8; 
70
                 parameter True  = 1;
71
                 parameter False = 0;
72
 
73
/*
74
output Do, So,  //Transmitter data out & strobe out
75
input  Di, Si,  //Receiver data in & strobe out
76
input  C_send_i,  //Commands to send characters
77
input [DW-1:0] data_s_i,  //data to send
78
output Send_ack_o,   //Acknowledgement
79
output  Type_c_o,  //Type of character received
80
output [DW-1:0] data_r_o,  //data received
81
input   Type_ack_i,
82
input program_i,
83
input gclk //global clock in
84
*/
85
wire err_crd;  //err from Tx
86
wire err_sqc;   //err from PPU
87
//err from Rx
88
wire err_par;
89
wire err_esc;
90
wire err_dsc;
91
 
92
wire gotBit;
93
wire gotFCT;
94
wire gotNULL;
95
wire gotNchar;
96
wire gotTIME;
97
wire C_SEND_FCT;
98
wire EnTx;
99
wire EnRx;
100
wire RST_rx;
101
wire RST_tx;
102
//wire Rx_DLL_LOCKED;
103
//wire RxErr;
104
 
105
 //Vector wire
106
wire [5:0] state;
107
assign PPUstate = state;
108
 
109
always @(posedge gclk)
110
begin:INT_GEN
111
if(reset)
112
  err_int_o <= 0;
113
else if(err_int_o==True)
114
  err_int_o <= 0;
115
else if(err_sqc ||err_crd || err_par || err_esc || err_dsc )
116
  err_int_o <= 1'b1;
117
end  //end block "INT_GEN"
118
 
119
Transmitter    inst_tx(
120
    .Do(Do),
121
    .So(So),
122
 
123
         .type_i(Tx_type_i),
124
    .TxData_i(data_i),
125
         .rdbuf_o(rdbuf_o),
126
         .CtrlFlg_i(CtrlFlg_i),
127
         .empty_i(Txbuf_Empty),
128
         .TICK_IN(TICK_IN),
129
         .TIMEin(TIMEin),
130
         .tx_drvclk_o(tx_drvclk_o),
131
 
132
        /*** .AUTOSTART(AUTOSTART),***/
133
  //  .Sending(), 
134
    .err_crd_o(err_crd),
135
    .gotFCT_i(gotFCT),
136
    .C_SEND_FCT_o(C_SEND_FCT),
137
    .EnTx(EnTx),
138
    .state_i(state),
139
    .reset(RST_tx),
140
    .gclk(gclk),
141
    .clk10(clk10)
142
    );
143
 
144
SPW_FSM  inst_fsm   //The PPU
145
                  (
146
    .active_o(active),
147
         .lnk_start(lnk_start),
148
    .lnk_dis(lnk_dis),
149
    .AUTOSTART(AUTOSTART),
150
 
151
         .state_o(state),
152
    .LINK_ERR_o(LINK_ERR_o),
153
    .err_sqc(err_sqc),
154
    .RST_tx_o(RST_tx),
155
    .enTx_o(EnTx),
156
    .err_crd_i(err_crd),
157
    .RST_rx_o(RST_rx),
158
    .enRx_o(EnRx),
159
    .Lnk_dsc_i(Lnk_dsc),
160
    .gotBit_i(gotBit),
161
    .gotFCT_i(gotFCT),
162
    .gotNchar_i(gotNchar),
163
    .gotTime_i(gotTIME),
164
    .gotNULL_i(gotNULL),
165
    .err_par_i(err_par),
166
    .err_esc_i(err_esc),
167
    .err_dsc_i(err_dsc),
168
    .reset(reset),
169
    .gclk(gclk),
170
    .clk10(clk10)
171
    );
172
 
173
Receiver    inst_rx(
174
    .Si(Si),
175
    .Di(Di),
176
 
177
         .RxData_o(data_o),
178
         .wrtbuf_o(wrbuf_o),
179
    .type_o(Rx_type_o),
180
    //.RxClk_o(RxClk_o), 
181
    .CtrlFlg_o(CtrlFlg_o),
182
    .TIMEout(TIMEout),
183
         .full_i(Rxbuf_Full),
184
         .TICK_OUT(TICK_OUT),
185
         .rx_drvclk_o(rx_drvclk_o),
186
 
187
    .gotBIT_o(gotBit),
188
    .gotFCT_o(gotFCT),
189
    .gotNchar_o(gotNchar),
190
    .gotTIME_o(gotTIME),
191
    .gotNULL_o(gotNULL),
192
    .err_par(err_par),
193
    .err_esc(err_esc),
194
    .err_dsc(err_dsc),
195
   // .RxErr_o(RxErr),      
196
    .EnRx_i(EnRx),
197
         .Lnk_dsc_o(Lnk_dsc),
198
    .C_Send_FCT_i(C_SEND_FCT),
199
   // .Vec_Rxfifo( ),     
200
    .DLL_LOCKED(Rx_DLL_LOCKED),
201
    .state_i(state),
202
    .reset(RST_rx),
203
    .clk10(clk10)
204
    );
205
 
206
regFile  inst_regFile (
207
                          );
208
 
209
endmodule

powered by: WebSVN 2.1.0

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