I wish to send different input data to a module that injects error in the data and sends it to the decoder. The following module works when I give one input data. But when I give more than 1 input data stream, this module only works on the last data stream.
module error_inject (data_in, parity_in, data_out, parity_out, idx_to_flip);
parameter DATA_WIDTH = 13;
parameter IDX_WIDTH = $clog2(DATA_WIDTH);
input [7:0] data_in;
input [4:0] parity_in;
output reg [7:0] data_out;
output reg [4:0] parity_out;
int i;
output reg [IDX_WIDTH-1:0] idx_to_flip;
reg [DATA_WIDTH-1:0] int_data;
always@(data_in)
begin
for (i=0;i<20;i=i+1)
begin
int_data = {data_in, parity_in};
idx_to_flip = $urandom_range(DATA_WIDTH-1);
$display("Flipping data bit %d", idx_to_flip);
int_data[idx_to_flip] = !int_data[idx_to_flip];
$display("bad data = %b",int_data);
data_out = int_data[12:5];
parity_out = int_data[4:0];
#60;
end
end
endmodule
I want the module to iterate over every input data that I provide through the testbench.
Aucun commentaire:
Enregistrer un commentaire