-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_file.v
993 lines (974 loc) · 25.8 KB
/
main_file.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
module main_file(input clk,rst, next_trigger,input wire[3:0] col_driver, output reg [3:0] arduino_comm, output reg [7:0] tracker, output wire [3:0] row_driver, output reg [7:0] led,led1,led2,led3);
parameter S0 = 7'h0;
parameter S1 = 7'h1;
parameter S2 = 7'h2;
parameter S3 = 7'h3;
parameter S4 = 7'h04;
parameter S5 = 7'h5;
parameter S6 = 7'h6;
parameter S7 = 7'h7;
parameter S8 = 7'h8;
parameter S9 = 7'h9;
parameter S10 = 7'ha;
parameter S11 = 7'hb;
parameter S12 = 7'hc;
parameter S13 = 7'hd;
parameter S14 = 7'he;
parameter S15 = 7'hf;
parameter S16 = 7'h10;
parameter S17 = 7'h11;
parameter S18 = 7'h12;
parameter S19 = 7'h13;
parameter S20 = 7'h14;
parameter S21 = 7'h15;
parameter S22 = 7'h16;
parameter S23 = 7'h17;
parameter S24 = 7'h18;
parameter S25 = 7'h19;
parameter S26 = 7'h1a;
parameter S27 = 7'h1b;
parameter S28 = 7'h1c;
parameter S29 = 7'h1d;
parameter S30 = 7'h1e;
parameter S31 = 7'h1f;
parameter S32 = 7'h20;
parameter S33 = 7'h21;
parameter S34 = 7'h22;
parameter S35 = 7'h23;
parameter S36 = 7'h24;
parameter S37 = 7'h25;
parameter S38 = 7'h26;
parameter S39 = 7'h27;
parameter S40 = 7'h28;
parameter S41 = 7'h29;
parameter S42 = 7'h2a;
parameter S43 = 7'h2b;
parameter S44 = 7'h2c;
parameter S45 = 7'h2d;
parameter S46 = 7'h2e;
parameter S47 = 7'h2f;
parameter S48 = 7'h30;
parameter S49 = 7'h31;
parameter S50 = 7'h32;
parameter S51 = 7'h33;
parameter S52 = 7'h34;
parameter S53 = 7'h35;
parameter S54 = 7'h36;
parameter S55 = 7'h37;
parameter S56 = 7'h38;
parameter S57 = 7'h39;
parameter S58 = 7'h3a;
parameter S59 = 7'h3b;
parameter S60 = 7'h3c;
parameter S61 = 7'h3d;
parameter S62 = 7'h3e;
parameter S63 =7'h3f;
parameter S64 = 7'h40;
parameter S65 = 7'h41;
parameter S66 = 7'h42;
parameter S67 = 7'h43;
parameter S68 = 7'h44;
parameter S69 = 7'h45;
parameter S70 = 7'h46;
parameter S71 = 7'h47;
parameter S72 = 7'h48;
parameter S73 = 7'h49;
parameter S74 = 7'h4A;
parameter S75 = 7'h4B;
parameter S76 = 7'h4C;
parameter S77 = 7'h4D;
parameter S78 = 7'h4E;
parameter S79 = 7'h4F;
parameter S80 = 7'h50;
parameter S81 = 7'h51;
parameter S82 = 7'h52;
parameter S83 = 7'h53;
reg [2:0] address;
reg [6:0] current_state,next_state = 0;
reg [15:0] data_11,data_12,data_13,data_14,data_15,data_16,data_17,data_18;
reg [15:0] data_21,data_22,data_23,data_24,data_25,data_26,data_27,data_28;
reg [15:0] data_into_sram1,data_into_sram2;
reg write_enable,output_enable,select,mac_rst;
reg [15:0] op_data,op_data_1;
wire [15:0] result;
wire [3:0] data;
wire clk1,clk2;
wire [15:0] data_from_sram1,data_from_sram2;
wire chip_select_1,chip_select_2 ;
initial begin
write_enable = 1'b1;
select = 1'b1;
output_enable = 1'b1;
current_state = S0;
next_state = S0;
mac_rst = 1;
address = 0;
end
clock_counter c1(clk,clk1);
clock_counter_2 c2(clk,clk2);
keyboardScanner k1(clk1,col_driver, row_driver,data);
demux d1(select,chip_select_1,chip_select_2);
MAC_unit M1(clk1,mac_rst,op_data,op_data_1,result);
sram s1(chip_select_1,write_enable,output_enable,address,data_into_sram1,data_from_sram1);
sram s2(chip_select_2,write_enable,output_enable,address,data_into_sram2,data_from_sram2);
integer i =0;
always @(posedge clk2) begin
case(current_state)
S0: begin
data_11 = 0;
data_12 = 0;
data_13 = 0;
data_14 = 0;
data_15 = 0;
data_16 = 0;
data_17 = 0;
data_18 = 0;
data_21 =0;
data_22 = 0;
data_23 = 0;
data_24 = 0;
data_25 =0;
data_26= 0;
data_27 = 0;
data_28 =0;
arduino_comm = 4'h1;
next_state = S1;
end
S1: begin
data_11[15:4] = 0;
data_11[3:0] = data;
seven_segment_display(data_11[3:0],led);
seven_segment_display(data_11[7:4],led1);
seven_segment_display(data_11[11:8],led2);
seven_segment_display(data_11[15:12],led3);
arduino_comm = 4'h2;
next_state = S2;
tracker = 8'hFE;
end
S2: begin
data_11[15:8] = 0;
data_11[7:4] = data;
seven_segment_display(data_11[3:0],led);
seven_segment_display(data_11[7:4],led1);
seven_segment_display(data_11[11:8],led2);
seven_segment_display(data_11[15:12],led3);
arduino_comm = 4'h2;
next_state = S3;
tracker = 8'hFE;
end
S3: begin
data_11[15:12] = 0;
data_11[11:8] = data;
seven_segment_display(data_11[3:0],led);
seven_segment_display(data_11[7:4],led1);
seven_segment_display(data_11[11:8],led2);
seven_segment_display(data_11[15:12],led3);
arduino_comm = 4'h2;
next_state = S4;
tracker = 8'hFE;
end
S4: begin
data_11[15:12] = data;
seven_segment_display(data_11[3:0],led);
seven_segment_display(data_11[7:4],led1);
seven_segment_display(data_11[11:8],led2);
seven_segment_display(data_11[15:12],led3);
arduino_comm = 4'h2;
write_to_memory_1(16'h1);
next_state = S5;
tracker = 8'hFE;
end
S5:begin
write_high_1(3'b000);
data_12[15:4] = 0;
data_12[3:0] = data;
seven_segment_display(data_12[3:0],led);
seven_segment_display(data_12[7:4],led1);
seven_segment_display(data_12[11:8],led2);
seven_segment_display(data_12[15:12],led3);
arduino_comm = 4'h2;
next_state = S6;
tracker = 8'hFD;
end
S6: begin
close_write;
data_12[15:8] = 0;
data_12[7:4] = data;
seven_segment_display(data_12[3:0],led);
seven_segment_display(data_12[7:4],led1);
seven_segment_display(data_12[11:8],led2);
seven_segment_display(data_12[15:12],led3);
arduino_comm = 4'h2;
next_state = S7;
tracker = 8'hFD;
end
S7: begin
data_12[15:12] = 0;
data_12[11:8] = data;
seven_segment_display(data_12[3:0],led);
seven_segment_display(data_12[7:4],led1);
seven_segment_display(data_12[11:8],led2);
seven_segment_display(data_12[15:12],led3);
arduino_comm = 4'h2;
next_state = S8;
tracker = 8'hFD;
end
S8: begin
data_12[15:12] = data;
seven_segment_display(data_12[3:0],led);
seven_segment_display(data_12[7:4],led1);
seven_segment_display(data_12[11:8],led2);
seven_segment_display(data_12[15:12],led3);
write_to_memory_1(data_12);
arduino_comm = 4'h2;
next_state = S9;
tracker = 8'hFD;
end
S9: begin
write_high_1(3'b001);
data_13[15:4] = 0;
data_13[3:0] = data;
seven_segment_display(data_13[3:0],led);
seven_segment_display(data_13[7:4],led1);
seven_segment_display(data_13[11:8],led2);
seven_segment_display(data_13[15:12],led3);
arduino_comm = 4'h2;
next_state = S10;
tracker = 8'hFB;
end
S10: begin
close_write;
data_13[15:8] = 0;
data_13[7:4] = data;
seven_segment_display(data_13[3:0],led);
seven_segment_display(data_13[7:4],led1);
seven_segment_display(data_13[11:8],led2);
seven_segment_display(data_13[15:12],led3);
arduino_comm = 4'h2;
next_state = S11;
tracker = 8'hFB;
end
S11: begin
data_13[15:12] = 0;
data_13[11:8] = data;
seven_segment_display(data_13[3:0],led);
seven_segment_display(data_13[7:4],led1);
seven_segment_display(data_13[11:8],led2);
seven_segment_display(data_13[15:12],led3);
arduino_comm = 4'h2;
next_state = S12;
tracker = 8'hFB;
end
S12: begin
data_13[15:12] = data;
seven_segment_display(data_13[3:0],led);
seven_segment_display(data_13[7:4],led1);
seven_segment_display(data_13[11:8],led2);
seven_segment_display(data_13[15:12],led3);
arduino_comm = 4'h2;
write_to_memory_1(data_13);
next_state = S13;
tracker = 8'hFB;
end
S13:begin
write_high_1(3'b010);
data_14[15:4] = 0;
data_14[3:0] = data;
seven_segment_display(data_14[3:0],led);
seven_segment_display(data_14[7:4],led1);
seven_segment_display(data_14[11:8],led2);
seven_segment_display(data_14[15:12],led3);
arduino_comm = 4'h2;
next_state = S14;
tracker = 8'hF7;
end
S14: begin
close_write;
data_14[15:8] = 0;
data_14[7:4] = data;
seven_segment_display(data_14[3:0],led);
seven_segment_display(data_14[7:4],led1);
seven_segment_display(data_14[11:8],led2);
seven_segment_display(data_14[15:12],led3);
arduino_comm = 4'h2;
next_state = S15;
tracker = 8'hF7;
end
S15: begin
data_14[15:12] = 0;
data_14[11:8] = data;
seven_segment_display(data_14[3:0],led);
seven_segment_display(data_14[7:4],led1);
seven_segment_display(data_14[11:8],led2);
seven_segment_display(data_14[15:12],led3);
arduino_comm = 4'h2;
next_state = S16;
tracker = 8'hF7;
end
S16: begin
data_14[15:12] = data;
seven_segment_display(data_14[3:0],led);
seven_segment_display(data_14[7:4],led1);
seven_segment_display(data_14[11:8],led2);
seven_segment_display(data_14[15:12],led3);
arduino_comm = 4'h2;
next_state = S17;
tracker = 8'hF7;
write_to_memory_1(data_14);
end
S17: begin
write_high_1(3'b011);
data_15[15:4] = 0;
data_15[3:0] = data;
seven_segment_display(data_15[3:0],led);
seven_segment_display(data_15[7:4],led1);
seven_segment_display(data_15[11:8],led2);
seven_segment_display(data_15[15:12],led3);
arduino_comm = 4'h2;
next_state = S18;
tracker = 8'hEF;
end
S18: begin
close_write;
data_15[15:8] = 0;
data_15[7:4] = data;
seven_segment_display(data_15[3:0],led);
seven_segment_display(data_15[7:4],led1);
seven_segment_display(data_15[11:8],led2);
seven_segment_display(data_15[15:12],led3);
arduino_comm = 4'h2;
next_state = S19;
tracker = 8'hF7;
end
S19: begin
data_15[15:12] = 0;
data_15[11:8] = data;
seven_segment_display(data_15[3:0],led);
seven_segment_display(data_15[7:4],led1);
seven_segment_display(data_15[11:8],led2);
seven_segment_display(data_15[15:12],led3);
arduino_comm = 4'h2;
next_state = S20;
tracker = 8'hF7;
end
S20: begin
data_15[15:12] = data;
seven_segment_display(data_15[3:0],led);
seven_segment_display(data_15[7:4],led1);
seven_segment_display(data_15[11:8],led2);
seven_segment_display(data_15[15:12],led3);
arduino_comm = 4'h2;
next_state = S21;
write_to_memory_1(data_15);
tracker = 8'hF7;
end
S21:begin
write_high_1(3'b100);
data_16[15:4] = 0;
data_16[3:0] = data;
seven_segment_display(data_16[3:0],led);
seven_segment_display(data_16[7:4],led1);
seven_segment_display(data_16[11:8],led2);
seven_segment_display(data_16[15:12],led3);
arduino_comm = 4'h2;
next_state = S22;
tracker = 8'hF7;
end
S22: begin
close_write;
data_16[15:8] = 0;
data_16[7:4] = data;
seven_segment_display(data_16[3:0],led);
seven_segment_display(data_16[7:4],led1);
seven_segment_display(data_16[11:8],led2);
seven_segment_display(data_16[15:12],led3);
arduino_comm = 4'h2;
next_state = S23;
tracker = 8'hDF;
end
S23: begin
data_16[15:12] = 0;
data_16[11:8] = data;
seven_segment_display(data_16[3:0],led);
seven_segment_display(data_16[7:4],led1);
seven_segment_display(data_16[11:8],led2);
seven_segment_display(data_16[15:12],led3);
arduino_comm = 4'h2;
next_state = S24;
tracker = 8'hDF;
end
S24: begin
data_16[15:12] = data;
seven_segment_display(data_16[3:0],led);
seven_segment_display(data_16[7:4],led1);
seven_segment_display(data_16[11:8],led2);
seven_segment_display(data_16[15:12],led3);
write_to_memory_1(data_16);
arduino_comm = 4'h2;
next_state = S25;
tracker = 8'hDF;
end
S25: begin
write_high_1(3'b101);
data_17[15:4] = 0;
data_17[3:0] = data;
seven_segment_display(data_17[3:0],led);
seven_segment_display(data_17[7:4],led1);
seven_segment_display(data_17[11:8],led2);
seven_segment_display(data_17[15:12],led3);
arduino_comm = 4'h2;
next_state = S26;
tracker = 8'hBF;
end
S26: begin
close_write;
data_17[15:8] = 0;
data_17[7:4] = data;
seven_segment_display(data_17[3:0],led);
seven_segment_display(data_17[7:4],led1);
seven_segment_display(data_17[11:8],led2);
seven_segment_display(data_17[15:12],led3);
arduino_comm = 4'h2;
next_state = S27;
tracker = 8'hBF;
end
S27: begin
data_17[15:12] = 0;
data_17[11:8] = data;
seven_segment_display(data_17[3:0],led);
seven_segment_display(data_17[7:4],led1);
seven_segment_display(data_17[11:8],led2);
seven_segment_display(data_17[15:12],led3);
arduino_comm = 4'h2;
next_state = S28;
tracker = 8'hBF;
end
S28:begin
data_17[15:12] = data;
seven_segment_display(data_17[3:0],led);
seven_segment_display(data_17[7:4],led1);
seven_segment_display(data_17[11:8],led2);
seven_segment_display(data_17[15:12],led3);
arduino_comm = 4'h2;
next_state = S29;
tracker = 8'hBF;
write_to_memory_1(data_17);
end
S29: begin
write_high_1(3'b110);
data_18[15:4] = 0;
data_18[3:0] = data;
seven_segment_display(data_18[3:0],led);
seven_segment_display(data_18[7:4],led1);
seven_segment_display(data_18[11:8],led2);
seven_segment_display(data_18[15:12],led3);
arduino_comm = 4'h2;
next_state = S30;
tracker = 8'h7F;
end
S30: begin
close_write;
data_18[15:8] = 0;
data_18[7:4] = data;
seven_segment_display(data_18[3:0],led);
seven_segment_display(data_18[7:4],led1);
seven_segment_display(data_18[11:8],led2);
seven_segment_display(data_18[15:12],led3);
arduino_comm = 4'h2;
next_state = S31;
tracker = 8'h7F;
end
S31: begin
data_18[15:12] = 0;
data_18[11:8] = data;
seven_segment_display(data_18[3:0],led);
seven_segment_display(data_18[7:4],led1);
seven_segment_display(data_18[11:8],led2);
seven_segment_display(data_18[15:12],led3);
arduino_comm = 4'h2;
next_state = S32;
tracker = 8'h7F;
end
S32: begin
data_18[15:12] = data;
seven_segment_display(data_18[3:0],led);
seven_segment_display(data_18[7:4],led1);
seven_segment_display(data_18[11:8],led2);
seven_segment_display(data_18[15:12],led3);
write_to_memory_1(data_18);
arduino_comm = 4'h2;
next_state = S33;
tracker = 8'h7F;
end
S33: begin
write_high_1(3'b111);
arduino_comm = 4'h3;
data_21[15:4] = 0;
data_21[3:0] = data;
seven_segment_display(data_21[3:0],led);
seven_segment_display(data_21[7:4],led1);
seven_segment_display(data_21[11:8],led2);
seven_segment_display(data_21[15:12],led3);
arduino_comm = 4'h3;
next_state = S34;
tracker = 8'hFE;
end
S34: begin
close_write;
arduino_comm = 4'h3;
data_21[15:8] = 0;
data_21[7:4] = data;
seven_segment_display(data_21[3:0],led);
seven_segment_display(data_21[7:4],led1);
seven_segment_display(data_21[11:8],led2);
seven_segment_display(data_21[15:12],led3);
next_state = S35;
tracker = 8'hFE;
end
S35: begin
data_21[15:12] = 0;
data_21[11:8] = data;
seven_segment_display(data_21[3:0],led);
seven_segment_display(data_21[7:4],led1);
seven_segment_display(data_21[11:8],led2);
seven_segment_display(data_21[15:12],led3);
arduino_comm = 4'h3;
next_state = S36;
tracker = 8'hFE;
end
S36:begin
data_21[15:12] = data;
seven_segment_display(data_21[3:0],led);
seven_segment_display(data_21[7:4],led1);
seven_segment_display(data_21[11:8],led2);
seven_segment_display(data_21[15:12],led3);
next_state = S37;
arduino_comm = 4'h3;
write_to_memory_2(data_21);
tracker = 8'hFE;
end
S37: begin
write_high_2(3'b000);
data_22[15:4] = 0;
data_22[3:0] = data;
seven_segment_display(data_22[3:0],led);
seven_segment_display(data_22[7:4],led1);
seven_segment_display(data_22[11:8],led2);
seven_segment_display(data_22[15:12],led3);
arduino_comm = 4'h3;
next_state = S38;
tracker = 8'hFD;
end
S38: begin
close_write;
data_22[15:8] = 0;
data_22[7:4] = data;
seven_segment_display(data_22[3:0],led);
seven_segment_display(data_22[7:4],led1);
seven_segment_display(data_22[11:8],led2);
seven_segment_display(data_22[15:12],led3);
arduino_comm = 4'h3;
next_state = S39;
tracker = 8'hFD;
end
S39: begin
data_22[15:12] = 0;
data_22[11:8] = data;
seven_segment_display(data_22[3:0],led);
seven_segment_display(data_22[7:4],led1);
seven_segment_display(data_22[11:8],led2);
seven_segment_display(data_22[15:12],led3);
arduino_comm = 4'h3;
next_state = S40;
tracker = 8'hFD;
end
S40: begin
data_22[15:12] = data;
seven_segment_display(data_22[3:0],led);
seven_segment_display(data_22[7:4],led1);
seven_segment_display(data_22[11:8],led2);
seven_segment_display(data_22[15:12],led3);
arduino_comm = 4'h3;
next_state = S41;
write_to_memory_2(data_22);
tracker = 8'hFD;
end
S41: begin
write_high_2(3'b001);
data_23[15:4] = 0;
data_23[3:0] = data;
seven_segment_display(data_23[3:0],led);
seven_segment_display(data_23[7:4],led1);
seven_segment_display(data_23[11:8],led2);
seven_segment_display(data_23[15:12],led3);
arduino_comm = 4'h3;
next_state = S42;
tracker = 8'hFB;
end
S42: begin
close_write;
data_23[15:8] = 0;
data_23[7:4] = data;
seven_segment_display(data_23[3:0],led);
seven_segment_display(data_23[7:4],led1);
seven_segment_display(data_23[11:8],led2);
seven_segment_display(data_23[15:12],led3);
arduino_comm = 4'h3;
next_state = S43;
tracker = 8'hFB;
end
S43: begin
data_23[15:12] = 0;
data_23[11:8] = data;
seven_segment_display(data_23[3:0],led);
seven_segment_display(data_23[7:4],led1);
seven_segment_display(data_23[11:8],led2);
seven_segment_display(data_23[15:12],led3);
arduino_comm = 4'h3;
next_state = S44;
tracker = 8'hFB;
end
S44:begin
data_23[15:12] = data;
seven_segment_display(data_23[3:0],led);
seven_segment_display(data_23[7:4],led1);
seven_segment_display(data_23[11:8],led2);
seven_segment_display(data_23[15:12],led3);
arduino_comm = 4'h3;
next_state = S45;
write_to_memory_2(data_23);
tracker = 8'hFB;
end
S45: begin
write_high_2(3'b010);
data_24[15:4] = 0;
data_24[3:0] = data;
seven_segment_display(data_24[3:0],led);
seven_segment_display(data_24[7:4],led1);
seven_segment_display(data_24[11:8],led2);
seven_segment_display(data_24[15:12],led3);
arduino_comm = 4'h3;
next_state = S46;
tracker = 8'hF7;
end
S46: begin
close_write;
data_24[15:8] = 0;
data_24[7:4] = data;
seven_segment_display(data_24[3:0],led);
seven_segment_display(data_24[7:4],led1);
seven_segment_display(data_24[11:8],led2);
seven_segment_display(data_24[15:12],led3);
arduino_comm = 4'h3;
next_state = S47;
tracker = 8'hF7;
end
S47: begin
data_24[15:12] = 0;
data_24[11:8] = data;
seven_segment_display(data_24[3:0],led);
seven_segment_display(data_24[7:4],led1);
seven_segment_display(data_24[11:8],led2);
seven_segment_display(data_24[15:12],led3);
arduino_comm = 4'h3;
next_state = S48;
tracker = 8'hF7;
end
S48: begin
data_24[15:12] = data;
seven_segment_display(data_24[3:0],led);
seven_segment_display(data_24[7:4],led1);
seven_segment_display(data_24[11:8],led2);
seven_segment_display(data_24[15:12],led3);
arduino_comm = 4'h3;
write_to_memory_2(data_24);
next_state = S49;
tracker = 8'hF7;
end
S49: begin
write_high_2(3'b011);
data_25[15:4] = 0;
data_25[3:0] = data;
seven_segment_display(data_25[3:0],led);
seven_segment_display(data_25[7:4],led1);
seven_segment_display(data_25[11:8],led2);
seven_segment_display(data_25[15:12],led3);
arduino_comm = 4'h3;
next_state = S50;
tracker = 8'hEF;
end
S50: begin
close_write;
data_25[15:8] = 0;
data_25[7:4] = data;
seven_segment_display(data_25[3:0],led);
seven_segment_display(data_25[7:4],led1);
seven_segment_display(data_25[11:8],led2);
seven_segment_display(data_25[15:12],led3);
arduino_comm = 4'h3;
next_state = S51;
tracker = 8'hEF;
end
S51: begin
data_25[15:12] = 0;
data_25[11:8] = data;
seven_segment_display(data_25[3:0],led);
seven_segment_display(data_25[7:4],led1);
seven_segment_display(data_25[11:8],led2);
seven_segment_display(data_25[15:12],led3);
arduino_comm = 4'h3;
next_state = S52;
tracker = 8'hEF;
end
S52:begin
data_25[15:12] = data;
seven_segment_display(data_25[3:0],led);
seven_segment_display(data_25[7:4],led1);
seven_segment_display(data_25[11:8],led2);
seven_segment_display(data_25[15:12],led3);
arduino_comm = 4'h3;
next_state = S53;
write_to_memory_2(data_25);
tracker = 8'hEF;
end
S53: begin
write_high_2(3'b100);
data_26[15:4] = 0;
data_26[3:0] = data;
seven_segment_display(data_26[3:0],led);
seven_segment_display(data_26[7:4],led1);
seven_segment_display(data_26[11:8],led2);
seven_segment_display(data_26[15:12],led3);
arduino_comm=4'h3;
next_state = S54;
tracker = 8'hDF;
end
S54: begin
close_write;
data_26[15:8] = 0;
data_26[7:4] = data;
seven_segment_display(data_26[3:0],led);
seven_segment_display(data_26[7:4],led1);
seven_segment_display(data_26[11:8],led2);
seven_segment_display(data_26[15:12],led3);
arduino_comm=4'h3;
next_state = S55;
tracker = 8'hDF;
end
S55: begin
data_26[15:12] = 0;
data_26[11:8] = data;
seven_segment_display(data_26[3:0],led);
seven_segment_display(data_26[7:4],led1);
seven_segment_display(data_26[11:8],led2);
seven_segment_display(data_26[15:12],led3);
arduino_comm=4'h3;
next_state = S56;
tracker = 8'hDF;
end
S56: begin
data_26[15:12] = data;
seven_segment_display(data_26[3:0],led);
seven_segment_display(data_26[7:4],led1);
seven_segment_display(data_26[11:8],led2);
seven_segment_display(data_26[15:12],led3);
arduino_comm=4'h3;
next_state = S57;
write_to_memory_2(data_26);
tracker = 8'hDF;
end
S57: begin
write_high_2(3'b101);
data_27[15:4] = 0;
data_27[3:0] = data;
seven_segment_display(data_27[3:0],led);
seven_segment_display(data_27[7:4],led1);
seven_segment_display(data_27[11:8],led2);
seven_segment_display(data_27[15:12],led3);
arduino_comm=4'h3;
next_state = S58;
tracker = 8'hBF;
end
S58: begin
close_write;
data_27[15:8] = 0;
data_27[7:4] = data;
seven_segment_display(data_27[3:0],led);
seven_segment_display(data_27[7:4],led1);
seven_segment_display(data_27[11:8],led2);
seven_segment_display(data_27[15:12],led3);
arduino_comm=4'h3;
next_state = S59;
tracker = 8'hBF;
end
S59: begin
data_27[15:12] = 0;
data_27[11:8] = data;
seven_segment_display(data_27[3:0],led);
seven_segment_display(data_27[7:4],led1);
seven_segment_display(data_27[11:8],led2);
seven_segment_display(data_27[15:12],led3);
arduino_comm=4'h3;
next_state = S60;
tracker = 8'hBF;
end
S60:begin
data_27[15:12] = data;
seven_segment_display(data_27[3:0],led);
seven_segment_display(data_27[7:4],led1);
seven_segment_display(data_27[11:8],led2);
seven_segment_display(data_27[15:12],led3);
arduino_comm=4'h3;
next_state = S61;
write_to_memory_2(data_27);
tracker = 8'hBF;
end
S61: begin
write_high_2(3'b110);
data_28[15:4] = 0;
data_28[3:0] = data;
seven_segment_display(data_28[3:0],led);
seven_segment_display(data_28[7:4],led1);
seven_segment_display(data_28[11:8],led2);
seven_segment_display(data_28[15:12],led3);
arduino_comm=4'h3;
next_state = S62;
tracker = 8'h7F;
end
S62: begin
close_write;
data_28[15:8] = 0;
data_28[7:4] = data;
seven_segment_display(data_28[3:0],led);
seven_segment_display(data_28[7:4],led1);
seven_segment_display(data_28[11:8],led2);
seven_segment_display(data_28[15:12],led3);
arduino_comm=4'h3;
next_state = S63;
tracker = 8'h7F;
end
S63:begin
data_28[15:12] = 0;
data_28[11:8] = data;
seven_segment_display(data_28[3:0],led);
seven_segment_display(data_28[7:4],led1);
seven_segment_display(data_28[11:8],led2);
seven_segment_display(data_28[15:12],led3);
arduino_comm=4'h3;
next_state = S64;
tracker = 8'h7F;
end
S64: begin
data_28[15:12] = data;
seven_segment_display(data_28[3:0],led);
seven_segment_display(data_28[7:4],led1);
seven_segment_display(data_28[11:8],led2);
seven_segment_display(data_28[15:12],led3);
arduino_comm=4'h3;
next_state = S65;
write_to_memory_2(data_28);
tracker = 8'h7F;
end
S65: begin
write_high_2(3'b111);
mac_rst = 0;
next_state = S66;
i=0;
end
S66: begin
close_write;
read_high_1(i);
next_state = S67;
end
S67: begin
read_from_memory_1(op_data);
read_high_2(i);
next_state = S68;
end
S68: begin
read_from_memory_2(op_data_1);
i = i+1;
if(i==8) next_state = S69;
else next_state = S66;
end
S69: begin
close_read;
op_data_1=0;
op_data = 0;
next_state = S70;
end
S70:begin
next_state = S70;
seven_segment_display(result[3:0],led);
seven_segment_display(result[7:4],led1);
seven_segment_display(result[11:8],led2);
seven_segment_display(result[15:12],led3);
end
endcase
end
always @(posedge clk2 or posedge rst or posedge next_trigger) begin
if(rst) current_state = 0;
current_state=next_state;
end
task write_high_1(input [2:0] addr);
address =addr;
select = 0;
write_enable = 0;
endtask
task write_high_2(input [2:0] addr);
address =addr;
select = 1;
write_enable = 0;
endtask
task close_write;
select = 1;
write_enable = 1;
endtask
task read_high_1(input [2:0] addr);
address =addr;
select = 0;
output_enable = 0;
endtask
task read_high_2(input [2:0] addr);
address =addr;
select = 1;
output_enable = 0;
endtask
task close_read;
select = 1;
output_enable = 1;
endtask
task write_to_memory_1(input [15:0] input_data);
data_into_sram1= input_data;
endtask
task write_to_memory_2(input [15:0] input_data);
data_into_sram2= input_data;
endtask
task read_from_memory_1(output reg[15:0] output_data);
output_data =data_from_sram1;
endtask
task read_from_memory_2(output reg[15:0] output_data);
output_data =data_from_sram2;
endtask
task seven_segment_display(input [3:0] number ,output reg [7:0] pattern_display );
case(number)
4'h0: pattern_display <= 8'b11000000;
4'h1: pattern_display <= 8'b11111001;
4'h2: pattern_display <= 8'b10100100;
4'h3: pattern_display <= 8'b10110000;
4'h4: pattern_display <= 8'b10011001;
4'h5: pattern_display <= 8'b10010010;
4'h6: pattern_display <= 8'b10000010;
4'h7: pattern_display <= 8'b11111000;
4'h8: pattern_display <= 8'b10000000;
4'h9: pattern_display <= 8'b10011000;
4'hA: pattern_display <= 8'b10001000;
4'hB: pattern_display <= 8'b10000011;
4'hC: pattern_display <= 8'b11000110;
4'hD: pattern_display <= 8'b10100001;
4'hE: pattern_display <= 8'b10000110;
4'hF: pattern_display <= 8'b10001110;
default: pattern_display <= 8'b11000000;
endcase
endtask
endmodule