Altera_Forum
Honored Contributor
14 years agoVerilog PIPO Shift-register issue
Hi,
I have this Verilog code that implements a Shift-Register Parallel In - Parallel Out. It should concatenate 2 parallel bits in vector until it reaches 16 (divide the input frequency by 8), when it does it should set an output flag (setOut).
module data_packer
(
input pin, // Parallel Input
input clk,
input reset, // Synchronous and assynchronous state machine controllers
output reg pout, // Parallel Output
output reg setOut // Output ready signal
);
// Declare registers
reg delay_line;
//reg delay_line_out;
reg state;
// Declare states
parameter S0 = 0, S1 = 1, S2 = 2, S3 = 3,
S4 = 4, S5 = 5, S6 = 6, S7 = 7;
// Output depends only on the state
always @ (state) begin
case (state)
S0:
delay_line <= {delay_line, pin};
S1:
delay_line <= {delay_line, pin};
S2:
delay_line <= {delay_line, pin};
S3:
delay_line <= {delay_line, pin};
S4:
delay_line <= {delay_line, pin};
S5:
delay_line <= {delay_line, pin};
S6:
delay_line <= {delay_line, pin};
S7:
delay_line <= {delay_line, pin};
endcase
end
// Determine the next state
always @ (posedge clk or negedge reset) begin
if (~reset) begin
state <= S0;
setOut <= 0;
end
else
case (state)
S0:
state <= S1;
S1:
state <= S2;
S2:
state <= S3;
S3:
begin
state <= S4;
setOut <= 1'b0;
end
S4:
state <= S5;
S5:
state <= S6;
S6:
state <= S7;
S7:
begin
state <= S0;
pout <= delay_line;
setOut <= 1'b1;
end
default:
begin
state <= S0;
setOut <= 1'b0;
end
endcase
end
endmodule
When I compile it it gives me this Warning:
Warning (10235): Verilog HDL Always Construct warning at data_packer_rev0.v(31): variable "delay_line" is read inside the Always Construct but isn't in the Always Construct's Event Control
Warning (10235): Verilog HDL Always Construct warning at data_packer_rev0.v(31): variable "pin" is read inside the Always Construct but isn't in the Always Construct's Event Control Repeated for every case of the "always @ (state) begin". Since, it isn't supposed to enter the case whenever delay_line or pin changes, what it should be done? Even though the warnings, it compiles successfully, but doesn't give any "setOut". Kind regards Pedro Ferreira