Here is my module
module shift(
input clk,
input rstn,
input load,
input dir,
input [7:0] LD,
output cout
);
reg [7:0] mem;
assign cout = dir?mem[0]:mem[7] ;
always @(posedge clk or negedge rstn)
begin
if(!rstn)
mem <= 8'h00;
else begin
if(load)
mem <= LD ;
else mem <= mem ;
case(dir)
0 : mem <= mem<<1 ;
1 : mem <= mem>>1 ;
endcase
end
end
endmodule
and here is my testbench.
module shift_tb();
reg clk;
reg rstn;
reg load;
reg dir;
reg[7:0] LD ;
wire cout;
shift UUT(.clk(clk), .rstn(rstn), .load(load), .dir(dir), .LD(LD), .cout(cout));
initial begin
$dumpfile("shift_out.vcd");
$dumpvars(2,shift_tb);
clk = 0 ;
rstn = 0 ;
load = 0;
dir = 0 ;
LD = 8'h00;
#10;
rstn = 1;
LD = 8'h55 ;
load = 1;
dir = 0 ;
#100;
LD = 8'hAA ;
load = 1;
dir = 1;
#100;
LD = 8'hFF;
load = 1;
rstn = 0 ;
#20 ;
$finish;
end
always
#5 clk = ~clk ;
endmodule
In the above code, my internal register "mem" does not take in the values from "LD" (parallel i/p ).
It stays at 0. The code does shift if mem is initialized with a random value say 8'h22 but still doesn't take in LD.
