module shift_reg (d, clk, reset,q);
input clk, d,reset;
output [3:0] q;
reg [3:0] q = 4'b0000;
always @(posedge clk)
begin
if(!reset)
begin
q <= 0;
end
else
begin
q <= q << 1;
q[0] <= d;
end
end
endmodule
module tb_shiftreg4();
reg D,CLK,RESET;
wire [3:0]Q;
shiftreg4 m(.d(D),.clk(CLK),.reset(RESET),.q(Q));
initial CLK=1'b0;
always #5 CLK=~CLK;
initial
begin
#5 RESET=1'b0;
#15 RESET=1'b1;
end
initial
begin
#15 D=1'b0;
#30 D=1'b1;
#45 D=1'b1;
end
'verilog' 카테고리의 다른 글
12비트 74163 카운터 & Test Bench (0) | 2012.11.11 |
---|---|
74163 카운터 & Test Bench (0) | 2012.11.11 |
Synchronous Reset D플립플롭 & Test Bench (0) | 2012.11.11 |
8비트 Full Adder & Test Bench (0) | 2012.11.11 |
4비트 Full Adder & Test Bench (0) | 2012.11.11 |