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

Subversion Repositories socwire

[/] [socwire/] [trunk/] [CODEC/] [socwire_codec.vhd] - Blame information for rev 22

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

Line No. Rev Author Line
1 22 bjoerno
---====================== Start Software License ========================---
2
--==                                                                    ==--
3
--== This license governs the use of this software, and your use of     ==--
4
--== this software constitutes acceptance of this license. Agreement    ==--
5
--== with all points is required to use this software.                  ==--
6
--==                                                                    ==--
7
--== 1. This source file may be used and distributed without            ==--
8
--== restriction provided that this software license statement is not   ==--
9
--== removed from the file and that any derivative work contains the    ==--
10
--== original software license notice and the associated disclaimer.    ==--
11
--==                                                                    ==--
12
--== 2. This source file is free software; you can redistribute it      ==--
13
--== and/or modify it under the restriction that UNDER NO CIRCUMTANCES  ==--
14
--== this Software is to be used to CONSTRUCT a SPACEWIRE INTERFACE     ==--
15
--== This implies modification and/or derivative work of this Software. ==--
16
--==                                                                    ==--
17
--== 3. This source is distributed in the hope that it will be useful,  ==--
18
--== but WITHOUT ANY WARRANTY; without even the implied warranty of     ==--
19
--== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               ==--
20
--==                                                                    ==--
21
--== Your rights under this license are terminated immediately if you   ==--
22
--== breach it in any way.                                              ==--
23
--==                                                                    ==--
24
---======================= End Software License =========================---
25
 
26
 
27
---====================== Start Copyright Notice ========================---
28
--==                                                                    ==--
29
--== Filename ..... socwire_codec.vhd                                   ==--
30
--== Download ..... http://www.ida.ing.tu-bs.de                         ==--
31
--== Company ...... IDA TU Braunschweig, Prof. Dr.-Ing. Harald Michalik ==--
32
--== Authors ...... Björn Osterloh, Karel Kotarowski                    ==--
33
--== Contact ...... Björn Osterloh (b.osterloh@tu-bs.de)                ==--
34
--== Copyright .... Copyright (c) 2008 IDA                              ==--
35
--== Project ...... SoCWire CODEC                                       ==--
36
--== Version ...... 1.00                                                ==--
37
--== Conception ... 11 November 2008                                    ==--
38
--== Modified ..... N/A                                                 ==--
39
--==                                                                    ==--
40
---======================= End Copyright Notice =========================---
41
 
42
 
43
 
44
LIBRARY IEEE;
45
USE IEEE.STD_LOGIC_1164.ALL;
46
USE WORK.ALL;
47
 
48
 
49
ENTITY socwire_codec IS
50
  GENERIC(
51
          --== Set Codec Speed to system clock in nanoseconds! ==--
52
          --== USE GEREIC MAPPING FROM TOPLEVEL!!!             ==--
53
               bitwidth : NATURAL RANGE 8 TO 8192;
54
               speed    : NATURAL RANGE 1 TO 100
55
         );
56
  PORT(
57
       --==  General Interface (Sync Rst, 50MHz Clock) ==--
58
 
59
       rst        : IN  STD_LOGIC;
60
       clk        : IN  STD_LOGIC;
61
 
62
       --== Link Enable Interface ==--
63
 
64
       enable     : IN  STD_LOGIC;
65
       disable    : IN  STD_LOGIC;
66
 
67
       --== Serial Receive Interface ==--
68
 
69
       rx         : IN  STD_LOGIC_VECTOR(bitwidth+1 DOWNTO 0);
70
       rx_valid   : IN  STD_LOGIC;
71
 
72
       --== Serial Transmit Interface ==--
73
 
74
       tx         : OUT STD_LOGIC_VECTOR(bitwidth+1 DOWNTO 0);
75
       tx_valid   : OUT STD_LOGIC;
76
 
77
       --== Data Input Interface ==--
78
 
79
       dat_full   : OUT STD_LOGIC;
80
       dat_nwrite : IN  STD_LOGIC;
81
       dat_din    : IN  STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
82
 
83
       --== Data Output Interface ==--
84
 
85
       dat_nread  : IN  STD_LOGIC;
86
       dat_empty  : OUT STD_LOGIC;
87
       dat_dout   : OUT STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
88
 
89
       --== Active Interface ==--
90
 
91
       active     : OUT STD_LOGIC
92
      );
