Hi,
There's a few ways to do this. For Xilinx you would probably want to go through Coregen and implement a ROM with an init file.
You can also built the LUT entirely out of slices (as opposed to the specialize block memory structures) by using generic code. Below is an example that should work for probably any FPGA (Xilinx, Altera, etc). The LUT contents are define in-line, so it's not as nice as using a data file. (I'm lazy, so it's only an 8-entry 8-bit LUT).
Finally, for simulation only, you can use the Verilog block "initial" to and $readmemb to read from a file. This won't work if you want to synthesize to real hardware like the code below.
-- Pete
module lut #( parameter INPUT_WIDTH = 3, parameter DATA_WIDTH = 8 ) ( input clk, reset, input [INPUT_WIDTH-1:0] in, output reg [DATA_WIDTH-1:0] out );
wire [DATA_WIDTH-1:0] my_lut_values[2**INPUT_WIDTH-1:0]; wire [0:DATA_WIDTH*(2**INPUT_WIDTH)-1] my_lut_string;
// my string of values that will initialize the LUT: A0, B7, 15, C3,
11, 22, 33, 44 assign my_lut_string = { 64'ha0b715c318223344 };
// put the initialization string into the LUT array genvar i; generate for (i=0; i < 2**INPUT_WIDTH; i=i+1) begin: part_select assign my_lut_values[i] = my_lut_string[(i+1)*DATA_WIDTH-1 -: DATA_WIDTH]; end endgenerate
// do the lookup always @(posedge clk) begin if (reset) out