how to implement LUT(lookup table) in Verilog


Hi all, I'd like to find out how to implement LUT in Verilog. I've seen two ways to do so: 1) using CASE statement and 2) assigning the values of LUT in "always @(posedge clk)" block. I thought it might also be possible to 3) have a memory in the size of LUT and assign each values from the beginning, then refer to(or copy) its values by indexing(or addressing). I'd like to find out the diffeerences among these three possible ways and know which is the best way to implement LUT. Below is examples of the three ways. Please let me know which method I'd better choose. thanks in advance! // 1) case statement reg [7:0] LUT [0:15]; always @ (addr) begin case (addr) 0: out = 8'h0F; 1: out = 8'h00; 2: out = 8'h01; . . . endcase // 2) assigning in "always @(posedge clk)" block always@(posedge clk) begin LUT[0] = 8'h0F; LUT[1] = 8'h00; LUT[2] = 8'h01; . . . // 3) having memory for LUT and referring by idexing reg [7:0] LUT [0:15] = {8'h0F,8'h00,8'h01,...};

Asked By: thomasc
On: May 10, 2005 11:13:33 PM

Comments(2)



Implimentation (1) The LUT is purely combinational logic, the input of the logic cone being 'addr' and the output being 'out'. Implimentation (2) The value of LUT is stored in registers. Coding out = LUT[addr]; will give an out combinational to addr. However, the implementation will turn out to be a mux whose inputs are the LUT values fed from registers clocked by CK, select being addr, and output being out. This system can be useful if you want to change the value of LUT w.r.t clock. Implementation (3) The value of LUT is stored in registers initialized to certain values. Coding out = LUT[addr]; will give a ciurcuit very similar to 2. Synthesys tools MAY optimize this to Implimentation (1) by removing registers as they have a fixed value. If you ar elooking for a purely combinational LUT, then Impl (1) may be best for you.
Hi thomasc, apart from those 3 there is one more i.e usage of UDP feature inverilog.UDPs synthesize to LUT.
You have to be logged in to be able to post a comment. To login Click Here. First time? Signup It just takes a few minutes to sign up.
Members with Most Replies
Find Job Openings