-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusr.v
More file actions
56 lines (48 loc) · 1.05 KB
/
Copy pathusr.v
File metadata and controls
56 lines (48 loc) · 1.05 KB
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
`timescale 1ns / 1ps
module usr(
input clk,rst,sin,load,shift,
input [3:0]pin,
input [1:0]mode,
output sout,
output [3:0]pout
);
reg [3:0]temp;
always@(posedge clk)
begin
if(rst)
temp = 4'b0000;
case(mode)
2'b00: //siso
begin
if(shift)
temp <= {sin,temp[3:1]};
else
temp <= temp;
end
2'b01: //sipo
begin
if(shift)
temp <= {sin,temp[3:1]};
else
temp <= temp;
end
2'b10: //piso
begin
if(load)
temp <= pin;
else
temp <= {sin,temp[3:1]};
end
2'b11: //pipo
begin
if(load)
temp <= pin;
else
temp <= temp;
end
default : temp <= temp;
endcase
end
assign sout = temp[0];
assign pout = (shift == 0 && load == 0) ? temp : 1'bx;
endmodule