-
Notifications
You must be signed in to change notification settings - Fork 0
/
shifter.v
56 lines (50 loc) · 938 Bytes
/
shifter.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
module shifter(A, LA, LR, Y, C); // add all inputs and outputs inside parentheses
// inputs
input [7:0] A;
input LA;
input LR;
// outputs
output [7:0] Y;
output C;
// reg and internal variable definitions
reg [7:0] Y;
reg C;
// implement module here
always @ (*) begin
if (~LR) begin
C <= A[7];
Y[7] <= A[6];
Y[6] <= A[5];
Y[5] <= A[4];
Y[4] <= A[3];
Y[3] <= A[2];
Y[2] <= A[1];
Y[1] <= A[0];
Y[0] <= 1'b0;
end
else begin
if (LA) begin
C <= A[0];
Y[7] <= 1'b0;
Y[6] <= A[7];
Y[5] <= A[6];
Y[4] <= A[5];
Y[3] <= A[4];
Y[2] <= A[3];
Y[1] <= A[2];
Y[0] <= A[1];
end
else begin
C <= A[0];
Y[7] <= A[7];
Y[6] <= A[7];
Y[5] <= A[6];
Y[4] <= A[5];
Y[3] <= A[4];
Y[2] <= A[3];
Y[1] <= A[2];
Y[0] <= A[1];
end
end
end
endmodule