93
END socwire_codec;
94
 
95
 
96
ARCHITECTURE rtl OF socwire_codec IS
97
 
98
---==========================---
99
--== Constants Declarations ==--
100
---==========================---
101
 
102
CONSTANT st_error_reset : STD_LOGIC_VECTOR(2 DOWNTO 0) := "000";
103
CONSTANT st_error_wait  : STD_LOGIC_VECTOR(2 DOWNTO 0) := "001";
104
CONSTANT st_ready       : STD_LOGIC_VECTOR(2 DOWNTO 0) := "010";
105
CONSTANT st_started     : STD_LOGIC_VECTOR(2 DOWNTO 0) := "011";
106
CONSTANT st_connecting  : STD_LOGIC_VECTOR(2 DOWNTO 0) := "100";
107
CONSTANT st_run         : STD_LOGIC_VECTOR(2 DOWNTO 0) := "101";
108
CONSTANT st_unknown_1   : STD_LOGIC_VECTOR(2 DOWNTO 0) := "110";
109
CONSTANT st_unknown_2   : STD_LOGIC_VECTOR(2 DOWNTO 0) := "111";
110
 
111
---===================================---
112
--== Signal Declarations (SM to All) ==--
113
---===================================---
114
 
115
SIGNAL state : STD_LOGIC_VECTOR(2 DOWNTO 0);
116
 
117
---==================================---
118
--== Signal Declarations (Rx to SM) ==--
119
---==================================---
120
 
121
SIGNAL got_null  : STD_LOGIC;
122
SIGNAL got_fct   : STD_LOGIC;
123
SIGNAL got_nchar : STD_LOGIC;
124
SIGNAL err_par   : STD_LOGIC;
125
SIGNAL err_esc   : STD_LOGIC;
126
SIGNAL err_dsc   : STD_LOGIC;
127
SIGNAL err_fct   : STD_LOGIC;
128
SIGNAL err_nchar : STD_LOGIC;
129
 
130
---=======================================---
131
--== Signal Declarations (Rx to Rx FIFO) ==--
132
---=======================================---
133
 
134
SIGNAL dat_full_i   : STD_LOGIC;
135
SIGNAL dat_nwrite_i : STD_LOGIC;
136
SIGNAL dat_din_i    : STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
137
 
138
---=======================================---
139
--== Signal Declarations (Rx FIFO to Tx) ==--
140
---=======================================---
141
 
142
SIGNAL fct_nread_i : STD_LOGIC;
143
SIGNAL fct_empty_i : STD_LOGIC;
144
 
145
---=======================================---
146
--== Signal Declarations (Rx to Tx FIFO) ==--
147
---=======================================---
148
 
149
SIGNAL fct_full_i   : STD_LOGIC;
150
SIGNAL fct_nwrite_i : STD_LOGIC;
151
 
152
---=======================================---
153
--== Signal Declarations (Tx FIFO to Tx) ==--
154
---=======================================---
155
 
156
SIGNAL dat_nread_i : STD_LOGIC;
157
SIGNAL dat_empty_i : STD_LOGIC;
158
SIGNAL dat_dout_i  : STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
159
 
160
---=============================================---
161
--== TESTBENCH : Type Declarations : TESTBENCH ==--
162
---=============================================---
163
 
164
TYPE ss IS
165
  (
166
   error_reset,
167
   error_wait,
168
   ready,
169
   started,
170
   connecting,
171
   run,
172
   unknown_1,
173
   unknown_2,
174
   baffled
175
  );
176
 
177
---===============================================---
178
--== TESTBENCH : Signal Declarations : TESTBENCH ==--
179
---===============================================---
180
 
181
SIGNAL codec_state : ss;
182
 
183
 
184
---=============================================---
185
--== Component Instantiations for leaf modules ==--
186
---=============================================---
187
 
188
COMPONENT receiver
189
  GENERIC(
190
            bitwidth : NATURAL RANGE 8 TO 8192;
191
            speed        : NATURAL RANGE 1 TO 100
192
         );
