M
Mr. Ken
Guest
For example, now I have a 256-bit vector, I need to look up four bit at a
time,
the base location is indicated by variable t0. I prefer to have codes as
concise
as possible since complex "case" statements are too troublesome.
TIA
assign box = {
{4'd13}, {4'd2}, {4'd8}, {4'd4}, {4'd6}, {4'd15}, {4'd11}, {4'd1}, {4'd10},
{4'd9}, {4'd3}, {4'd14}, {4'd5}, {4'd0}, {4'd12}, {4'd7},
{4'd1}, {4'd15}, {4'd13}, {4'd8}, {4'd10}, {4'd3}, {4'd7}, {4'd4}, {4'd12},
{4'd5}, {4'd6}, {4'd11}, {4'd0}, {4'd14}, {4'd9}, {4'd2},
{4'd7}, {4'd11}, {4'd4}, {4'd1}, {4'd9}, {4'd12}, {4'd14}, {4'd2}, {4'd0},
{4'd6}, {4'd10}, {4'd13}, {4'd15}, {4'd3}, {4'd5}, {4'd8},
{4'd2}, {4'd1}, {4'd14}, {4'd7}, {4'd4}, {4'd10}, {4'd8}, {4'd13}, {4'd15},
{4'd12}, {4'd9}, {4'd0}, {4'd3}, {4'd5}, {4'd6}, {4'd11}};
assign t0 = (cond) ? 6'b00001 : variable;
assign s0 = box[{t0, 2'b11}:{t0, 2'b00}];
time,
the base location is indicated by variable t0. I prefer to have codes as
concise
as possible since complex "case" statements are too troublesome.
TIA
assign box = {
{4'd13}, {4'd2}, {4'd8}, {4'd4}, {4'd6}, {4'd15}, {4'd11}, {4'd1}, {4'd10},
{4'd9}, {4'd3}, {4'd14}, {4'd5}, {4'd0}, {4'd12}, {4'd7},
{4'd1}, {4'd15}, {4'd13}, {4'd8}, {4'd10}, {4'd3}, {4'd7}, {4'd4}, {4'd12},
{4'd5}, {4'd6}, {4'd11}, {4'd0}, {4'd14}, {4'd9}, {4'd2},
{4'd7}, {4'd11}, {4'd4}, {4'd1}, {4'd9}, {4'd12}, {4'd14}, {4'd2}, {4'd0},
{4'd6}, {4'd10}, {4'd13}, {4'd15}, {4'd3}, {4'd5}, {4'd8},
{4'd2}, {4'd1}, {4'd14}, {4'd7}, {4'd4}, {4'd10}, {4'd8}, {4'd13}, {4'd15},
{4'd12}, {4'd9}, {4'd0}, {4'd3}, {4'd5}, {4'd6}, {4'd11}};
assign t0 = (cond) ? 6'b00001 : variable;
assign s0 = box[{t0, 2'b11}:{t0, 2'b00}];