-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRegDesloc.vhd
1075 lines (1059 loc) · 42.2 KB
/
RegDesloc.vhd
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
--------------------------------------------------------------------------------
-- Title : Registrador de Deslocamento
-- Project : CPU Multi-ciclo
--------------------------------------------------------------------------------
-- File : RegDesloc.vhd
-- Author : Emannuel Gomes Macêdo <egm@cin.ufpe.br>
-- Fernando Raposo Camara da Silva <frcs@cin.ufpe.br>
-- Pedro Machado Manhães de Castro <pmmc@cin.ufpe.br>
-- Rodrigo Alves Costa <rac2@cin.ufpe.br>
-- Organization : Universidade Federal de Pernambuco
-- Created : 10/07/2002
-- Last update : 26/11/2002
-- Plataform : Flex10K
-- Simulators : Altera Max+plus II
-- Synthesizers :
-- Targets :
-- Dependency :
--------------------------------------------------------------------------------
-- Description : Entidade responsável pelo deslocamento de um vetor de 32
-- bits para a direita e para a esquerda.
-- Entradas:
-- * N: vetor de 5 bits que indica a quantidade de
-- deslocamentos
-- * Shift: vetor de 3 bits que indica a função a ser
-- realizada pelo registrador
-- Abaixo seguem os valores referentes à entrada shift e as
-- respectivas funções do registrador:
--
-- Shift FUNÇÃO DO REGISTRADOR
-- 000 faz nada
-- 001 carrega vetor (sem deslocamentos)
-- 010 deslocamento à esquerda n vezes
-- 011 deslocamento à direita lógico n vezes
-- 100 deslocamento à direita aritmético n vezes
-- 101 rotação à direita n vezes
-- 110 rotação à esquerda n vezes
--------------------------------------------------------------------------------
-- Copyright (c) notice
-- Universidade Federal de Pernambuco (UFPE).
-- CIn - Centro de Informatica.
-- Developed by computer science undergraduate students.
-- This code may be used for educational and non-educational purposes as
-- long as its copyright notice remains unchanged.
--------------------------------------------------------------------------------
-- Revisions : 2
-- Revision Number : 2.0
-- Version : 1.2
-- Date : 26/11/2002
-- Modifier : Marcus Vinicius Lima e Machado <mvlm@cin.ufpe.br>
-- Paulo Roberto Santana Oliveira Filho <prsof@cin.ufpe.br>
-- Viviane Cristina Oliveira Aureliano <vcoa@cin.ufpe.br>
-- Description :
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Revisions : 3
-- Revision Number : 1.2
-- Version : 1.3
-- Date : 08/08/2008
-- Modifier : João Paulo Fernandes Barbosa (jpfb@cin.ufpe.br)
-- Description : Os sinais de entrada e saída passam a ser do tipo std_logic.
--------------------------------------------------------------------------------
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
-- Short name: desl
ENTITY RegDesloc IS
PORT(
Clk : IN STD_LOGIC; -- Clock do sistema
Reset : IN STD_LOGIC; -- Reset
Shift : IN STD_LOGIC_vector (2 downto 0); -- Função a ser realizada pelo registrador
N : IN STD_LOGIC_vector (4 downto 0); -- Quantidade de deslocamentos
Entrada : IN STD_LOGIC_vector (31 downto 0); -- Vetor a ser deslocado
Saida : OUT STD_LOGIC_vector (31 downto 0) -- Vetor deslocado
);
END RegDesloc;
-- Arquitetura que define o comportamento do registrador de deslocamento
-- Simulation
ARCHITECTURE behavioral_arch OF RegDesloc IS
signal temp : STD_LOGIC_vector (31 downto 0); -- Vetor temporário
begin
-- Clocked process
process (Clk, Reset)
begin
if(Reset = '1') then
temp <= "00000000000000000000000000000000";
elsif (Clk = '1' and Clk'event) then
case Shift is
when "000" => -- Faz nada
temp <= temp;
when "001" => -- Carrega vetor de entrada, não faz deslocamentos
temp <= Entrada;
when "010" => -- Deslocamento à esquerda N vezes
case N is
when "00000" => -- Deslocamento à esquerda nenhuma vez
temp <= temp;
when "00001" => -- Deslocamento à esquerda 1 vez
temp(0) <= '0';
temp(31 downto 1) <= temp(30 downto 0);
when "00010" => -- Deslocamento à esquerda 2 vezes
temp(1 downto 0) <= "00";
temp(31 downto 2) <= temp(29 downto 0);
when "00011" => -- Deslocamento à esquerda 3 vezes
temp(2 downto 0) <= "000";
temp(31 downto 3) <= temp(28 downto 0);
when "00100" => -- Deslocamento à esquerda 4 vezes
temp(3 downto 0) <= "0000";
temp(31 downto 4) <= temp(27 downto 0);
when "00101" => -- Deslocamento à esquerda 5 vezes
temp(4 downto 0) <= "00000";
temp(31 downto 5) <= temp(26 downto 0);
when "00110" => -- Deslocamento à esquerda 6 vezes
temp(5 downto 0) <= "000000";
temp(31 downto 6) <= temp(25 downto 0);
when "00111" => -- Deslocamento à esquerda 7 vezes
temp(6 downto 0) <= "0000000";
temp(31 downto 7) <= temp(24 downto 0);
when "01000" => -- e assim sucessivamente...
temp(7 downto 0) <= "00000000";
temp(31 downto 8) <= temp(23 downto 0);
when "01001" =>
temp(8 downto 0) <= "000000000";
temp(31 downto 9) <= temp(22 downto 0);
when "01010" =>
temp(9 downto 0) <= "0000000000";
temp(31 downto 10) <= temp(21 downto 0);
when "01011" =>
temp(10 downto 0) <= "00000000000";
temp(31 downto 11) <= temp(20 downto 0);
when "01100" =>
temp(11 downto 0) <= "000000000000";
temp(31 downto 12) <= temp(19 downto 0);
when "01101" =>
temp(12 downto 0) <= "0000000000000";
temp(31 downto 13) <= temp(18 downto 0);
when "01110" =>
temp(13 downto 0) <= "00000000000000";
temp(31 downto 14) <= temp(17 downto 0);
when "01111" =>
temp(14 downto 0) <= "000000000000000";
temp(31 downto 15) <= temp(16 downto 0);
when "10000" =>
temp(15 downto 0) <= "0000000000000000";
temp(31 downto 16) <= temp(15 downto 0);
when "10001" =>
temp(16 downto 0) <= "00000000000000000";
temp(31 downto 17) <= temp(14 downto 0);
when "10010" =>
temp(17 downto 0) <= "000000000000000000";
temp(31 downto 18) <= temp(13 downto 0);
when "10011" =>
temp(18 downto 0) <= "0000000000000000000";
temp(31 downto 19) <= temp(12 downto 0);
when "10100" =>
temp(19 downto 0) <= "00000000000000000000";
temp(31 downto 20) <= temp(11 downto 0);
when "10101" =>
temp(20 downto 0) <= "000000000000000000000";
temp(31 downto 21) <= temp(10 downto 0);
when "10110" =>
temp(21 downto 0) <= "0000000000000000000000";
temp(31 downto 22) <= temp(9 downto 0);
when "10111" =>
temp(22 downto 0) <= "00000000000000000000000";
temp(31 downto 23) <= temp(8 downto 0);
when "11000" =>
temp(23 downto 0) <= "000000000000000000000000";
temp(31 downto 24) <= temp(7 downto 0);
when "11001" =>
temp(24 downto 0) <= "0000000000000000000000000";
temp(31 downto 25) <= temp(6 downto 0);
when "11010" =>
temp(25 downto 0) <= "00000000000000000000000000";
temp(31 downto 26) <= temp(5 downto 0);
when "11011" =>
temp(26 downto 0) <= "000000000000000000000000000";
temp(31 downto 27) <= temp(4 downto 0);
when "11100" =>
temp(27 downto 0) <= "0000000000000000000000000000";
temp(31 downto 28) <= temp(3 downto 0);
when "11101" =>
temp(28 downto 0) <= "00000000000000000000000000000";
temp(31 downto 29) <= temp(2 downto 0);
when "11110" =>
temp(29 downto 0) <= "000000000000000000000000000000";
temp(31 downto 30) <= temp(1 downto 0);
when "11111" =>
temp(30 downto 0) <= "0000000000000000000000000000000";
temp(31) <= temp(0);
end case;
-- Deslocamento à direita lógico N vezes
when "011" =>
case n is
when "00000" => -- Deslocamento à direita lógico nenhuma vez
temp <= temp;
when "00001" => -- Deslocamento à direita lógico 1 vez
temp(30 downto 0) <= temp(31 downto 1);
temp(31) <= '0';
when "00010" => -- Deslocamento à direita lógico 2 vezes
temp(29 downto 0) <= temp(31 downto 2);
temp(31 downto 30) <= "00";
when "00011" => -- Deslocamento à direita lógico 3 vezes
temp(28 downto 0) <= temp(31 downto 3);
temp(31 downto 29) <= "000";
when "00100" => -- Deslocamento à direita lógico 4 vezes
temp(27 downto 0) <= temp(31 downto 4);
temp(31 downto 28) <= "0000";
when "00101" => -- Deslocamento à direita lógico 5 vezes
temp(26 downto 0) <= temp(31 downto 5);
temp(31 downto 27) <= "00000";
when "00110" => -- Deslocamento à direita lógico 6 vezes
temp(25 downto 0) <= temp(31 downto 6);
temp(31 downto 26) <= "000000";
when "00111" => -- Deslocamento à direita lógico 7 vezes
temp(24 downto 0) <= temp(31 downto 7);
temp(31 downto 25) <= "0000000";
when "01000" => -- Deslocamento à direita lógico 8 vezes
temp(23 downto 0) <= temp(31 downto 8);
temp(31 downto 24) <= "00000000";
when "01001" => -- Deslocamento à direita lógico 9 vezes
temp(22 downto 0) <= temp(31 downto 9);
temp(31 downto 23) <= "000000000";
when "01010" => -- Deslocamento à direita lógico 10 vezes
temp(21 downto 0) <= temp(31 downto 10);
temp(31 downto 22) <= "0000000000";
when "01011" => -- Deslocamento à direita lógico 11 vezes
temp(20 downto 0) <= temp(31 downto 11);
temp(31 downto 21) <= "00000000000";
when "01100" => -- Deslocamento à direita lógico 12 vezes
temp(19 downto 0) <= temp(31 downto 12);
temp(31 downto 20) <= "000000000000";
when "01101" => -- Deslocamento à direita lógico 13 vezes
temp(18 downto 0) <= temp(31 downto 13);
temp(31 downto 19) <= "0000000000000";
when "01110" => -- Deslocamento à direita lógico 14 vezes
temp(17 downto 0) <= temp(31 downto 14);
temp(31 downto 18) <= "00000000000000";
when "01111" => -- Deslocamento à direita lógico 15 vezes
temp(16 downto 0) <= temp(31 downto 15);
temp(31 downto 17) <= "000000000000000";
when "10000" => -- Deslocamento à direita lógico 16 vezes
temp(15 downto 0) <= temp(31 downto 16);
temp(31 downto 16) <= "0000000000000000";
when "10001" => -- Deslocamento à direita lógico 17 vezes
temp(14 downto 0) <= temp(31 downto 17);
temp(31 downto 15) <= "00000000000000000";
when "10010" => -- Deslocamento à direita lógico 18 vezes
temp(13 downto 0) <= temp(31 downto 18);
temp(31 downto 14) <= "000000000000000000";
when "10011" => -- Deslocamento à direita lógico 19 vezes
temp(12 downto 0) <= temp(31 downto 19);
temp(31 downto 13) <= "0000000000000000000";
when "10100" => -- Deslocamento à direita lógico 20 vezes
temp(11 downto 0) <= temp(31 downto 20);
temp(31 downto 12) <= "00000000000000000000";
when "10101" => -- Deslocamento à direita lógico 21 vezes
temp(10 downto 0) <= temp(31 downto 21);
temp(31 downto 11) <= "000000000000000000000";
when "10110" => -- Deslocamento à direita lógico 22 vezes
temp(9 downto 0) <= temp(31 downto 22);
temp(31 downto 10) <= "0000000000000000000000";
when "10111" => -- Deslocamento à direita lógico 23 vezes
temp(8 downto 0) <= temp(31 downto 23);
temp(31 downto 9) <= "00000000000000000000000";
when "11000" => -- Deslocamento à direita lógico 24 vezes
temp(7 downto 0) <= temp(31 downto 24);
temp(31 downto 8) <= "000000000000000000000000";
when "11001" => -- Deslocamento à direita lógico 25 vezes
temp(6 downto 0) <= temp(31 downto 25);
temp(31 downto 7) <= "0000000000000000000000000";
when "11010" => -- Deslocamento à direita lógico 26 vezes
temp(5 downto 0) <= temp(31 downto 26);
temp(31 downto 6) <= "00000000000000000000000000";
when "11011" => -- Deslocamento à direita lógico 27 vezes
temp(4 downto 0) <= temp(31 downto 27);
temp(31 downto 5) <= "000000000000000000000000000";
when "11100" => -- Deslocamento à direita lógico 28 vezes
temp(3 downto 0) <= temp(31 downto 28);
temp(31 downto 4) <= "0000000000000000000000000000";
when "11101" => -- Deslocamento à direita lógico 29 vezes
temp(2 downto 0) <= temp(31 downto 29);
temp(31 downto 3) <= "00000000000000000000000000000";
when "11110" => -- Deslocamento à direita lógico 30 vezes
temp(1 downto 0) <= temp(31 downto 30);
temp(31 downto 2) <= "000000000000000000000000000000";
when "11111" => -- Deslocamento à direita lógico 31 vezes
temp(0) <= temp(31);
temp(31 downto 1) <= "0000000000000000000000000000000";
end case;
-- Deslocamento à direita aritmético N vezes
when "100" =>
case n is
when "00000" => -- Deslocamento à direita aritmético nenhuma vez
temp <= temp;
when "00001" => -- Deslocamento à direita aritmético 1 vezes
temp(30 downto 0) <= temp(31 downto 1);
temp(31) <= temp(31);
when "00010" => -- Deslocamento à direita aritmético 2 vezes
temp(29 downto 0) <= temp(31 downto 2);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "00011" => -- Deslocamento à direita aritmético 3 vezes
temp(28 downto 0) <= temp(31 downto 3);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "00100" => -- Deslocamento à direita aritmético 4 vezes
temp(27 downto 0) <= temp(31 downto 4);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "00101" => -- Deslocamento à direita aritmético 5 vezes
temp(26 downto 0) <= temp(31 downto 5);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "00110" => -- Deslocamento à direita aritmético 6 vezes
temp(25 downto 0) <= temp(31 downto 6);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "00111" => -- Deslocamento à direita aritmético 7 vezes
temp(24 downto 0) <= temp(31 downto 7);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01000" => -- Deslocamento à direita aritmético 8 vezes
temp(23 downto 0) <= temp(31 downto 8);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01001" => -- Deslocamento à direita aritmético 9 vezes
temp(22 downto 0) <= temp(31 downto 9);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01010" => -- Deslocamento à direita aritmético 10 vezes
temp(21 downto 0) <= temp(31 downto 10);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01011" => -- Deslocamento à direita aritmético 11 vezes
temp(20 downto 0) <= temp(31 downto 11);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01100" => -- Deslocamento à direita aritmético 12 vezes
temp(19 downto 0) <= temp(31 downto 12);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01101" => -- Deslocamento à direita aritmético 13 vezes
temp(18 downto 0) <= temp(31 downto 13);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01110" => -- Deslocamento à direita aritmético 14 vezes
temp(17 downto 0) <= temp(31 downto 14);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "01111" => -- Deslocamento à direita aritmético 15 vezes
temp(16 downto 0) <= temp(31 downto 15);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10000" => -- Deslocamento à direita aritmético 16 vezes
temp(15 downto 0) <= temp(31 downto 16);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10001" => -- Deslocamento à direita aritmético 17 vezes
temp(14 downto 0) <= temp(31 downto 17);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10010" => -- Deslocamento à direita aritmético 18 vezes
temp(13 downto 0) <= temp(31 downto 18);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10011" => -- Deslocamento à direita aritmético 19 vezes
temp(12 downto 0) <= temp(31 downto 19);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10100" => -- Deslocamento à direita aritmético 20 vezes
temp(11 downto 0) <= temp(31 downto 20);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10101" => -- Deslocamento à direita aritmético 21 vezes
temp(10 downto 0) <= temp(31 downto 21);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10110" => -- Deslocamento à direita aritmético 22 vezes
temp(9 downto 0) <= temp(31 downto 22);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "10111" => -- Deslocamento à direita aritmético 23 vezes
temp(8 downto 0) <= temp(31 downto 23);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11000" => -- Deslocamento à direita aritmético 24 vezes
temp(7 downto 0) <= temp(31 downto 24);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11001" => -- Deslocamento à direita aritmético 25 vezes
temp(6 downto 0) <= temp(31 downto 25);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11010" => -- Deslocamento à direita aritmético 26 vezes
temp(5 downto 0) <= temp(31 downto 26);
temp(6) <= temp(31);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11011" => -- Deslocamento à direita aritmético 27 vezes
temp(4 downto 0) <= temp(31 downto 27);
temp(5) <= temp(31);
temp(6) <= temp(31);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11100" => -- Deslocamento à direita aritmético 28 vezes
temp(3 downto 0) <= temp(31 downto 28);
temp(4) <= temp(31);
temp(5) <= temp(31);
temp(6) <= temp(31);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11101" => -- Deslocamento à direita aritmético 29 vezes
temp(2 downto 0) <= temp(31 downto 29);
temp(3) <= temp(31);
temp(4) <= temp(31);
temp(5) <= temp(31);
temp(6) <= temp(31);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11110" => -- Deslocamento à direita aritmético 30 vezes
temp(1 downto 0) <= temp(31 downto 30);
temp(2) <= temp(31);
temp(3) <= temp(31);
temp(4) <= temp(31);
temp(5) <= temp(31);
temp(6) <= temp(31);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
when "11111" => -- Deslocamento à direita aritmético 31 vezes
temp(0) <= temp(31);
temp(1) <= temp(31);
temp(2) <= temp(31);
temp(3) <= temp(31);
temp(4) <= temp(31);
temp(5) <= temp(31);
temp(6) <= temp(31);
temp(7) <= temp(31);
temp(8) <= temp(31);
temp(9) <= temp(31);
temp(10) <= temp(31);
temp(11) <= temp(31);
temp(12) <= temp(31);
temp(13) <= temp(31);
temp(14) <= temp(31);
temp(15) <= temp(31);
temp(16) <= temp(31);
temp(17) <= temp(31);
temp(18) <= temp(31);
temp(19) <= temp(31);
temp(20) <= temp(31);
temp(21) <= temp(31);
temp(22) <= temp(31);
temp(23) <= temp(31);
temp(24) <= temp(31);
temp(25) <= temp(31);
temp(26) <= temp(31);
temp(27) <= temp(31);
temp(28) <= temp(31);
temp(29) <= temp(31);
temp(30) <= temp(31);
temp(31) <= temp(31);
end case;
-- Rotação à direita N vezes
when "101" =>
case n is
when "00000" => -- Rotação à direita nenhuma vez
temp <= temp;
when "00001" => -- Rotação à direita 1 vez
temp(30 downto 0) <= temp(31 downto 1);
temp(31) <= temp(0);
when "00010" => -- Rotação à direita 2 vezes
temp(29 downto 0) <= temp(31 downto 2);
temp(31 downto 30) <= temp(1 downto 0);
when "00011" => -- Rotação à direita 3 vezes
temp(28 downto 0) <= temp(31 downto 3);
temp(31 downto 29) <= temp(2 downto 0);
when "00100" => -- Rotação à direita 4 vezes
temp(27 downto 0) <= temp(31 downto 4);
temp(31 downto 28) <= temp(3 downto 0);
when "00101" => -- Rotação à direita 5 vezes
temp(26 downto 0) <= temp(31 downto 5);
temp(31 downto 27) <= temp(4 downto 0);
when "00110" => -- Rotação à direita 6 vezes
temp(25 downto 0) <= temp(31 downto 6);
temp(31 downto 26) <= temp(5 downto 0);
when "00111" => -- Rotação à direita 7 vezes
temp(24 downto 0) <= temp(31 downto 7);
temp(31 downto 25) <= temp(6 downto 0);
when "01000" => -- Rotação à direita 8 vezes
temp(23 downto 0) <= temp(31 downto 8);
temp(31 downto 24) <= temp(7 downto 0);
when "01001" => -- Rotação à direita 9 vezes
temp(22 downto 0) <= temp(31 downto 9);
temp(31 downto 23) <= temp(8 downto 0);
when "01010" => -- Rotação à direita 10 vezes
temp(21 downto 0) <= temp(31 downto 10);
temp(31 downto 22) <= temp(9 downto 0);
when "01011" => -- Rotação à direita 11 vezes
temp(20 downto 0) <= temp(31 downto 11);
temp(31 downto 21) <= temp(10 downto 0);
when "01100" => -- Rotação à direita 12 vezes
temp(19 downto 0) <= temp(31 downto 12);
temp(31 downto 20) <= temp(11 downto 0);
when "01101" => -- Rotação à direita 13 vezes
temp(18 downto 0) <= temp(31 downto 13);
temp(31 downto 19) <= temp(12 downto 0);
when "01110" => -- Rotação à direita 14 vezes
temp(17 downto 0) <= temp(31 downto 14);
temp(31 downto 18) <= temp(13 downto 0);
when "01111" => -- Rotação à direita 15 vezes
temp(16 downto 0) <= temp(31 downto 15);
temp(31 downto 17) <= temp(14 downto 0);
when "10000" => -- Rotação à direita 16 vezes
temp(15 downto 0) <= temp(31 downto 16);
temp(31 downto 16) <= temp(15 downto 0);
when "10001" => -- Rotação à direita 17 vezes
temp(14 downto 0) <= temp(31 downto 17);
temp(31 downto 15) <= temp(16 downto 0);
when "10010" => -- Rotação à direita 18 vezes
temp(13 downto 0) <= temp(31 downto 18);
temp(31 downto 14) <= temp(17 downto 0);
when "10011" => -- Rotação à direita 19 vezes
temp(12 downto 0) <= temp(31 downto 19);
temp(31 downto 13) <= temp(18 downto 0);
when "10100" => -- Rotação à direita 20 vezes
temp(11 downto 0) <= temp(31 downto 20);
temp(31 downto 12) <= temp(19 downto 0);
when "10101" => -- Rotação à direita 21 vezes
temp(10 downto 0) <= temp(31 downto 21);
temp(31 downto 11) <= temp(20 downto 0);
when "10110" => -- Rotação à direita 22 vezes
temp(9 downto 0) <= temp(31 downto 22);
temp(31 downto 10) <= temp(21 downto 0);
when "10111" => -- Rotação à direita 23 vezes
temp(8 downto 0) <= temp(31 downto 23);
temp(31 downto 9) <= temp(22 downto 0);
when "11000" => -- Rotação à direita 24 vezes
temp(7 downto 0) <= temp(31 downto 24);
temp(31 downto 8) <= temp(23 downto 0);
when "11001" => -- Rotação à direita 25 vezes
temp(6 downto 0) <= temp(31 downto 25);
temp(31 downto 7) <= temp(24 downto 0);
when "11010" => -- Rotação à direita 26 vezes
temp(5 downto 0) <= temp(31 downto 26);
temp(31 downto 6) <= temp(25 downto 0);
when "11011" => -- Rotação à direita 27 vezes
temp(4 downto 0) <= temp(31 downto 27);
temp(31 downto 5) <= temp(26 downto 0);
when "11100" => -- Rotação à direita 28 vezes
temp(3 downto 0) <= temp(31 downto 28);
temp(31 downto 4) <= temp(27 downto 0);
when "11101" => -- Rotação à direita 29 vezes
temp(2 downto 0) <= temp(31 downto 29);
temp(31 downto 3) <= temp(28 downto 0);
when "11110" => -- Rotação à direita 30 vezes
temp(1 downto 0) <= temp(31 downto 30);
temp(31 downto 2) <= temp(29 downto 0);
when "11111" => -- Rotação à direita 31 vezes
temp(0) <= temp(31);
temp(31 downto 1) <= temp(30 downto 0);
end case;
-- Rotação à esquerda N vezes
when "110" =>
case n is
when "00000" => -- Rotação à esquerda nenhuma vez
temp <= temp;
when "00001" => -- Rotação à esquerda 1 vez
temp(0) <= temp(31);
temp(31 downto 1) <= temp(30 downto 0);
when "00010" => -- Rotação à esquerda 2 vezes
temp(1 downto 0) <= temp(31 downto 30);
temp(31 downto 2) <= temp(29 downto 0);
when "00011" => -- Rotação à esquerda 3 vezes
temp(2 downto 0) <= temp(31 downto 29);
temp(31 downto 3) <= temp(28 downto 0);
when "00100" => -- Rotação à esquerda 4 vezes
temp(3 downto 0) <= temp(31 downto 28);
temp(31 downto 4) <= temp(27 downto 0);
when "00101" => -- Rotação à esquerda 5 vezes
temp(4 downto 0) <= temp(31 downto 27);
temp(31 downto 5) <= temp(26 downto 0);
when "00110" => -- Rotação à esquerda 6 vezes
temp(5 downto 0) <= temp(31 downto 26);
temp(31 downto 6) <= temp(25 downto 0);
when "00111" => -- Rotação à esquerda 7 vezes
temp(6 downto 0) <= temp(31 downto 25);
temp(31 downto 7) <= temp(24 downto 0);
when "01000" => -- Rotação à esquerda 8 vezes
temp(7 downto 0) <= temp(31 downto 24);
temp(31 downto 8) <= temp(23 downto 0);
when "01001" => -- Rotação à esquerda 9 vezes
temp(8 downto 0) <= temp(31 downto 23);
temp(31 downto 9) <= temp(22 downto 0);
when "01010" => -- Rotação à esquerda 10 vezes
temp(9 downto 0) <= temp(31 downto 22);