forked from filipamator/vu_meter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdft_top.v
3658 lines (3418 loc) · 97.6 KB
/
dft_top.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This source file contains a Verilog description of an IP core
* automatically generated by the SPIRAL HDL Generator.
*
* This product includes a hardware design developed by Carnegie Mellon University.
*
* Copyright (c) 2005-2011 by Peter A. Milder for the SPIRAL Project,
* Carnegie Mellon University
*
* For more information, see the SPIRAL project website at:
* http://www.spiral.net
*
* This design is provided for internal, non-commercial research use only
* and is not for redistribution, with or without modifications.
*
* You may not use the name "Carnegie Mellon University" or derivations
* thereof to endorse or promote products derived from this software.
*
* THE SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER
* EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO ANY WARRANTY
* THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS OR BE ERROR-FREE AND ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
* TITLE, OR NON-INFRINGEMENT. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* BE LIABLE FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO DIRECT, INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN
* ANY WAY CONNECTED WITH THIS SOFTWARE (WHETHER OR NOT BASED UPON WARRANTY,
* CONTRACT, TORT OR OTHERWISE).
*
*/
/* Portions of this design are protected by US Patent no. 8,321,823
* (assignee: Carnegie Mellon University).
*/
// Input/output stream: 2 complex words per cycle
// Throughput: one transform every 5141 cycles
// Latency: 5625 cycles
// Resources required:
// 4 multipliers (16 x 16 bit)
// 6 adders (16 x 16 bit)
// 1 adders (10 x 10 bit)
// 4 RAMs (1024 words, 32 bits per word)
// 2 ROMs (1024 words, 16 bits per word)
// Generated on Sun Sep 24 18:19:29 EDT 2017
// Latency: 5625 clock cycles
// Throughput: 1 transform every 5141 cycles
// We use an interleaved complex data format. X0 represents the
// real portion of the first input, and X1 represents the imaginary
// portion. The X variables are system inputs and the Y variables
// are system outputs.
// The design uses a system of flag signals to indicate the
// beginning of the input and output data streams. The 'nexx'
// input (asserted high), is used to instruct the system that the
// input stream will begin on the following cycle.
// This system has a 'gap' of 5141 cycles. This means that
// 5141 cycles must elapse between the beginning of the input
// vectors.
// The output signal 'nexx_out' (also asserted high) indicates
// that the output vector will begin streaming out of the system
// on the following cycle.
// The system has a latency of 5625 cycles. This means that
// the 'nexx_out' will be asserted 5625 cycles after the user
// asserts 'nexx'.
// The simple testbench below will demonstrate the timing for loading
// and unloading data vectors.
// The system reset signal is asserted high.
// Please note: when simulating floating point code, you must include
// Xilinx's DSP slice simulation module.
module dft_testbench();
reg clk, reset, nexx;
wire nexx_out;
integer i, j, k, l, m;
reg [15:0] counter;
reg [15:0] in [3:0];
wire [15:0] X0;
wire [15:0] Y0;
wire [15:0] X1;
wire [15:0] Y1;
wire [15:0] X2;
wire [15:0] Y2;
wire [15:0] X3;
wire [15:0] Y3;
reg clrCnt;
assign X0 = in[0];
assign X1 = in[1];
assign X2 = in[2];
assign X3 = in[3];
initial clk = 0;
always #10000 clk = ~clk;
// Instantiate top-level module of core 'X' signals are system inputs
// and 'Y' signals are system outputs
dft_top dft_top_instance (.clk(clk), .reset(reset), .nexx(nexx), .nexx_out(nexx_out),
.X0(X0), .Y0(Y0),
.X1(X1), .Y1(Y1),
.X2(X2), .Y2(Y2),
.X3(X3), .Y3(Y3));
// You can use this counter to verify that the gap and latency are as expected.
always @(posedge clk) begin
if (clrCnt) counter <= 0;
else counter <= counter+1;
end
initial begin
@(posedge clk);
@(posedge clk);
// On the nexx cycle, begin loading input vector.
nexx <= 1;
clrCnt <= 1;
@(posedge clk);
clrCnt <= 0;
nexx <= 0;
// The 1024 complex data points enter the system over 512 cycles
for (j=0; j < 511; j = j+1) begin
// Input: 2 complex words per cycle
for (k=0; k < 4; k = k+1) begin
in[k] <= j*4 + k;
end
@(posedge clk);
end
j = 511;
for (k=0; k < 4; k = k+1) begin
in[k] <= j*4 + k;
end
@(posedge clk);
// Wait until the nexx data vector can be entered
while (counter < 5139)
@(posedge clk);
// On the nexx cycle, we will start the nexx data vector
nexx <= 1;
clrCnt <= 1;
@(posedge clk);
clrCnt <= 0;
nexx <= 0;
// Start entering nexx input vector
for (j=0; j < 511; j = j+1) begin
// Input 4 words per cycle
for (k=0; k < 4; k = k+1) begin
in[k] <= 2048 + j*4 + k;
end
@(posedge clk);
end
j = 511;
for (k=0; k < 4; k = k+1) begin
in[k] <= 2048 + j*4 + k;
end
end
initial begin
// set initial values
in[0] <= 0;
in[1] <= 0;
in[2] <= 0;
in[3] <= 0;
nexx <= 0;
reset <= 0;
@(posedge clk);
reset <= 1;
@(posedge clk);
reset <= 0;
@(posedge clk);
@(posedge clk);
// Wait until nexx_out goes high, then wait one clock cycle and begin receiving data
@(posedge nexx_out);
@(posedge clk); #1;
$display("--- begin output 1---");
for (m=0; m < 511; m=m+1) begin
$display("%x", Y0);
$display("%x", Y1);
$display("%x", Y2);
$display("%x", Y3);
@(posedge clk); #1;
end
$display("%x", Y0);
$display("%x", Y1);
$display("%x", Y2);
$display("%x", Y3);
// Wait until nexx_out goes high, then wait one clock cycle and begin receiving data
@(posedge nexx_out);
@(posedge clk); #1;
$display("--- begin output 2---");
for (m=0; m < 511; m=m+1) begin
$display("%x", Y0);
$display("%x", Y1);
$display("%x", Y2);
$display("%x", Y3);
@(posedge clk); #1;
end
$display("%x", Y0);
$display("%x", Y1);
$display("%x", Y2);
$display("%x", Y3);
$finish;
end
endmodule
// Latency: 5625
// Gap: 5141
// module_name_is:dft_top
module dft_top(clk, reset, nexx, nexx_out,
X0, Y0,
X1, Y1,
X2, Y2,
X3, Y3);
output nexx_out;
input clk, reset, nexx;
input [15:0] X0,
X1,
X2,
X3;
output [15:0] Y0,
Y1,
Y2,
Y3;
wire [15:0] t0_0;
wire [15:0] t0_1;
wire [15:0] t0_2;
wire [15:0] t0_3;
wire nexx_0;
wire [15:0] t1_0;
wire [15:0] t1_1;
wire [15:0] t1_2;
wire [15:0] t1_3;
wire nexx_1;
wire [15:0] t2_0;
wire [15:0] t2_1;
wire [15:0] t2_2;
wire [15:0] t2_3;
wire nexx_2;
assign t0_0 = X0;
assign Y0 = t2_0;
assign t0_1 = X1;
assign Y1 = t2_1;
assign t0_2 = X2;
assign Y2 = t2_2;
assign t0_3 = X3;
assign Y3 = t2_3;
assign nexx_0 = nexx;
assign nexx_out = nexx_2;
// latency=484, gap=512
rc68760 stage0(.clk(clk), .reset(reset), .nexx(nexx_0), .nexx_out(nexx_1),
.X0(t0_0), .Y0(t1_0),
.X1(t0_1), .Y1(t1_1),
.X2(t0_2), .Y2(t1_2),
.X3(t0_3), .Y3(t1_3));
// latency=5141, gap=5141
ICompose_71037 IComposeInst71264(.nexx(nexx_1), .clk(clk), .reset(reset), .nexx_out(nexx_2),
.X0(t1_0), .Y0(t2_0),
.X1(t1_1), .Y1(t2_1),
.X2(t1_2), .Y2(t2_2),
.X3(t1_3), .Y3(t2_3));
endmodule
// Latency: 484
// Gap: 512
module rc68760(clk, reset, nexx, nexx_out,
X0, Y0,
X1, Y1,
X2, Y2,
X3, Y3);
output nexx_out;
input clk, reset, nexx;
input [15:0] X0,
X1,
X2,
X3;
output [15:0] Y0,
Y1,
Y2,
Y3;
wire [31:0] t0;
wire [31:0] s0;
assign t0 = {X0, X1};
wire [31:0] t1;
wire [31:0] s1;
assign t1 = {X2, X3};
assign Y0 = s0[31:16];
assign Y1 = s0[15:0];
assign Y2 = s1[31:16];
assign Y3 = s1[15:0];
perm68758 instPerm71265(.x0(t0), .y0(s0),
.x1(t1), .y1(s1),
.clk(clk), .nexx(nexx), .nexx_out(nexx_out), .reset(reset)
);
endmodule
// Latency: 484
// Gap: 512
module perm68758(clk, nexx, reset, nexx_out,
x0, y0,
x1, y1);
parameter numBanks = 2;
parameter logBanks = 1;
parameter depth = 512;
parameter logDepth = 9;
parameter width = 32;
input [width-1:0] x0;
output [width-1:0] y0;
wire [width-1:0] ybuff0;
input [width-1:0] x1;
output [width-1:0] y1;
wire [width-1:0] ybuff1;
input clk, nexx, reset;
output nexx_out;
wire nexx0;
reg inFlip0, outFlip0;
reg inActive, outActive;
wire [logBanks-1:0] inBank0, outBank0;
wire [logDepth-1:0] inAddr0, outAddr0;
wire [logBanks-1:0] outBank_a0;
wire [logDepth-1:0] outAddr_a0;
wire [logDepth+logBanks-1:0] addr0, addr0b, addr0c;
wire [logBanks-1:0] inBank1, outBank1;
wire [logDepth-1:0] inAddr1, outAddr1;
wire [logBanks-1:0] outBank_a1;
wire [logDepth-1:0] outAddr_a1;
wire [logDepth+logBanks-1:0] addr1, addr1b, addr1c;
reg [logDepth-1:0] inCount, outCount, outCount_d, outCount_dd, outCount_for_rd_addr, outCount_for_rd_data;
assign addr0 = {inCount, 1'd0};
assign addr0b = {outCount, 1'd0};
assign addr0c = {outCount_for_rd_addr, 1'd0};
assign addr1 = {inCount, 1'd1};
assign addr1b = {outCount, 1'd1};
assign addr1c = {outCount_for_rd_addr, 1'd1};
wire [width+logDepth-1:0] w_0_0, w_0_1, w_1_0, w_1_1;
reg [width-1:0] z_0_0;
reg [width-1:0] z_0_1;
wire [width-1:0] z_1_0, z_1_1;
wire [logDepth-1:0] u_0_0, u_0_1, u_1_0, u_1_1;
always @(posedge clk) begin
end
assign inBank0[0] = addr0[9] ^ addr0[0];
assign inAddr0[0] = addr0[8];
assign inAddr0[1] = addr0[7];
assign inAddr0[2] = addr0[6];
assign inAddr0[3] = addr0[5];
assign inAddr0[4] = addr0[4];
assign inAddr0[5] = addr0[3];
assign inAddr0[6] = addr0[2];
assign inAddr0[7] = addr0[1];
assign inAddr0[8] = addr0[0];
assign outBank0[0] = addr0b[9] ^ addr0b[0];
assign outAddr0[0] = addr0b[1];
assign outAddr0[1] = addr0b[2];
assign outAddr0[2] = addr0b[3];
assign outAddr0[3] = addr0b[4];
assign outAddr0[4] = addr0b[5];
assign outAddr0[5] = addr0b[6];
assign outAddr0[6] = addr0b[7];
assign outAddr0[7] = addr0b[8];
assign outAddr0[8] = addr0b[9];
assign outBank_a0[0] = addr0c[9] ^ addr0c[0];
assign outAddr_a0[0] = addr0c[1];
assign outAddr_a0[1] = addr0c[2];
assign outAddr_a0[2] = addr0c[3];
assign outAddr_a0[3] = addr0c[4];
assign outAddr_a0[4] = addr0c[5];
assign outAddr_a0[5] = addr0c[6];
assign outAddr_a0[6] = addr0c[7];
assign outAddr_a0[7] = addr0c[8];
assign outAddr_a0[8] = addr0c[9];
assign inBank1[0] = addr1[9] ^ addr1[0];
assign inAddr1[0] = addr1[8];
assign inAddr1[1] = addr1[7];
assign inAddr1[2] = addr1[6];
assign inAddr1[3] = addr1[5];
assign inAddr1[4] = addr1[4];
assign inAddr1[5] = addr1[3];
assign inAddr1[6] = addr1[2];
assign inAddr1[7] = addr1[1];
assign inAddr1[8] = addr1[0];
assign outBank1[0] = addr1b[9] ^ addr1b[0];
assign outAddr1[0] = addr1b[1];
assign outAddr1[1] = addr1b[2];
assign outAddr1[2] = addr1b[3];
assign outAddr1[3] = addr1b[4];
assign outAddr1[4] = addr1b[5];
assign outAddr1[5] = addr1b[6];
assign outAddr1[6] = addr1b[7];
assign outAddr1[7] = addr1b[8];
assign outAddr1[8] = addr1b[9];
assign outBank_a1[0] = addr1c[9] ^ addr1c[0];
assign outAddr_a1[0] = addr1c[1];
assign outAddr_a1[1] = addr1c[2];
assign outAddr_a1[2] = addr1c[3];
assign outAddr_a1[3] = addr1c[4];
assign outAddr_a1[4] = addr1c[5];
assign outAddr_a1[5] = addr1c[6];
assign outAddr_a1[6] = addr1c[7];
assign outAddr_a1[7] = addr1c[8];
assign outAddr_a1[8] = addr1c[9];
nexxReg #(482, 9) nexxReg_71270(.X(nexx), .Y(nexx0), .reset(reset), .clk(clk));
shiftRegFIFO #(2, 1) shiftFIFO_71273(.X(nexx0), .Y(nexx_out), .clk(clk));
memArray1024_68758 #(numBanks, logBanks, depth, logDepth, width)
memSys(.inFlip(inFlip0), .outFlip(outFlip0), .nexx(nexx), .reset(reset),
.x0(w_1_0[width+logDepth-1:logDepth]), .y0(ybuff0),
.inAddr0(w_1_0[logDepth-1:0]),
.outAddr0(u_1_0),
.x1(w_1_1[width+logDepth-1:logDepth]), .y1(ybuff1),
.inAddr1(w_1_1[logDepth-1:0]),
.outAddr1(u_1_1),
.clk(clk));
always @(posedge clk) begin
if (reset == 1) begin
z_0_0 <= 0;
z_0_1 <= 0;
inFlip0 <= 0; outFlip0 <= 1; outCount <= 0; inCount <= 0;
outCount_for_rd_addr <= 0;
outCount_for_rd_data <= 0;
end
else begin
outCount_d <= outCount;
outCount_dd <= outCount_d;
if (inCount == 481)
outCount_for_rd_addr <= 0;
else
outCount_for_rd_addr <= outCount_for_rd_addr+1;
if (inCount == 483)
outCount_for_rd_data <= 0;
else
outCount_for_rd_data <= outCount_for_rd_data+1;
z_0_0 <= ybuff0;
z_0_1 <= ybuff1;
if (inCount == 481) begin
outFlip0 <= ~outFlip0;
outCount <= 0;
end
else
outCount <= outCount+1;
if (inCount == 511) begin
inFlip0 <= ~inFlip0;
end
if (nexx == 1) begin
if (inCount >= 481)
inFlip0 <= ~inFlip0;
inCount <= 0;
end
else
inCount <= inCount + 1;
end
end
assign w_0_0 = {x0, inAddr0};
assign w_0_1 = {x1, inAddr1};
assign y0 = z_1_0;
assign y1 = z_1_1;
assign u_0_0 = outAddr_a0;
assign u_0_1 = outAddr_a1;
wire wr_ctrl_st_0;
assign wr_ctrl_st_0 = inCount[8];
switch #(logDepth+width) in_sw_0_0(.x0(w_0_0), .x1(w_0_1), .y0(w_1_0), .y1(w_1_1), .ctrl(wr_ctrl_st_0));
wire rdd_ctrl_st_0;
assign rdd_ctrl_st_0 = outCount_for_rd_data[8];
switch #(width) out_sw_0_0(.x0(z_0_0), .x1(z_0_1), .y0(z_1_0), .y1(z_1_1), .ctrl(rdd_ctrl_st_0));
wire rda_ctrl_st_0;
assign rda_ctrl_st_0 = outCount_for_rd_addr[8];
switch #(logDepth) rdaddr_sw_0_0(.x0(u_0_0), .x1(u_0_1), .y0(u_1_0), .y1(u_1_1), .ctrl(rda_ctrl_st_0));
endmodule
module memArray1024_68758(nexx, reset,
x0, y0,
inAddr0,
outAddr0,
x1, y1,
inAddr1,
outAddr1,
clk, inFlip, outFlip);
parameter numBanks = 2;
parameter logBanks = 1;
parameter depth = 512;
parameter logDepth = 9;
parameter width = 32;
input clk, nexx, reset;
input inFlip, outFlip;
wire nexx0;
input [width-1:0] x0;
output [width-1:0] y0;
input [logDepth-1:0] inAddr0, outAddr0;
input [width-1:0] x1;
output [width-1:0] y1;
input [logDepth-1:0] inAddr1, outAddr1;
nexxReg #(512, 9) nexxReg_71278(.X(nexx), .Y(nexx0), .reset(reset), .clk(clk));
memMod #(depth*2, width, logDepth+1)
memMod0(.in(x0), .out(y0), .inAddr({inFlip, inAddr0}),
.outAddr({outFlip, outAddr0}), .writeSel(1'b1), .clk(clk));
memMod #(depth*2, width, logDepth+1)
memMod1(.in(x1), .out(y1), .inAddr({inFlip, inAddr1}),
.outAddr({outFlip, outAddr1}), .writeSel(1'b1), .clk(clk));
endmodule
module nexxReg(X, Y, reset, clk);
parameter depth=2, logDepth=1;
output Y;
input X;
input clk, reset;
reg [logDepth:0] count;
reg active;
assign Y = (count == depth) ? 1 : 0;
always @ (posedge clk) begin
if (reset == 1) begin
count <= 0;
active <= 0;
end
else if (X == 1) begin
active <= 1;
count <= 1;
end
else if (count == depth) begin
count <= 0;
active <= 0;
end
else if (active)
count <= count+1;
end
endmodule
module memMod(in, out, inAddr, outAddr, writeSel, clk);
parameter depth=1024, width=16, logDepth=10;
input [width-1:0] in;
input [logDepth-1:0] inAddr, outAddr;
input writeSel, clk;
output [width-1:0] out;
reg [width-1:0] out;
// synthesis attribute ram_style of mem is block
/* synthesis syn_ramstyle = "MLAB"*/
reg [width-1:0] mem[depth-1:0];
always @(posedge clk) begin
out <= mem[outAddr];
if (writeSel)
mem[inAddr] <= in;
end
endmodule
module memMod_dist(in, out, inAddr, outAddr, writeSel, clk);
parameter depth=1024, width=16, logDepth=10;
input [width-1:0] in;
input [logDepth-1:0] inAddr, outAddr;
input writeSel, clk;
output [width-1:0] out;
reg [width-1:0] out;
// synthesis attribute ram_style of mem is distributed
reg [width-1:0] mem[depth-1:0];
always @(posedge clk) begin
out <= mem[outAddr];
if (writeSel)
mem[inAddr] <= in;
end
endmodule
module switch(ctrl, x0, x1, y0, y1);
parameter width = 16;
input [width-1:0] x0, x1;
output [width-1:0] y0, y1;
input ctrl;
assign y0 = (ctrl == 0) ? x0 : x1;
assign y1 = (ctrl == 0) ? x1 : x0;
endmodule
module shiftRegFIFO(X, Y, clk);
parameter depth=1, width=1;
output [width-1:0] Y;
input [width-1:0] X;
input clk;
reg [width-1:0] mem [depth-1:0];
integer index;
assign Y = mem[depth-1];
always @ (posedge clk) begin
for(index=1;index<depth;index=index+1) begin
mem[index] <= mem[index-1];
end
mem[0]<=X;
end
endmodule
// Latency: 5141
// Gap: 5141
module ICompose_71037(clk, reset, nexx, nexx_out,
X0, Y0,
X1, Y1,
X2, Y2,
X3, Y3);
output nexx_out;
reg nexx_out;
input clk, reset, nexx;
reg [9:0] cycle_count;
reg [9:0] count;
input [15:0] X0,
X1,
X2,
X3;
output [15:0] Y0,
Y1,
Y2,
Y3;
reg [15:0] Y0,
Y1,
Y2,
Y3;
reg int_nexx;
reg state;
wire [15:0] t0;
reg [15:0] s0;
wire [15:0] t1;
reg [15:0] s1;
wire [15:0] t2;
reg [15:0] s2;
wire [15:0] t3;
reg [15:0] s3;
reg [1:0] iri_state;
wire int_nexx_out;
reg [4:0] i1;
statementList71035 instList71283 (.clk(clk), .reset(reset), .nexx(int_nexx), .nexx_out(int_nexx_out),
.i1_in(i1),
.X0(s0), .Y0(t0),
.X1(s1), .Y1(t1),
.X2(s2), .Y2(t2),
.X3(s3), .Y3(t3));
always @(posedge clk) begin
if (reset == 1) begin
int_nexx <= 0;
i1 <= 9;
cycle_count <= 0;
nexx_out <= 0;
iri_state <= 0;
Y0 <= 0;
Y1 <= 0;
Y2 <= 0;
Y3 <= 0;
end
else begin
Y0 <= t0;
Y1 <= t1;
Y2 <= t2;
Y3 <= t3;
nexx_out <= 0;
case (iri_state)
0: begin
i1 <= 9;
cycle_count <= 0;
if (nexx == 1) begin
int_nexx <= 1;
iri_state <= 1;
end
else begin
int_nexx <= 0;
iri_state <= 0;
end
end
1: begin
int_nexx <= 0;
cycle_count <= cycle_count + 1;
i1 <= i1;
if (cycle_count < 512)
iri_state <= 1;
else
iri_state <= 2;
end
2: begin
cycle_count <= 0;
i1 <= i1 - 1;
if (i1 > 0) begin
iri_state <= 1;
int_nexx <= 1;
end
else begin
iri_state <= 0;
nexx_out <= 1;
int_nexx <= 0;
end
end
endcase
end
end
always @(posedge clk) begin
if (reset == 1) begin
state <= 0;
count <= 0;
s0 <= 0;
s1 <= 0;
s2 <= 0;
s3 <= 0;
end
else begin
case (state)
0: begin
count <= 0;
if (nexx == 1) begin
state <= 1;
count <= 0;
s0 <= X0;
s1 <= X1;
s2 <= X2;
s3 <= X3;
end
else begin
state <= 0;
count <= 0;
s0 <= t0;
s1 <= t1;
s2 <= t2;
s3 <= t3;
end
end
1: begin
count <= count + 1;
if (count < 512) begin
s0 <= X0;
s1 <= X1;
s2 <= X2;
s3 <= X3;
state <= 1;
end
else begin
s0 <= t0;
s1 <= t1;
s2 <= t2;
s3 <= t3;
state <= 0;
end
end
endcase
end
end
endmodule
// Latency: 513
// Gap: 512
// module_name_is:statementList71035
module statementList71035(clk, reset, nexx, nexx_out,
i1_in,
X0, Y0,
X1, Y1,
X2, Y2,
X3, Y3);
output nexx_out;
input clk, reset, nexx;
input [4:0] i1_in;
input [15:0] X0,
X1,
X2,
X3;
output [15:0] Y0,
Y1,
Y2,
Y3;
wire [15:0] t0_0;
wire [15:0] t0_1;
wire [15:0] t0_2;
wire [15:0] t0_3;
wire nexx_0;
wire [15:0] t1_0;
wire [15:0] t1_1;
wire [15:0] t1_2;
wire [15:0] t1_3;
wire nexx_1;
wire [15:0] t2_0;
wire [15:0] t2_1;
wire [15:0] t2_2;
wire [15:0] t2_3;
wire nexx_2;
wire [15:0] t3_0;
wire [15:0] t3_1;
wire [15:0] t3_2;
wire [15:0] t3_3;
wire nexx_3;
wire [4:0] i1;
wire [4:0] i1_0;
assign t0_0 = X0;
assign Y0 = t3_0;
assign t0_1 = X1;
assign Y1 = t3_1;
assign t0_2 = X2;
assign Y2 = t3_2;
assign t0_3 = X3;
assign Y3 = t3_3;
assign nexx_0 = nexx;
assign nexx_out = nexx_3;
assign i1_0 = i1_in;
// latency=11, gap=512
DirSum_70950 DirSumInst71286(.nexx(nexx_0), .clk(clk), .reset(reset), .nexx_out(nexx_1),
.i1(i1_0),
.X0(t0_0), .Y0(t1_0),
.X1(t0_1), .Y1(t1_1),
.X2(t0_2), .Y2(t1_2),
.X3(t0_3), .Y3(t1_3));
// latency=2, gap=512
codeBlock70952 codeBlockIsnt71287(.clk(clk), .reset(reset), .nexx_in(nexx_1), .nexx_out(nexx_2),
.X0_in(t1_0), .Y0(t2_0),
.X1_in(t1_1), .Y1(t2_1),
.X2_in(t1_2), .Y2(t2_2),
.X3_in(t1_3), .Y3(t2_3));
// latency=500, gap=512
rc71033 instrc71288(.clk(clk), .reset(reset), .nexx(nexx_2), .nexx_out(nexx_3),
.X0(t2_0), .Y0(t3_0),
.X1(t2_1), .Y1(t3_1),
.X2(t2_2), .Y2(t3_2),
.X3(t2_3), .Y3(t3_3));
endmodule
// Latency: 11
// Gap: 512
module DirSum_70950(clk, reset, nexx, nexx_out,
i1,
X0, Y0,
X1, Y1,
X2, Y2,
X3, Y3);
output nexx_out;
input clk, reset, nexx;
input [4:0] i1;
reg [8:0] i2;
input [15:0] X0,
X1,
X2,
X3;
output [15:0] Y0,
Y1,
Y2,
Y3;
always @(posedge clk) begin
if (reset == 1) begin
i2 <= 0;
end
else begin
if (nexx == 1)
i2 <= 0;
else if (i2 == 511)
i2 <= 0;
else
i2 <= i2 + 1;
end
end
codeBlock68762 codeBlockIsnt71289(.clk(clk), .reset(reset), .nexx_in(nexx), .nexx_out(nexx_out),
.i2_in(i2),
.i1_in(i1),
.X0_in(X0), .Y0(Y0),
.X1_in(X1), .Y1(Y1),
.X2_in(X2), .Y2(Y2),
.X3_in(X3), .Y3(Y3));
endmodule
module D2_69922(addr, out, clk);
input clk;
output [15:0] out;
reg [15:0] out, out2, out3;
input [9:0] addr;
always @(posedge clk) begin
out2 <= out3;
out <= out2;
case(addr)
0: out3 <= 16'h0;
1: out3 <= 16'hff9b;
2: out3 <= 16'hff37;
3: out3 <= 16'hfed2;
4: out3 <= 16'hfe6e;
5: out3 <= 16'hfe09;
6: out3 <= 16'hfda5;
7: out3 <= 16'hfd40;
8: out3 <= 16'hfcdc;
9: out3 <= 16'hfc78;
10: out3 <= 16'hfc13;
11: out3 <= 16'hfbaf;
12: out3 <= 16'hfb4b;
13: out3 <= 16'hfae6;
14: out3 <= 16'hfa82;
15: out3 <= 16'hfa1e;
16: out3 <= 16'hf9ba;
17: out3 <= 16'hf956;
18: out3 <= 16'hf8f2;
19: out3 <= 16'hf88e;
20: out3 <= 16'hf82a;
21: out3 <= 16'hf7c7;
22: out3 <= 16'hf763;
23: out3 <= 16'hf6ff;
24: out3 <= 16'hf69c;
25: out3 <= 16'hf639;
26: out3 <= 16'hf5d5;