0
\$\begingroup\$
//Universal shift register..32 bit
// en_out=1 serial out..
//en_out=0..parallel out
module Uni_shft_reg(data_out,
data_in,
s1,s0,
lft_shf,
ryt_shf,
en_out,load,
clk,reset);
output reg [31:0]data_out;
input [31:0]data_in;
input s1,s0,clk,reset,lft_shf,ryt_shf,en_out,load;
reg temp1[31:0],temp2 [31:0],temp3[31:0];
reg f1,f2;
always @(posedge clk or negedge reset)
begin
 if (!reset)
 begin data_out <= 32'd0; end
 else
 begin
 case ({s1,s0})
 2'b00 : data_out <= data_out;
 2'b01 :begin
 if(en_out==1)
 data_out <= {ryt_shf,data_out[31:1]};
 else begin
 temp1[31] <= ryt_shf;
 data_out <= temp1;
 temp1 <= {temp1[30:0],1'b0};
 end
 end
 2'b10 :begin
 case(en_out)
 1'b1: data_out <= {data_out[30:0],lft_shf};
 1'b0: begin
 temp2[0] <= lft_shf ;
 data_out <= temp2;
 temp2 <= {temp2[30:0],1'b0};
 end
 endcase
 end
 2'b11 : begin
 if(en_out==0)
 data_out<=data_in;
 else
 begin
 if (load)
 temp3 <= data_in;
 else
 begin data_out<= temp3[31];
 temp3 <= {temp3[30:0],1'b0};end
 end
 endcase
 end
 endcase
 end
end
endmodule

this is the code which I have written for universal shift register.. On compiling...I am having an error which I am not able to fix.Please help me out.. thanks.

ERROR : Assignment compatible type required for assignment.

errors in the line
line 33 , 34 44 46 58 61 63

Dave Tweed
184k17 gold badges248 silver badges431 bronze badges
asked Jun 24, 2014 at 5:15
\$\endgroup\$
0

1 Answer 1

2
\$\begingroup\$

On line 15, you are declaring arrays: reg temp1[31:0],temp2 [31:0],temp3[31:0] whereas your data_out is a 32 bit vector, not an array.

So, on line 33 you are assigning array value to a single vector value. In ModelSim 10.1d I get

** Error: design.sv(33): Case item comparison: Illegal assignment to type 'reg[31:0]' from type 'reg $[31:0]': Cannot assign an unpacked type to a packed type.

There you go, it says the error happened here : Cannot assign an unpacked type to a packed type. You should declare the temp variables like this:

reg [31:0] temp1,temp2, temp3;

Also, there is an extra endcase syntax on line 61. Here is your modified code

answered Jun 24, 2014 at 8:25
\$\endgroup\$
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.