193
        PORT(
194
       --== General Interface (Sync Rst, 50MHz Clock) ==--
195
 
196
       rst       : IN  STD_LOGIC;
197
       clk       : IN  STD_LOGIC;
198
 
199
       --== SoCWire Interface ==--
200
 
201
       state     : IN  STD_LOGIC_VECTOR(2 DOWNTO 0);
202
 
203
       --== External Receive Interface ==--
204
 
205
       rx                : IN  STD_LOGIC_VECTOR(bitwidth+1 DOWNTO 0);
206
       rx_valid  : IN  STD_LOGIC;
207
 
208
       --== Character Interface ==--
209
 
210
       got_null  : OUT STD_LOGIC;
211
       got_fct   : OUT STD_LOGIC;
212
       got_nchar : OUT STD_LOGIC;
213
 
214
       --== Error Interface ==--
215
 
216
       err_par   : OUT STD_LOGIC;
217
       err_esc   : OUT STD_LOGIC;
218
       err_dsc   : OUT STD_LOGIC;
219
       err_fct   : OUT STD_LOGIC;
220
       err_nchar : OUT STD_LOGIC;
221
 
222
       --== Data Output Interface ==--
223
 
224
       dat_nread : IN  STD_LOGIC;
225
       dat_empty : OUT STD_LOGIC;
226
       dat_dout  : OUT STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
227
 
228
       --== FCT Output Interface ==--
229
 
230
       fct_nread : IN  STD_LOGIC;
231
       fct_empty : OUT STD_LOGIC
232
      );
233
END COMPONENT;
234
 
235
COMPONENT receive_fifo
236
 
237
  GENERIC(
238
          bitwidth : NATURAL RANGE 8 TO 8192
239
         );
240
 
241
        PORT(
242
       --== General Interface (Sync Rst, 50MHz Clock) ==--
243
 
244
       rst        : IN  STD_LOGIC;
245
       clk        : IN  STD_LOGIC;
246
 
247
       --== SoCWire Interface ==--
248
 
249
       state      : IN  STD_LOGIC_VECTOR(2 DOWNTO 0);
250
 
251
       --== Data Input Interface ==--
252
 
253
       dat_full   : OUT STD_LOGIC;
254
       dat_nwrite : IN  STD_LOGIC;
255
       dat_din    : IN  STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
256
 
257
       --== Data Output Interface ==--
258
 
259
       dat_nread  : IN  STD_LOGIC;
260
       dat_empty  : OUT STD_LOGIC;
261
       dat_dout   : OUT STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
262
 
263
       --== FCT Output Interface ==--
264
 
265
       fct_nread  : IN  STD_LOGIC;
266
       fct_empty  : OUT STD_LOGIC
267
      );
268
END COMPONENT receive_fifo;
269
 
270
COMPONENT state_machine
271
    GENERIC(
272
            speed        : NATURAL RANGE 1 TO 100
273
           );
274
        PORT(
275
       --==  General Interface (Sync Rst, 50MHz Clock) ==--
276
 
277
       rst       : IN  STD_LOGIC;
278
       clk       : IN  STD_LOGIC;
279
 
280
       --== Link Enable Interface ==--
281
 
282
       enable    : IN  STD_LOGIC;
283
       disable   : IN  STD_LOGIC;
284
 
285
       --== SoCWire Interface ==--
286
 
287
       state     : OUT STD_LOGIC_VECTOR(2 DOWNTO 0);
288
 
289
       --== Character Interface ==--
290
 
291
       got_null  : IN  STD_LOGIC;
292
       got_fct   : IN  STD_LOGIC;
293
       got_nchar : IN  STD_LOGIC;
294
 
295
       --== Error Interface ==--
296
 
297
       err_par   : IN  STD_LOGIC;
298
       err_esc   : IN  STD_LOGIC;
299
       err_dsc   : IN  STD_LOGIC;
300
       err_fct   : IN  STD_LOGIC;
301
       err_nchar : IN  STD_LOGIC;
302
 
303
       --== Active Interface ==--
304
 
305
       active    : OUT STD_LOGIC
306
      );
