OpenCores
URL https://opencores.org/ocsvn/fast_log/fast_log/trunk

Subversion Repositories fast_log

[/] [fast_log/] [trunk/] [Log2pipelined.v] - Diff between revs 3 and 4

Show entire file | Details | Blame | View Log

Rev 3 Rev 4
Line 1... Line 1...
module Log2pipelined
module Log2pipelined
 
 
/*
/*
A fast base-2 logarithm function, 24 bits in, 8 bits out.
A fast base-2 logarithm function, 24 bits (21 used) in, 8 bits out.
Designed and coded by: Michael Dunn, http://www.cantares.on.ca/
Designed and coded by: Michael Dunn, http://www.cantares.on.ca/
(more info at the web site - see "Extras")
(more info at the web site - see "Extras")
Executes every cycle, with a latency of 3.
Executes every cycle, with a latency of 3.
 
 
 
This version has a smallish lookup table, hence, a slightly uneven output.
 
Valid input range = 000100 - FFFFFF. In effect, there is a binary point:
 
xxxx.yy. Logs of inputs below 1.00 are negative, and not handled by this design.
 
 
License: Free to use & modify, but please keep this header intact.
License: Free to use & modify, but please keep this header intact.
July 18, 2010, Kitchener, Ontario, Canada
July 22, 2010, Kitchener, Ontario, Canada
This version not yet tested... In fact, has a problem. Stay tuned.
 
*/
*/
 
 
(
(
        input [23:0]     DIN,
        input [23:0]     DIN,
        input                   clk,
        input                   clk,
Line 22... Line 26...
 
 
reg     [3:0]    priencout1;
reg     [3:0]    priencout1;
reg     [3:0]    priencout2;
reg     [3:0]    priencout2;
reg     [3:0]    priencout3;
reg     [3:0]    priencout3;
reg     [4:0]    barrelout;
reg     [4:0]    barrelout;
reg     [20:0]   barrelin;
reg     [19:0]   barrelin;
reg     [3:0]    LUTout;
reg     [3:0]    LUTout;
 
 
 
 
 
assign  DOUT    =       {priencout3, LUTout};   // Basic top-level connectivity
 
 
always @(posedge clk)                                           // Basic top-level connectivity
always @(posedge clk)
begin
begin
        priencout2      <=      priencout1;
        priencout2      <=      priencout1;
        priencout3      <=      priencout2;
        priencout3      <=      priencout2;
        barrelin        <=      DIN[23:3];
        barrelin        <=      DIN[22:3];
end
end
 
 
assign  DOUT    =       {priencout3, LUTout};
 
 
 
 
 
 
 
wire [20:0] tmp1 =       (barrelin << ~priencout1);
wire [19:0] tmp1 =       (barrelin << ~priencout1);      // Barrel shifter - OMG, it's a primitive in Verilog!
always @(posedge clk)                                           // Barrel shifter - OMG, it's a primitive in Verilog!
always @(posedge clk)
begin
begin
        barrelout       <=      tmp1[19:15];
        barrelout       <=      tmp1[19:15];
end
end
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.