307
END COMPONENT state_machine;
308
 
309
COMPONENT transmitter
310
  GENERIC(
311
          bitwidth : NATURAL RANGE 8 TO 8192
312
         );
313
        PORT(
314
 
315
       --== General Interface (Sync Rst, 50MHz Clock) ==--
316
 
317
       rst        : IN  STD_LOGIC;
318
       clk        : IN  STD_LOGIC;
319
 
320
       --== SoCWire Interface ==--
321
 
322
       state      : IN  STD_LOGIC_VECTOR(2 DOWNTO 0);
323
 
324
       --== External Transmit Interface ==--
325
 
326
       tx                 : OUT STD_LOGIC_VECTOR(bitwidth+1 DOWNTO 0);
327
       tx_valid   : OUT STD_LOGIC;
328
 
329
       --== Data Input Interface ==--
330
 
331
       dat_full   : OUT STD_LOGIC;
332
       dat_nwrite : IN  STD_LOGIC;
333
       dat_din    : IN  STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
334
 
335
       --== FCT Input Interface ==--
336
 
337
       fct_full   : OUT STD_LOGIC;
338
       fct_nwrite : IN  STD_LOGIC
339
      );
340
END COMPONENT transmitter;
341
 
342
COMPONENT transmit_fifo
343
  GENERIC(
344
          bitwidth : NATURAL RANGE 8 TO 8192
345
         );
346
        PORT(
347
       --== General Interface (Sync Rst, 50MHz Clock) ==--
348
 
349
       rst        : IN  STD_LOGIC;
350
       clk        : IN  STD_LOGIC;
351
 
352
       --== SoCWire Interface ==--
353
 
354
       state      : IN  STD_LOGIC_VECTOR(2 DOWNTO 0);
355
 
356
       --== Data Input Interface ==--
357
 
358
       dat_full   : OUT STD_LOGIC;
359
       dat_nwrite : IN  STD_LOGIC;
360
       dat_din    : IN  STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
361
 
362
       --== Data Output Interface ==--
363
 
364
       dat_nread  : IN  STD_LOGIC;
365
       dat_empty  : OUT STD_LOGIC;
366
       dat_dout   : OUT STD_LOGIC_VECTOR(bitwidth DOWNTO 0);
367
 
368
       --== FCT Input Interface ==--
369
 
370
       fct_full   : OUT STD_LOGIC;
371
       fct_nwrite : IN  STD_LOGIC
372
      );
373
END COMPONENT transmit_fifo;
374
 
375
BEGIN
376
 
377
  ---===================================================---
378
  --== TESTBENCH : Show State more clearly : TESTBENCH ==--
379
  ---===================================================---
380
 
381
  codec_state <= error_reset WHEN (state = st_error_reset) ELSE
382
                 error_wait  WHEN (state = st_error_wait) ELSE
383
                 ready       WHEN (state = st_ready) ELSE
384
                 started     WHEN (state = st_started) ELSE
385
                 connecting  WHEN (state = st_connecting) ELSE
386
                 run         WHEN (state = st_run) ELSE
387
                 unknown_1   WHEN (state = st_unknown_1) ELSE
388
                 unknown_2   WHEN (state = st_unknown_2) ELSE
389
                 baffled;
390
 
391
 
392
  ---======================---
393
  --== SoCWire Receiver ==--
394
  ---======================---
395
 
396
  U0 : receiver
397
    GENERIC MAP
398
          ( speed => speed,
399
            bitwidth => bitwidth )
400
    PORT MAP
401
      (--==  General Interface (Sync Rst) ==--
402
       rst       => rst,
403
       clk       => clk,
404
       --== SoCWire Interface ==--
405
       state     => state,
406
       --== External Receive Interface ==--
407
       rx                => rx,
408
       rx_valid  => rx_valid,
409
       --== Character Interface ==--
410
       got_null  => got_null,
411
       got_fct   => got_fct,
412
       got_nchar => got_nchar,
413
       --== Error Interface ==--
414
       err_par   => err_par,
415
       err_esc   => err_esc,
416
       err_dsc   => err_dsc,
417
       err_fct   => err_fct,
418
       err_nchar => err_nchar,
419
       --== Data Output Interface ==--
420
       dat_nread => dat_full_i,
421
       dat_empty => dat_nwrite_i,
422
       dat_dout  => dat_din_i,
423
       --== FCT Output Interface ==--
424
       fct_nread => fct_full_i,
425
       fct_empty => fct_nwrite_i
426
      );
427
 
428
 
429
  ---================---
430
  --== Receive FIFO ==--
431
  ---================---
432
 
433
  U1 : receive_fifo
434
      GENERIC MAP
435
          ( bitwidth => bitwidth )
436
    PORT MAP
437
      (--==  General Interface (Sync Rst) ==--
438
       rst        => rst,
439
       clk        => clk,
440
       --== SoCWire Interface ==--
441
       state      => state,
442
       --== Data Input Interface ==--
443
       dat_full   => dat_full_i,
444
       dat_nwrite => dat_nwrite_i,
445
       dat_din    => dat_din_i,
446
       --== Data Output Interface ==--
447
       dat_nread  => dat_nread,
448
       dat_empty  => dat_empty,
449
       dat_dout   => dat_dout,
450
       --== FCT Output Interface ==--
451
       fct_nread  => fct_nread_i,
452
       fct_empty  => fct_empty_i
453
      );
454
 
455
 
456
  ---===========================---
457
  --== SoCWire State Machine ==--
458
  ---===========================---
459
 
460
  U2 : state_machine
461
    GENERIC MAP
462
          ( speed =>  speed )
463
    PORT MAP
464
      (--==  General Interface (Sync Rst, 50MHz Clock) ==--
465
       rst       => rst,
466
       clk       => clk,
467
       --== Link Enable Interface ==--
468
       enable    => enable,
469
       disable   => disable,
470
       --== SoCWire Interface ==--
471
       state     => state,
472
       --== Character Interface ==--
473
       got_null  => got_null,
474
       got_fct   => got_fct,
475
       got_nchar => got_nchar,
476
       --== Error Interface ==--
477
       err_par   => err_par,
478
       err_esc   => err_esc,
479
       err_dsc   => err_dsc,
480
       err_fct   => err_fct,
481
       err_nchar => err_nchar,
482
       --== Active Interface ==--
483
       active    => active
484
      );
485
 
486
 
487
  ---=========================---
488
  --== SoCWire Transmitter ==--
489
  ---=========================---
490
 
491
  U3 : transmitter
492
    GENERIC MAP
493
          ( bitwidth =>  bitwidth )
494
    PORT MAP
495
      (--== General Interface (Sync Rst, 50MHz Clock) ==--
496
       rst        => rst,
497
       clk        => clk,
498
       --== SoCWire Interface ==--
499
       state      => state,
500
       --== External Transmit Interface ==--
501
       tx                 => tx,
502
       tx_valid   => tx_valid,
503
       --== Data Input Interface ==--
504
       dat_full   => dat_nread_i,
505
       dat_nwrite => dat_empty_i,
506
       dat_din    => dat_dout_i,
507
       --== FCT Input Interface ==--
508
       fct_full   => fct_nread_i,
509
       fct_nwrite => fct_empty_i
510
      );
511
 
512
 
513
  ---====================---
514
  --== Transmitter FIFO ==--
515
  ---====================---
516
 
517
  U4 : transmit_fifo
518
    GENERIC MAP
519
          ( bitwidth =>  bitwidth )
520
    PORT MAP
521
      (--== General Interface (Sync Rst, 50MHz Clock) ==--
522
       rst        => rst,
523
       clk        => clk,
524
       --== SoCWire Interface ==--
525
       state      => state,
526
       --== Data Input Interface ==--
527
       dat_full   => dat_full,
528
       dat_nwrite => dat_nwrite,
529
       dat_din    => dat_din,
530
       --== Data Output Interface ==--
531
       dat_nread  => dat_nread_i,
532
       dat_empty  => dat_empty_i,
533
       dat_dout   => dat_dout_i,
534
       --== FCT Input Interface ==--
535
       fct_full   => fct_full_i,
536
       fct_nwrite => fct_nwrite_i
537
      );
538
 
539
END rtl;

powered by: WebSVN 2.1.0

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