Commit dc92d265 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

initial commit

parents
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#define LUT_SIZE_LOG2 10
#define LUT_SIZE (1<<LUT_SIZE_LOG2)
#define ACC_FRAC_BITS 32
#define ACC_BITS (ACC_FRAC_BITS + LUT_SIZE_LOG2 + 2)
#define SLOPE_BITS 18
#define SLOPE_SHIFT 7
#define LUT_BITS 18
#define LUT_AMPL ((1ULL<<(LUT_BITS-1))-(1<<12))
struct lut_entry {
int value;
int slope;
} lut [LUT_SIZE];
struct dds_state {
uint64_t acc;
uint64_t delta;
};
int dds_update(struct dds_state *s)
{
int rv;
int frac;
int quad;
int index;
index = (s->acc >> (ACC_FRAC_BITS)) & ((1 << LUT_SIZE_LOG2) - 1);
quad = (s->acc >> (ACC_FRAC_BITS + LUT_SIZE_LOG2)) & 1;
frac = (s->acc >> (ACC_FRAC_BITS - SLOPE_BITS)) & ((1ULL << SLOPE_BITS) - 1);
struct lut_entry e;
int sign = 1;
// printf("quad %d index %d \n", quad,index);
switch(quad)
{
case 0:
sign = 1;
break;
case 1:
sign = -1;
break;
}
e=lut[index];
int adj = ((int64_t)e.slope * (int64_t)frac) >> (SLOPE_BITS + SLOPE_SHIFT);
printf("idx %d l %d slope %d frac %d adj %d\n", index, e.value, e.slope, frac, adj);
int dither_bits = 7;
// printf("f %d %d %d\n", frac, e.slope, adj);
int v0 = ((((e.value + adj )* sign))); // + (random()&(1<<dither_bits)-1)) << 1) + 1;
printf("v0 %d\n", v0);
v0 >>= 1;
int vb = v0 & (1<<(dither_bits-1));
v0 >>= (dither_bits - 1);
if(vb) v0 ++;
// printf("v %d adj %d\n", v0, adj);
s->acc += s->delta;
s->acc &= ((1ULL << ACC_BITS) - 1ULL);
return v0;
}
void calc_lut()
{
int i,p;
for(i=0;i<LUT_SIZE;i++)
{
double x0 = M_PI*((double)i/LUT_SIZE);
double x1 = M_PI*((double)(i+1)/LUT_SIZE);
double y0 = (double) LUT_AMPL * sin(x0);
double y1 = (double) LUT_AMPL * sin(x1);
double slope = (y1-y0) * (double)(1<<SLOPE_SHIFT);
// printf("v %.3f [%d] slope %.3f [%d] %d\n", y0, (int)y0, slope, (int)slope );
lut[i].value = (int) y0;
lut[i].slope = (int)slope;
p=lut[i].value;
// printf("lut[%d]=36'h%llx;\n",i, (uint64_t) (lut[i].value & 0x3ffff) | (((uint64_t)lut[i].slope & 0x3ffff) << 18));
}
}
void dds_init(struct dds_state *dds, double freq, double fs)
{
dds->acc = 0;
dds->delta = (uint64_t) (((double)LUT_SIZE * freq/fs) * (double)(1ULL << ACC_FRAC_BITS));
dds->delta = 100000000000ULL;
}
main()
{
struct dds_state dds;
calc_lut();
dds_init(&dds, 11.1111e6, 500e6);
int i;
for(i=0;i<262144;i++)
{
printf("", dds_update(&dds));
}
}
files = ["dds_single_channel.v","lfsr_gen.vhd" ]
`timescale 1ns/1ps
module dds_single_channel
(
clk_i,
rst_n_i,
acc_load_i,
tune_load_i,
acc_i,
tune_i,
dreq_i,
y_o,
lut_addr_o,
lut_data_i
);
parameter integer g_acc_frac_bits = 32;
parameter integer g_dither_init_value = 32'h00000001;
parameter integer g_output_bits = 12;
parameter integer g_lut_sample_bits= 18;
parameter integer g_lut_slope_bits = 18;
parameter integer g_interp_shift = 7;
parameter integer g_lut_size_log2 = 12;
parameter integer g_dither_taps = 32'hD0000001;
parameter integer g_dither_length = 32;
localparam c_dither_bits = (g_lut_sample_bits - g_output_bits - 1);
localparam c_acc_bits = g_acc_frac_bits + g_lut_size_log2 + 1;
localparam c_output_shift = g_lut_sample_bits - g_output_bits;
wire signed [c_dither_bits :0 ] dither_in;
input clk_i;
input rst_n_i;
input acc_load_i;
input tune_load_i;
input [g_acc_frac_bits + g_lut_size_log2 : 0] acc_i;
input [g_acc_frac_bits + g_lut_size_log2 : 0] tune_i;
input dreq_i;
output reg [g_output_bits-1:0] y_o;
output reg [g_lut_size_log2-1:0] lut_addr_o;
input [g_lut_sample_bits + g_lut_slope_bits - 1:0] lut_data_i;
reg [c_acc_bits-1:0] acc0, acc1, tune;
wire [g_lut_size_log2 : 0] phase;
wire [g_lut_slope_bits-1 : 0] frac;
reg [g_lut_slope_bits-1 : 0] frac_d0, frac_d1, frac_d2, frac_d3;
wire half;
reg [g_lut_size_log2-1:0] addr0, addr1,tmp,tmp2,tmp3;
reg [8:0] sign;
reg [g_lut_sample_bits + g_lut_slope_bits-1:0] lut_in;
wire signed [g_lut_slope_bits-1:0] lut_slope;
reg signed [g_lut_slope_bits-1:0] slope_d0;
wire signed [g_lut_sample_bits-1:0] lut_sample;
reg signed [g_lut_sample_bits-1:0] sample_d0;
reg signed [g_lut_sample_bits-1:0] interp, interp_d0;
reg signed [g_lut_sample_bits-1:0] qv;
reg signed [g_output_bits:0] yt;
wire signed [2*g_lut_slope_bits-1:0] interp_mul;
reg [g_dither_length-1:0] lfsr=g_dither_init_value;
assign lut_slope = lut_in[g_lut_sample_bits + g_lut_slope_bits - 1 : g_lut_sample_bits ];
assign lut_sample = lut_in[g_lut_sample_bits - 1 : 0];
assign phase = acc1 [ g_acc_frac_bits + g_lut_size_log2 - 1 : g_acc_frac_bits - 1];
assign half = acc1 [g_acc_frac_bits + g_lut_size_log2];
assign frac = acc1 [g_acc_frac_bits - 1 : g_acc_frac_bits-g_lut_slope_bits];
always@(posedge clk_i)
begin
if (!rst_n_i) begin
lfsr <= g_dither_init_value;
end else if (dreq_i) begin
if(lfsr[0])
lfsr <= {1'b0, lfsr[g_dither_length-1:1]} ^ g_dither_taps;
else
lfsr <= {1'b0, lfsr[g_dither_length-1:1]};
end
end
assign dither_in = { lfsr[c_dither_bits+4:5], 1'b0 };
assign interp_mul = signed'(lut_slope) * signed'({1'b0, frac_d3});
always@(posedge clk_i)
begin
if (!rst_n_i) begin
acc0 <= 0;
acc1 <= 0;
tune <= 0;
end else begin
if(tune_load_i)
tune <= tune_i;
if(acc_load_i)
acc0 <= acc_i;
if(dreq_i) begin
acc0 <= acc0 + tune;
acc1 <= acc0;
addr0 <= acc1[g_acc_frac_bits + g_lut_size_log2-1 : g_acc_frac_bits];
sign <= {sign[7:0], half };
lut_addr_o <= addr0;
lut_in <= lut_data_i;
frac_d0 <= frac;
frac_d1 <= frac_d0;
frac_d2 <= frac_d1;
frac_d3 <= frac_d2;
interp <= interp_mul >>> (g_lut_slope_bits + g_interp_shift);
sample_d0 <= lut_sample;
qv <= signed'(sample_d0) + signed'(interp) + signed'(dither_in) + 1;
if(sign[5])
yt <= qv >>> (c_output_shift-1);
else
yt <= (-qv) >>> (c_output_shift-1);
if(yt[0])
y_o <= yt[g_output_bits:1] + 1;
else
y_o <= yt[g_output_bits:1];
end
end // else: !if(!rst_n_i)
end // always@ (posedge clk_i)
endmodule // dds_single_channel
library ieee;
use ieee.STD_LOGIC_1164.all;
entity lfsr_gen is
generic (
g_length : integer;
g_init_value : std_logic_vector;
g_taps : std_logic_vector;
g_recurse : integer := 1
);
port (
clk_i : in std_logic;
rst_n_i : in std_logic;
enable_i : in std_logic;
q_o : out std_logic_vector(g_length-1 downto 0)
);
end lfsr_gen;
architecture rtl of lfsr_gen is
subtype t_lfsr_reg is std_logic_vector(g_length-1 downto 0);
function f_next(x : t_lfsr_reg; taps : std_logic_vector; recurse : integer) return t_lfsr_reg is
variable tmp : t_lfsr_reg;
variable t0 : std_logic;
begin
tmp := x;
for i in 1 to recurse loop
t0 := tmp(0);
tmp := '0' & tmp(tmp'length-1 downto 1);
if(t0 = '1')then
tmp := tmp xor taps;
end if;
end loop; -- i
return tmp;
end f_next;
signal r : t_lfsr_reg;
begin -- rtl
p_generate : process(clk_i)
begin
if rising_edge(clk_i) then
if rst_n_i = '0' then
r <= g_init_value;
elsif(enable_i = '1') then
r <= f_next(r, g_taps, g_recurse);
q_o <= r;
end if;
end if;
end process;
end rtl;
action= "simulation"
target= "xilinx"
fetchto="../../ip_cores"
modules = { "local" : [ "../../rtl" ] }
files = ["main.sv"]
vlog_opt="+incdir+../../sim"
lut[0]=36'h30b1c0000;
lut[1]=36'h30b180185;
lut[2]=36'h30b14030b;
lut[3]=36'h30b100490;
lut[4]=36'h30b080616;
lut[5]=36'h30b00079b;
lut[6]=36'h30af40921;
lut[7]=36'h30ae80aa6;
lut[8]=36'h30ad80c2c;
lut[9]=36'h30ac80db1;
lut[10]=36'h30ab40f36;
lut[11]=36'h30aa010bc;
lut[12]=36'h30a881241;
lut[13]=36'h30a7013c6;
lut[14]=36'h30a58154c;
lut[15]=36'h30a3816d1;
lut[16]=36'h30a1c1856;
lut[17]=36'h309fc19db;
lut[18]=36'h309dc1b60;
lut[19]=36'h309b81ce5;
lut[20]=36'h309901e6a;
lut[21]=36'h309681fef;
lut[22]=36'h309402173;
lut[23]=36'h3091422f8;
lut[24]=36'h308e8247c;
lut[25]=36'h308b82601;
lut[26]=36'h308882785;
lut[27]=36'h30854290a;
lut[28]=36'h308202a8e;
lut[29]=36'h307ec2c12;
lut[30]=36'h307b42d96;
lut[31]=36'h307782f1a;
lut[32]=36'h3073c309d;
lut[33]=36'h307003221;
lut[34]=36'h306c033a4;
lut[35]=36'h3067c3528;
lut[36]=36'h3063c36ab;
lut[37]=36'h305f4382e;
lut[38]=36'h305ac39b1;
lut[39]=36'h305643b34;
lut[40]=36'h305183cb7;
lut[41]=36'h304cc3e39;
lut[42]=36'h304803fbc;
lut[43]=36'h3042c413e;
lut[44]=36'h303dc42c0;
lut[45]=36'h303884442;
lut[46]=36'h3033045c4;
lut[47]=36'h302d84745;
lut[48]=36'h3028048c7;
lut[49]=36'h302244a48;
lut[50]=36'h301c84bc9;
lut[51]=36'h301684d4a;
lut[52]=36'h301044ecb;
lut[53]=36'h300a4504b;
lut[54]=36'h3003c51cc;
lut[55]=36'h2ffd8534c;
lut[56]=36'h2ff7054cc;
lut[57]=36'h2ff04564b;
lut[58]=36'h2fe9857cb;
lut[59]=36'h2fe28594a;
lut[60]=36'h2fdb85ac9;
lut[61]=36'h2fd485c48;
lut[62]=36'h2fcd45dc7;
lut[63]=36'h2fc605f45;
lut[64]=36'h2fbe860c3;
lut[65]=36'h2fb6c6241;
lut[66]=36'h2faf463bf;
lut[67]=36'h2fa74653c;
lut[68]=36'h2f9f866ba;
lut[69]=36'h2f9786837;
lut[70]=36'h2f8f469b3;
lut[71]=36'h2f8706b30;
lut[72]=36'h2f7e86cac;
lut[73]=36'h2f7606e28;
lut[74]=36'h2f6d86fa4;
lut[75]=36'h2f64c711f;
lut[76]=36'h2f5c0729a;
lut[77]=36'h2f5307415;
lut[78]=36'h2f4a07590;
lut[79]=36'h2f40c770a;
lut[80]=36'h2f3787884;
lut[81]=36'h2f2e079fe;
lut[82]=36'h2f2487b77;
lut[83]=36'h2f1b07cf0;
lut[84]=36'h2f1147e69;
lut[85]=36'h2f0747fe2;
lut[86]=36'h2efd4815a;
lut[87]=36'h2ef3482d2;
lut[88]=36'h2ee90844a;
lut[89]=36'h2edec85c1;
lut[90]=36'h2ed448738;
lut[91]=36'h2ec9c88af;
lut[92]=36'h2ebf08a25;
lut[93]=36'h2eb448b9b;
lut[94]=36'h2ea988d10;
lut[95]=36'h2e9e88e86;
lut[96]=36'h2e9348ffb;
lut[97]=36'h2e884916f;
lut[98]=36'h2e7cc92e4;
lut[99]=36'h2e7189457;
lut[100]=36'h2e65c95cb;
lut[101]=36'h2e5a4973e;
lut[102]=36'h2e4e898b1;
lut[103]=36'h2e4289a23;
lut[104]=36'h2e3689b96;
lut[105]=36'h2e2a89d07;
lut[106]=36'h2e1e49e79;
lut[107]=36'h2e11c9fea;
lut[108]=36'h2e058a15a;
lut[109]=36'h2df8ca2ca;
lut[110]=36'h2dec4a43a;
lut[111]=36'h2ddf8a5a9;
lut[112]=36'h2dd28a718;
lut[113]=36'h2dc58a887;
lut[114]=36'h2db88a9f5;
lut[115]=36'h2dab4ab63;
lut[116]=36'h2d9e0acd0;
lut[117]=36'h2d908ae3d;
lut[118]=36'h2d830afaa;
lut[119]=36'h2d754b116;
lut[120]=36'h2d678b282;
lut[121]=36'h2d59cb3ed;
lut[122]=36'h2d4bcb558;
lut[123]=36'h2d3d8b6c2;
lut[124]=36'h2d2f4b82c;
lut[125]=36'h2d210b995;
lut[126]=36'h2d12cbafe;
lut[127]=36'h2d040bc67;
lut[128]=36'h2cf58bdcf;
lut[129]=36'h2ce6cbf37;
lut[130]=36'h2cd80c09e;
lut[131]=36'h2cc90c205;
lut[132]=36'h2cb9cc36b;
lut[133]=36'h2caacc4d1;
lut[134]=36'h2c9b8c636;
lut[135]=36'h2c8c0c79b;
lut[136]=36'h2c7c8c8ff;
lut[137]=36'h2c6d0ca63;
lut[138]=36'h2c5d4cbc7;
lut[139]=36'h2c4d4cd2a;
lut[140]=36'h2c3d8ce8c;
lut[141]=36'h2c2d8cfee;
lut[142]=36'h2c1d4d14f;
lut[143]=36'h2c0d0d2b0;
lut[144]=36'h2bfccd411;
lut[145]=36'h2bec4d571;
lut[146]=36'h2bdbcd6d0;
lut[147]=36'h2bcb0d82f;
lut[148]=36'h2bba4d98d;
lut[149]=36'h2ba94daeb;
lut[150]=36'h2b984dc48;
lut[151]=36'h2b874dda5;
lut[152]=36'h2b760df01;
lut[153]=36'h2b64ce05d;
lut[154]=36'h2b534e1b8;
lut[155]=36'h2b41ce313;
lut[156]=36'h2b304e46d;
lut[157]=36'h2b1e8e5c6;
lut[158]=36'h2b0cce71f;
lut[159]=36'h2aface878;
lut[160]=36'h2ae8ce9d0;
lut[161]=36'h2ad68eb27;
lut[162]=36'h2ac44ec7e;
lut[163]=36'h2ab20edd4;
lut[164]=36'h2a9f8ef29;
lut[165]=36'h2a8d0f07e;
lut[166]=36'h2a7a8f1d3;
lut[167]=36'h2a67cf326;
lut[168]=36'h2a54cf47a;
lut[169]=36'h2a41cf5cc;
lut[170]=36'h2a2ecf71e;
lut[171]=36'h2a1bcf870;
lut[172]=36'h2a088f9c1;
lut[173]=36'h29f50fb11;
lut[174]=36'h29e18fc61;
lut[175]=36'h29ce0fdb0;
lut[176]=36'h29ba4fefe;
lut[177]=36'h29a69004c;
lut[178]=36'h2992d0199;
lut[179]=36'h297ed02e6;
lut[180]=36'h296ad0432;
lut[181]=36'h29569057d;
lut[182]=36'h2942506c8;
lut[183]=36'h292e10812;
lut[184]=36'h29199095b;
lut[185]=36'h290510aa4;
lut[186]=36'h28f050bec;
lut[187]=36'h28db90d34;
lut[188]=36'h28c690e7b;
lut[189]=36'h28b1d0fc1;
lut[190]=36'h289c91106;
lut[191]=36'h28879124b;
lut[192]=36'h287251390;
lut[193]=36'h285cd14d3;
lut[194]=36'h284791616;
lut[195]=36'h283211758;
lut[196]=36'h281c5189a;
lut[197]=36'h2806919db;
lut[198]=36'h27f0d1b1b;
lut[199]=36'h27dad1c5a;
lut[200]=36'h27c4d1d99;
lut[201]=36'h27ae91ed7;
lut[202]=36'h279892015;
lut[203]=36'h278212152;
lut[204]=36'h276bd228e;
lut[205]=36'h2755523c9;
lut[206]=36'h273e92504;
lut[207]=36'h27281263e;
lut[208]=36'h271112777;
lut[209]=36'h26fa528b0;
lut[210]=36'h26e3529e7;
lut[211]=36'h26cc52b1e;
lut[212]=36'h26b512c55;
lut[213]=36'h269dd2d8b;
lut[214]=36'h268692ebf;
lut[215]=36'h266f12ff4;
lut[216]=36'h265793127;
lut[217]=36'h263fd325a;
lut[218]=36'h26285338c;
lut[219]=36'h2610534bd;
lut[220]=36'h25f8935ee;
lut[221]=36'h25e09371d;
lut[222]=36'h25c89384c;
lut[223]=36'h25b05397b;
lut[224]=36'h259813aa8;
lut[225]=36'h257f93bd5;
lut[226]=36'h256753d01;
lut[227]=36'h254e93e2c;
lut[228]=36'h253613f57;
lut[229]=36'h251d54080;
lut[230]=36'h2504941a9;
lut[231]=36'h24eb942d1;
lut[232]=36'h24d2943f9;
lut[233]=36'h24b99451f;
lut[234]=36'h24a094645;
lut[235]=36'h24875476a;
lut[236]=36'h246dd488e;
lut[237]=36'h2454949b2;
lut[238]=36'h243b14ad4;
lut[239]=36'h242154bf6;
lut[240]=36'h240794d17;
lut[241]=36'h23edd4e38;
lut[242]=36'h23d414f57;
lut[243]=36'h23ba15076;
lut[244]=36'h23a015193;
lut[245]=36'h2386152b0;
lut[246]=36'h236bd53cd;
lut[247]=36'h2351954e8;
lut[248]=36'h233715603;
lut[249]=36'h231c9571c;
lut[250]=36'h230215835;
lut[251]=36'h22e79594d;
lut[252]=36'h22ccd5a65;
lut[253]=36'h22b215b7b;
lut[254]=36'h229715c90;
lut[255]=36'h227c15da5;
lut[256]=36'h226115eb9;
lut[257]=36'h224615fcc;
lut[258]=36'h222ad60de;
lut[259]=36'h220f961f0;
lut[260]=36'h21f416300;
lut[261]=36'h21d896410;
lut[262]=36'h21bd1651f;
lut[263]=36'h21a19662c;
lut[264]=36'h2185d6739;
lut[265]=36'h216a16846;
lut[266]=36'h214e16951;
lut[267]=36'h213256a5b;
lut[268]=36'h211616b65;
lut[269]=36'h20fa16c6e;
lut[270]=36'h20ddd6d76;
lut[271]=36'h20c196e7c;
lut[272]=36'h20a556f83;
lut[273]=36'h2088d7088;
lut[274]=36'h206c5718c;
lut[275]=36'h204fd728f;
lut[276]=36'h203317392;
lut[277]=36'h201697493;
lut[278]=36'h1ff997594;
lut[279]=36'h1fdcd7694;
lut[280]=36'h1fbfd7793;
lut[281]=36'h1fa2d7891;
lut[282]=36'h1f859798e;
lut[283]=36'h1f6897a8a;
lut[284]=36'h1f4b57b85;
lut[285]=36'h1f2dd7c80;
lut[286]=36'h1f1097d79;
lut[287]=36'h1ef317e72;
lut[288]=36'h1ed557f69;
lut[289]=36'h1eb7d8060;
lut[290]=36'h1e9a18156;
lut[291]=36'h1e7c5824b;
lut[292]=36'h1e5e5833e;
lut[293]=36'h1e4098431;
lut[294]=36'h1e2298523;
lut[295]=36'h1e0458614;
lut[296]=36'h1de658705;
lut[297]=36'h1dc8187f4;
lut[298]=36'h1da9d88e2;
lut[299]=36'h1d8b589cf;
lut[300]=36'h1d6cd8abc;
lut[301]=36'h1d4e58ba7;
lut[302]=36'h1d2fd8c92;
lut[303]=36'h1d1118d7b;
lut[304]=36'h1cf298e64;
lut[305]=36'h1cd398f4b;
lut[306]=36'h1cb4d9032;
lut[307]=36'h1c95d9117;
lut[308]=36'h1c76d91fc;
lut[309]=36'h1c57d92e0;
lut[310]=36'h1c38d93c3;
lut[311]=36'h1c19994a4;
lut[312]=36'h1bfa59585;
lut[313]=36'h1bdad9665;
lut[314]=36'h1bbb99744;
lut[315]=36'h1b9c19822;
lut[316]=36'h1b7c998ff;
lut[317]=36'h1b5cd99da;
lut[318]=36'h1b3d59ab5;
lut[319]=36'h1b1d99b8f;
lut[320]=36'h1afd99c68;
lut[321]=36'h1addd9d40;
lut[322]=36'h1abdd9e17;
lut[323]=36'h1a9dd9eed;
lut[324]=36'h1a7dd9fc2;
lut[325]=36'h1a5dda096;
lut[326]=36'h1a3d9a169;
lut[327]=36'h1a1d5a23b;
lut[328]=36'h19fd1a30c;
lut[329]=36'h19dc9a3dc;
lut[330]=36'h19bc1a4aa;
lut[331]=36'h199b9a578;
lut[332]=36'h197b1a645;
lut[333]=36'h195a9a711;
lut[334]=36'h1939da7dc;
lut[335]=36'h19191a8a6;
lut[336]=36'h18f85a96e;
lut[337]=36'h18d75aa36;
lut[338]=36'h18b69aafd;
lut[339]=36'h18959abc3;
lut[340]=36'h18745ac87;
lut[341]=36'h18535ad4b;
lut[342]=36'h18321ae0e;
lut[343]=36'h18111aecf;
lut[344]=36'h17ef9af90;
lut[345]=36'h17ce5b04f;
lut[346]=36'h17ad1b10e;
lut[347]=36'h178b9b1cb;
lut[348]=36'h176a1b287;
lut[349]=36'h17489b343;
lut[350]=36'h1726db3fd;
lut[351]=36'h17051b4b6;
lut[352]=36'h16e35b56e;
lut[353]=36'h16c19b625;
lut[354]=36'h169fdb6db;
lut[355]=36'h167ddb790;
lut[356]=36'h165c1b844;
lut[357]=36'h163a1b8f7;
lut[358]=36'h1617db9a9;
lut[359]=36'h15f5dba5a;
lut[360]=36'h15d39bb0a;
lut[361]=36'h15b15bbb8;
lut[362]=36'h158f1bc66;
lut[363]=36'h156cdbd12;
lut[364]=36'h154a9bdbe;
lut[365]=36'h15281be68;
lut[366]=36'h15059bf11;
lut[367]=36'h14e31bfb9;
lut[368]=36'h14c09c060;
lut[369]=36'h149ddc106;
lut[370]=36'h147b1c1ab;
lut[371]=36'h14589c24f;
lut[372]=36'h1435dc2f2;
lut[373]=36'h1412dc394;
lut[374]=36'h13f01c434;
lut[375]=36'h13cd1c4d4;
lut[376]=36'h13aa1c572;
lut[377]=36'h13871c610;
lut[378]=36'h13641c6ac;
lut[379]=36'h13411c747;
lut[380]=36'h131ddc7e1;
lut[381]=36'h12fa9c87a;
lut[382]=36'h12d75c912;
lut[383]=36'h12b41c9a8;
lut[384]=36'h1290dca3e;
lut[385]=36'h126d5cad3;
lut[386]=36'h1249dcb66;
lut[387]=36'h12269cbf8;
lut[388]=36'h12031cc89;
lut[389]=36'h11df5cd1a;
lut[390]=36'h11bbdcda9;
lut[391]=36'h11981ce36;
lut[392]=36'h11749cec3;
lut[393]=36'h1150dcf4f;
lut[394]=36'h112d1cfd9;
lut[395]=36'h11091d063;
lut[396]=36'h10e55d0eb;
lut[397]=36'h10c19d172;
lut[398]=36'h109d9d1f8;
lut[399]=36'h10799d27d;
lut[400]=36'h10559d301;
lut[401]=36'h10319d384;
lut[402]=36'h100d5d405;
lut[403]=36'hfe95d486;
lut[404]=36'hfc51d505;
lut[405]=36'hfa0dd583;
lut[406]=36'hf7c9d600;
lut[407]=36'hf585d67c;
lut[408]=36'hf341d6f7;
lut[409]=36'hf0fdd770;
lut[410]=36'heeb5d7e9;
lut[411]=36'hec6dd860;
lut[412]=36'hea29d8d6;
lut[413]=36'he7e1d94c;
lut[414]=36'he595d9c0;
lut[415]=36'he34dda32;
lut[416]=36'he105daa4;
lut[417]=36'hdeb9db14;
lut[418]=36'hdc71db84;
lut[419]=36'hda25dbf2;
lut[420]=36'hd7d9dc5f;
lut[421]=36'hd58ddccb;
lut[422]=36'hd341dd36;
lut[423]=36'hd0f1dd9f;
lut[424]=36'hcea5de08;
lut[425]=36'hcc55de6f;
lut[426]=36'hca09ded5;
lut[427]=36'hc7b9df3a;
lut[428]=36'hc569df9e;
lut[429]=36'hc319e001;
lut[430]=36'hc0c9e063;
lut[431]=36'hbe75e0c3;
lut[432]=36'hbc25e122;
lut[433]=36'hb9d5e180;
lut[434]=36'hb781e1dd;
lut[435]=36'hb52de239;
lut[436]=36'hb2d9e294;
lut[437]=36'hb085e2ed;
lut[438]=36'hae31e345;
lut[439]=36'habdde39c;
lut[440]=36'ha989e3f2;
lut[441]=36'ha735e447;
lut[442]=36'ha4dde49b;
lut[443]=36'ha289e4ed;
lut[444]=36'ha031e53e;
lut[445]=36'h9dd9e58e;
lut[446]=36'h9b81e5dd;
lut[447]=36'h9929e62b;
lut[448]=36'h96d1e678;
lut[449]=36'h9479e6c3;
lut[450]=36'h9221e70d;
lut[451]=36'h8fc9e756;
lut[452]=36'h8d6de79e;
lut[453]=36'h8b15e7e5;
lut[454]=36'h88b9e82b;
lut[455]=36'h8661e86f;
lut[456]=36'h8405e8b2;
lut[457]=36'h81a9e8f4;
lut[458]=36'h7f4de935;
lut[459]=36'h7cf1e975;
lut[460]=36'h7a95e9b3;
lut[461]=36'h7839e9f0;
lut[462]=36'h75ddea2c;
lut[463]=36'h7381ea67;
lut[464]=36'h7121eaa1;
lut[465]=36'h6ec5eada;
lut[466]=36'h6c65eb11;
lut[467]=36'h6a09eb47;
lut[468]=36'h67a9eb7c;
lut[469]=36'h654debb0;
lut[470]=36'h62edebe3;
lut[471]=36'h608dec14;
lut[472]=36'h5e2dec45;
lut[473]=36'h5bcdec74;
lut[474]=36'h5971eca2;
lut[475]=36'h5711ecce;
lut[476]=36'h54b1ecfa;
lut[477]=36'h524ded24;
lut[478]=36'h4feded4d;
lut[479]=36'h4d8ded75;
lut[480]=36'h4b2ded9c;
lut[481]=36'h48cdedc2;
lut[482]=36'h4669ede6;
lut[483]=36'h4409ee09;
lut[484]=36'h41a5ee2b;
lut[485]=36'h3f45ee4c;
lut[486]=36'h3ce1ee6c;
lut[487]=36'h3a81ee8a;
lut[488]=36'h381deea7;
lut[489]=36'h35bdeec4;
lut[490]=36'h3359eede;
lut[491]=36'h30f5eef8;
lut[492]=36'h2e95ef11;
lut[493]=36'h2c31ef28;
lut[494]=36'h29cdef3e;
lut[495]=36'h276def53;
lut[496]=36'h2509ef67;
lut[497]=36'h22a5ef79;
lut[498]=36'h2041ef8a;
lut[499]=36'h1dddef9b;
lut[500]=36'h1b79efa9;
lut[501]=36'h1915efb7;
lut[502]=36'h16b5efc4;
lut[503]=36'h1451efcf;
lut[504]=36'h11edefd9;
lut[505]=36'hf89efe2;
lut[506]=36'hd25efea;
lut[507]=36'hac1eff1;
lut[508]=36'h85deff6;
lut[509]=36'h5f9effa;
lut[510]=36'h395effd;
lut[511]=36'h131efff;
lut[512]=36'hffed1f000;
lut[513]=36'hffc6defff;
lut[514]=36'hffa09effd;
lut[515]=36'hff7a5effa;
lut[516]=36'hff541eff6;
lut[517]=36'hff2ddeff1;
lut[518]=36'hff079efea;
lut[519]=36'hfee15efe2;
lut[520]=36'hfebb1efd9;
lut[521]=36'hfe94defcf;
lut[522]=36'hfe6edefc4;
lut[523]=36'hfe489efb7;
lut[524]=36'hfe225efa9;
lut[525]=36'hfdfc1ef9b;
lut[526]=36'hfdd5def8a;
lut[527]=36'hfdaf9ef79;
lut[528]=36'hfd895ef67;
lut[529]=36'hfd635ef53;
lut[530]=36'hfd3d1ef3e;
lut[531]=36'hfd16def28;
lut[532]=36'hfcf0def11;
lut[533]=36'hfcca9eef8;
lut[534]=36'hfca45eede;
lut[535]=36'hfc7e5eec4;
lut[536]=36'hfc581eea7;
lut[537]=36'hfc321ee8a;
lut[538]=36'hfc0bdee6c;
lut[539]=36'hfbe5dee4c;
lut[540]=36'hfbbf9ee2b;
lut[541]=36'hfb999ee09;
lut[542]=36'hfb735ede6;
lut[543]=36'hfb4d5edc2;
lut[544]=36'hfb275ed9c;
lut[545]=36'hfb015ed75;
lut[546]=36'hfadb5ed4d;
lut[547]=36'hfab51ed24;
lut[548]=36'hfa8f1ecfa;
lut[549]=36'hfa691ecce;
lut[550]=36'hfa435eca2;
lut[551]=36'hfa1d5ec74;
lut[552]=36'hf9f75ec45;
lut[553]=36'hf9d15ec14;
lut[554]=36'hf9ab5ebe3;
lut[555]=36'hf9859ebb0;
lut[556]=36'hf95f9eb7c;
lut[557]=36'hf939deb47;
lut[558]=36'hf913deb11;
lut[559]=36'hf8ee1eada;
lut[560]=36'hf8c81eaa1;
lut[561]=36'hf8a25ea67;
lut[562]=36'hf87c9ea2c;
lut[563]=36'hf856de9f0;
lut[564]=36'hf8311e9b3;
lut[565]=36'hf80b5e975;
lut[566]=36'hf7e59e935;
lut[567]=36'hf7bfde8f4;
lut[568]=36'hf79a1e8b2;
lut[569]=36'hf7749e86f;
lut[570]=36'hf74ede82b;
lut[571]=36'hf7295e7e5;
lut[572]=36'hf7039e79e;
lut[573]=36'hf6de1e756;
lut[574]=36'hf6b89e70d;
lut[575]=36'hf6931e6c3;
lut[576]=36'hf66d9e678;
lut[577]=36'hf6481e62b;
lut[578]=36'hf6229e5dd;
lut[579]=36'hf5fd1e58e;
lut[580]=36'hf5d79e53e;
lut[581]=36'hf5b25e4ed;
lut[582]=36'hf58cde49b;
lut[583]=36'hf5679e447;
lut[584]=36'hf5425e3f2;
lut[585]=36'hf51d1e39c;
lut[586]=36'hf4f7de345;
lut[587]=36'hf4d29e2ed;
lut[588]=36'hf4ad5e294;
lut[589]=36'hf4881e239;
lut[590]=36'hf462de1dd;
lut[591]=36'hf43dde180;
lut[592]=36'hf418de122;
lut[593]=36'hf3f39e0c3;
lut[594]=36'hf3ce9e063;
lut[595]=36'hf3a99e001;
lut[596]=36'hf3849df9e;
lut[597]=36'hf35f9df3a;
lut[598]=36'hf33added5;
lut[599]=36'hf315dde6f;
lut[600]=36'hf2f11de08;
lut[601]=36'hf2cc1dd9f;
lut[602]=36'hf2a75dd36;
lut[603]=36'hf2829dccb;
lut[604]=36'hf25dddc5f;
lut[605]=36'hf2391dbf2;
lut[606]=36'hf2149db84;
lut[607]=36'hf1efddb14;
lut[608]=36'hf1cb5daa4;
lut[609]=36'hf1a6dda32;
lut[610]=36'hf1821d9c0;
lut[611]=36'hf15d9d94c;
lut[612]=36'hf1395d8d6;
lut[613]=36'hf114dd860;
lut[614]=36'hf0f05d7e9;
lut[615]=36'hf0cc1d770;
lut[616]=36'hf0a7dd6f7;
lut[617]=36'hf0839d67c;
lut[618]=36'hf05f5d600;
lut[619]=36'hf03b1d583;
lut[620]=36'hf016dd505;
lut[621]=36'heff2dd486;
lut[622]=36'hefce9d405;
lut[623]=36'hefaa9d384;
lut[624]=36'hef869d301;
lut[625]=36'hef629d27d;
lut[626]=36'hef3e9d1f8;
lut[627]=36'hef1add172;
lut[628]=36'heef71d0eb;
lut[629]=36'heed31d063;
lut[630]=36'heeaf5cfd9;
lut[631]=36'hee8b9cf4f;
lut[632]=36'hee681cec3;
lut[633]=36'hee445ce36;
lut[634]=36'hee20dcda9;
lut[635]=36'hedfd1cd1a;
lut[636]=36'hedd99cc89;
lut[637]=36'hedb65cbf8;
lut[638]=36'hed92dcb66;
lut[639]=36'hed6f5cad3;
lut[640]=36'hed4c1ca3e;
lut[641]=36'hed28dc9a8;
lut[642]=36'hed059c912;
lut[643]=36'hece25c87a;
lut[644]=36'hecbf1c7e1;
lut[645]=36'hec9c1c747;
lut[646]=36'hec791c6ac;
lut[647]=36'hec561c610;
lut[648]=36'hec331c572;
lut[649]=36'hec101c4d4;
lut[650]=36'hebed5c434;
lut[651]=36'hebca5c394;
lut[652]=36'heba79c2f2;
lut[653]=36'heb851c24f;
lut[654]=36'heb625c1ab;
lut[655]=36'heb3f9c106;
lut[656]=36'heb1d1c060;
lut[657]=36'heafa9bfb9;
lut[658]=36'head81bf11;
lut[659]=36'heab59be68;
lut[660]=36'hea935bdbe;
lut[661]=36'hea711bd12;
lut[662]=36'hea4edbc66;
lut[663]=36'hea2c9bbb8;
lut[664]=36'hea0a5bb0a;
lut[665]=36'he9e85ba5a;
lut[666]=36'he9c61b9a9;
lut[667]=36'he9a41b8f7;
lut[668]=36'he9825b844;
lut[669]=36'he9605b790;
lut[670]=36'he93e9b6db;
lut[671]=36'he91cdb625;
lut[672]=36'he8fb1b56e;
lut[673]=36'he8d95b4b6;
lut[674]=36'he8b79b3fd;
lut[675]=36'he8961b343;
lut[676]=36'he8749b287;
lut[677]=36'he8531b1cb;
lut[678]=36'he831db10e;
lut[679]=36'he8109b04f;
lut[680]=36'he7ef1af90;
lut[681]=36'he7ce1aecf;
lut[682]=36'he7acdae0e;
lut[683]=36'he78bdad4b;
lut[684]=36'he76a9ac87;
lut[685]=36'he7499abc3;
lut[686]=36'he728daafd;
lut[687]=36'he707daa36;
lut[688]=36'he6e71a96e;
lut[689]=36'he6c65a8a6;
lut[690]=36'he6a59a7dc;
lut[691]=36'he6851a711;
lut[692]=36'he6649a645;
lut[693]=36'he6441a578;
lut[694]=36'he6239a4aa;
lut[695]=36'he6031a3dc;
lut[696]=36'he5e2da30c;
lut[697]=36'he5c29a23b;
lut[698]=36'he5a25a169;
lut[699]=36'he5825a096;
lut[700]=36'he56259fc2;
lut[701]=36'he54259eed;
lut[702]=36'he52259e17;
lut[703]=36'he50299d40;
lut[704]=36'he4e299c68;
lut[705]=36'he4c2d9b8f;
lut[706]=36'he4a359ab5;
lut[707]=36'he483999da;
lut[708]=36'he464198ff;
lut[709]=36'he44499822;
lut[710]=36'he42559744;
lut[711]=36'he405d9665;
lut[712]=36'he3e699585;
lut[713]=36'he3c7594a4;
lut[714]=36'he3a8593c3;
lut[715]=36'he389592e0;
lut[716]=36'he36a591fc;
lut[717]=36'he34b59117;
lut[718]=36'he32c99032;
lut[719]=36'he30d98f4b;
lut[720]=36'he2ef18e64;
lut[721]=36'he2d058d7b;
lut[722]=36'he2b1d8c92;
lut[723]=36'he29358ba7;
lut[724]=36'he274d8abc;
lut[725]=36'he256589cf;
lut[726]=36'he238188e2;
lut[727]=36'he219d87f4;
lut[728]=36'he1fbd8705;
lut[729]=36'he1dd98614;
lut[730]=36'he1bf98523;
lut[731]=36'he1a1d8431;
lut[732]=36'he183d833e;
lut[733]=36'he1661824b;
lut[734]=36'he14858156;
lut[735]=36'he12ad8060;
lut[736]=36'he10d17f69;
lut[737]=36'he0ef97e72;
lut[738]=36'he0d257d79;
lut[739]=36'he0b4d7c80;
lut[740]=36'he09797b85;
lut[741]=36'he07a97a8a;
lut[742]=36'he05d5798e;
lut[743]=36'he04057891;
lut[744]=36'he02357793;
lut[745]=36'he00697694;
lut[746]=36'hdfe997594;
lut[747]=36'hdfcd17493;
lut[748]=36'hdfb057392;
lut[749]=36'hdf93d728f;
lut[750]=36'hdf775718c;
lut[751]=36'hdf5ad7088;
lut[752]=36'hdf3e96f83;
lut[753]=36'hdf2256e7c;
lut[754]=36'hdf0616d76;
lut[755]=36'hdeea16c6e;
lut[756]=36'hdecdd6b65;
lut[757]=36'hdeb216a5b;
lut[758]=36'hde9616951;
lut[759]=36'hde7a56846;
lut[760]=36'hde5e96739;
lut[761]=36'hde431662c;
lut[762]=36'hde279651f;
lut[763]=36'hde0c16410;
lut[764]=36'hddf096300;
lut[765]=36'hddd5561f0;
lut[766]=36'hddba160de;
lut[767]=36'hdd9f15fcc;
lut[768]=36'hdd8415eb9;
lut[769]=36'hdd6915da5;
lut[770]=36'hdd4e15c90;
lut[771]=36'hdd3355b7b;
lut[772]=36'hdd1895a65;
lut[773]=36'hdcfe1594d;
lut[774]=36'hdce395835;
lut[775]=36'hdcc91571c;
lut[776]=36'hdcae95603;
lut[777]=36'hdc94554e8;
lut[778]=36'hdc7a153cd;
lut[779]=36'hdc60152b0;
lut[780]=36'hdc4615193;
lut[781]=36'hdc2c15076;
lut[782]=36'hdc1254f57;
lut[783]=36'hdbf894e38;
lut[784]=36'hdbded4d17;
lut[785]=36'hdbc514bf6;
lut[786]=36'hdbab94ad4;
lut[787]=36'hdb92549b2;
lut[788]=36'hdb78d488e;
lut[789]=36'hdb5f9476a;
lut[790]=36'hdb4694645;
lut[791]=36'hdb2d9451f;
lut[792]=36'hdb14943f9;
lut[793]=36'hdafb942d1;
lut[794]=36'hdae2d41a9;
lut[795]=36'hdaca14080;
lut[796]=36'hdab193f57;
lut[797]=36'hda98d3e2c;
lut[798]=36'hda8093d01;
lut[799]=36'hda6813bd5;
lut[800]=36'hda4fd3aa8;
lut[801]=36'hda379397b;
lut[802]=36'hda1f9384c;
lut[803]=36'hda079371d;
lut[804]=36'hd9efd35ee;
lut[805]=36'hd9d7d34bd;
lut[806]=36'hd9c05338c;
lut[807]=36'hd9a89325a;
lut[808]=36'hd99113127;
lut[809]=36'hd97992ff4;
lut[810]=36'hd96252ebf;
lut[811]=36'hd94b12d8b;
lut[812]=36'hd933d2c55;
lut[813]=36'hd91cd2b1e;
lut[814]=36'hd905d29e7;
lut[815]=36'hd8ef128b0;
lut[816]=36'hd8d812777;
lut[817]=36'hd8c19263e;
lut[818]=36'hd8aad2504;
lut[819]=36'hd894523c9;
lut[820]=36'hd87e1228e;
lut[821]=36'hd86792152;
lut[822]=36'hd85192015;
lut[823]=36'hd83b51ed7;
lut[824]=36'hd82551d99;
lut[825]=36'hd80f51c5a;
lut[826]=36'hd7f991b1b;
lut[827]=36'hd7e3d19db;
lut[828]=36'hd7ce1189a;
lut[829]=36'hd7b891758;
lut[830]=36'hd7a351616;
lut[831]=36'hd78dd14d3;
lut[832]=36'hd77891390;
lut[833]=36'hd7639124b;
lut[834]=36'hd74e51106;
lut[835]=36'hd73990fc1;
lut[836]=36'hd72490e7b;
lut[837]=36'hd70fd0d34;
lut[838]=36'hd6fb10bec;
lut[839]=36'hd6e690aa4;
lut[840]=36'hd6d21095b;
lut[841]=36'hd6bdd0812;
lut[842]=36'hd6a9906c8;
lut[843]=36'hd6955057d;
lut[844]=36'hd68150432;
lut[845]=36'hd66d502e6;
lut[846]=36'hd65990199;
lut[847]=36'hd645d004c;
lut[848]=36'hd6320fefe;
lut[849]=36'hd61e8fdb0;
lut[850]=36'hd60b0fc61;
lut[851]=36'hd5f78fb11;
lut[852]=36'hd5e44f9c1;
lut[853]=36'hd5d14f870;
lut[854]=36'hd5be4f71e;
lut[855]=36'hd5ab4f5cc;
lut[856]=36'hd5984f47a;
lut[857]=36'hd5858f326;
lut[858]=36'hd5730f1d3;
lut[859]=36'hd5608f07e;
lut[860]=36'hd54e0ef29;
lut[861]=36'hd53bcedd4;
lut[862]=36'hd5298ec7e;
lut[863]=36'hd5174eb27;
lut[864]=36'hd5054e9d0;
lut[865]=36'hd4f34e878;
lut[866]=36'hd4e18e71f;
lut[867]=36'hd4cfce5c6;
lut[868]=36'hd4be4e46d;
lut[869]=36'hd4acce313;
lut[870]=36'hd49b4e1b8;
lut[871]=36'hd48a0e05d;
lut[872]=36'hd478cdf01;
lut[873]=36'hd467cdda5;
lut[874]=36'hd456cdc48;
lut[875]=36'hd445cdaeb;
lut[876]=36'hd4350d98d;
lut[877]=36'hd4244d82f;
lut[878]=36'hd413cd6d0;
lut[879]=36'hd4034d571;
lut[880]=36'hd3f30d411;
lut[881]=36'hd3e2cd2b0;
lut[882]=36'hd3d28d14f;
lut[883]=36'hd3c28cfee;
lut[884]=36'hd3b2cce8c;
lut[885]=36'hd3a2ccd2a;
lut[886]=36'hd3930cbc7;
lut[887]=36'hd3838ca63;
lut[888]=36'hd3740c8ff;
lut[889]=36'hd3648c79b;
lut[890]=36'hd3554c636;
lut[891]=36'hd3464c4d1;
lut[892]=36'hd3370c36b;
lut[893]=36'hd3280c205;
lut[894]=36'hd3194c09e;
lut[895]=36'hd30a8bf37;
lut[896]=36'hd2fc0bdcf;
lut[897]=36'hd2ed4bc67;
lut[898]=36'hd2df0bafe;
lut[899]=36'hd2d0cb995;
lut[900]=36'hd2c28b82c;
lut[901]=36'hd2b44b6c2;
lut[902]=36'hd2a64b558;
lut[903]=36'hd2988b3ed;
lut[904]=36'hd28acb282;
lut[905]=36'hd27d0b116;
lut[906]=36'hd26f8afaa;
lut[907]=36'hd2620ae3d;
lut[908]=36'hd254cacd0;
lut[909]=36'hd2478ab63;
lut[910]=36'hd23a8a9f5;
lut[911]=36'hd22d8a887;
lut[912]=36'hd2208a718;
lut[913]=36'hd213ca5a9;
lut[914]=36'hd2074a43a;
lut[915]=36'hd1fa8a2ca;
lut[916]=36'hd1ee4a15a;
lut[917]=36'hd1e1c9fea;
lut[918]=36'hd1d589e79;
lut[919]=36'hd1c989d07;
lut[920]=36'hd1bd89b96;
lut[921]=36'hd1b189a23;
lut[922]=36'hd1a5c98b1;
lut[923]=36'hd19a4973e;
lut[924]=36'hd18e895cb;
lut[925]=36'hd18349457;
lut[926]=36'hd177c92e4;
lut[927]=36'hd16cc916f;
lut[928]=36'hd16188ffb;
lut[929]=36'hd15688e86;
lut[930]=36'hd14bc8d10;
lut[931]=36'hd14108b9b;
lut[932]=36'hd13648a25;
lut[933]=36'hd12bc88af;
lut[934]=36'hd12148738;
lut[935]=36'hd117085c1;
lut[936]=36'hd10cc844a;
lut[937]=36'hd102c82d2;
lut[938]=36'hd0f8c815a;
lut[939]=36'hd0eec7fe2;
lut[940]=36'hd0e507e69;
lut[941]=36'hd0db87cf0;
lut[942]=36'hd0d207b77;
lut[943]=36'hd0c8879fe;
lut[944]=36'hd0bf47884;
lut[945]=36'hd0b60770a;
lut[946]=36'hd0ad07590;
lut[947]=36'hd0a407415;
lut[948]=36'hd09b4729a;
lut[949]=36'hd0928711f;
lut[950]=36'hd08a06fa4;
lut[951]=36'hd08186e28;
lut[952]=36'hd07906cac;
lut[953]=36'hd070c6b30;
lut[954]=36'hd068869b3;
lut[955]=36'hd06086837;
lut[956]=36'hd058c66ba;
lut[957]=36'hd050c653c;
lut[958]=36'hd049463bf;
lut[959]=36'hd04186241;
lut[960]=36'hd03a060c3;
lut[961]=36'hd032c5f45;
lut[962]=36'hd02b85dc7;
lut[963]=36'hd02485c48;
lut[964]=36'hd01d85ac9;
lut[965]=36'hd0168594a;
lut[966]=36'hd00fc57cb;
lut[967]=36'hd0090564b;
lut[968]=36'hd002854cc;
lut[969]=36'hcffc4534c;
lut[970]=36'hcff5c51cc;
lut[971]=36'hcfefc504b;
lut[972]=36'hcfe984ecb;
lut[973]=36'hcfe384d4a;
lut[974]=36'hcfddc4bc9;
lut[975]=36'hcfd804a48;
lut[976]=36'hcfd2848c7;
lut[977]=36'hcfcd04745;
lut[978]=36'hcfc7845c4;
lut[979]=36'hcfc244442;
lut[980]=36'hcfbd442c0;
lut[981]=36'hcfb80413e;
lut[982]=36'hcfb343fbc;
lut[983]=36'hcfae83e39;
lut[984]=36'hcfa9c3cb7;
lut[985]=36'hcfa543b34;
lut[986]=36'hcfa0c39b1;
lut[987]=36'hcf9c4382e;
lut[988]=36'hcf98436ab;
lut[989]=36'hcf9403528;
lut[990]=36'hcf90033a4;
lut[991]=36'hcf8c43221;
lut[992]=36'hcf888309d;
lut[993]=36'hcf84c2f1a;
lut[994]=36'hcf8142d96;
lut[995]=36'hcf7e02c12;
lut[996]=36'hcf7ac2a8e;
lut[997]=36'hcf778290a;
lut[998]=36'hcf7482785;
lut[999]=36'hcf7182601;
lut[1000]=36'hcf6ec247c;
lut[1001]=36'hcf6c022f8;
lut[1002]=36'hcf6982173;
lut[1003]=36'hcf6701fef;
lut[1004]=36'hcf6481e6a;
lut[1005]=36'hcf6241ce5;
lut[1006]=36'hcf6041b60;
lut[1007]=36'hcf5e419db;
lut[1008]=36'hcf5c81856;
lut[1009]=36'hcf5a816d1;
lut[1010]=36'hcf590154c;
lut[1011]=36'hcf57813c6;
lut[1012]=36'hcf5601241;
lut[1013]=36'hcf54c10bc;
lut[1014]=36'hcf5380f36;
lut[1015]=36'hcf5280db1;
lut[1016]=36'hcf5180c2c;
lut[1017]=36'hcf50c0aa6;
lut[1018]=36'hcf5000921;
lut[1019]=36'hcf4f8079b;
lut[1020]=36'hcf4f00616;
lut[1021]=36'hcf4ec0490;
lut[1022]=36'hcf4e8030b;
lut[1023]=36'hcf4e40185;
module main;
parameter g_lut_size_log2 = 10;
parameter g_lut_sample_bits = 18;
parameter g_lut_slope_bits = 18;
reg clk = 0;
reg rst_n = 0;
reg [g_lut_sample_bits + g_lut_slope_bits-1:0] lut_data;
wire [g_lut_size_log2-1:0] lut_addr;
reg [g_lut_sample_bits + g_lut_slope_bits-1:0] lut[0:2**g_lut_size_log2-1];
wire signed [13:0] y;
always@(posedge clk)
lut_data <= lut[lut_addr];
dds_single_channel #(
.g_lut_sample_bits (g_lut_sample_bits),
.g_lut_slope_bits (g_lut_slope_bits),
.g_lut_size_log2 (g_lut_size_log2),
.g_acc_frac_bits (32),
.g_output_bits(14)
) DUT (
.clk_i (clk),
.rst_n_i (rst_n),
.acc_i (44'h0),
.tune_i (44'd100000000000),
.acc_load_i (1'b0),
.tune_load_i(1'b1),
.dreq_i(1'b1),
// #y_o : out std_logic_vector(g_sample_bits-1 downto 0);
.lut_addr_o (lut_addr),
.lut_data_i (lut_data),
.y_o(y)
);
initial #10ns rst_n = 1;
always #1ns clk <= ~clk;
initial begin
real fs=500e6;
real fout=10.079e6;
int i, lut_size;
lut_size = 2**g_lut_size_log2;
// tune = 44'd100000000000;
//int'(real'(2**g_frac_bits) * real'(2**g_lut_size_log2) / fout / fs * 4.0);
for (i=0;i<lut_size;i++)
begin
real y0,y1,ampl;
reg [g_lut_sample_bits + g_lut_slope_bits-1:0] lv;
ampl = real'((2**(g_lut_sample_bits-1)) - (2 ** 12));
//$display("Amplitude: %.3f\n",ampl);
y0 = ampl * $sin (3.14159265358979323846 / real'(lut_size) * i);
y1 = ampl * $sin (3.14159265358979323846 / real'(lut_size) * (i+1));
lv [g_lut_sample_bits-1:0] = int'(y0);
lv [g_lut_sample_bits+g_lut_slope_bits-1:g_lut_sample_bits] = int' ((y1-y0) * 128.0);
lut[i] = lv;
end
end // initial begin
/* initial begin
`include "lut.v"
end*/
int s_count = 0, l_count = 0;
integer f_out;
initial begin
f_out = $fopen("/tmp/dds-hw.dat","w");
$display("File opened, handle %d", f_out);
end
always@(posedge clk)
begin
s_count <= s_count + 1;
if(s_count > 128)
begin
string s;
l_count <= l_count + 1;
$sformat(s, "%d\n", int'(y));
$fwrite(f_out, s);
if(l_count == 262144)
begin
$fclose(f_out);
$stop;
end
end
end
endmodule // main
make
vlog -sv main.sv +incdir+../../sim
vsim -L unisim work.main -voptargs="+acc" -suppress 8684,8683
set NumericStdNoWarnings 1
set StdArithNoWarnings 1
do wave.do
run 100ns
wave zoomfull
radix -hex
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /main/DUT/g_acc_frac_bits
add wave -noupdate /main/DUT/g_dither_init_value
add wave -noupdate /main/DUT/g_output_bits
add wave -noupdate /main/DUT/g_lut_sample_bits
add wave -noupdate /main/DUT/g_lut_slope_bits
add wave -noupdate /main/DUT/g_interp_shift
add wave -noupdate /main/DUT/g_lut_size_log2
add wave -noupdate /main/DUT/c_acc_bits
add wave -noupdate /main/DUT/c_output_shift
add wave -noupdate /main/DUT/clk_i
add wave -noupdate /main/DUT/rst_n_i
add wave -noupdate /main/DUT/acc_load_i
add wave -noupdate /main/DUT/tune_load_i
add wave -noupdate /main/DUT/acc_i
add wave -noupdate /main/DUT/tune_i
add wave -noupdate /main/DUT/dreq_i
add wave -noupdate -format Analog-Step -height 100 -max 2048.0 -min -2048.0 /main/DUT/y_o
add wave -noupdate -format Analog-Step -height 50 -max 1000.0 -min -1000.0 -radix decimal /main/DUT/interp
add wave -noupdate /main/DUT/lut_addr_o
add wave -noupdate /main/DUT/lut_data_i
add wave -noupdate /main/DUT/acc0
add wave -noupdate /main/DUT/acc1
add wave -noupdate /main/DUT/tune
add wave -noupdate /main/DUT/phase
add wave -noupdate /main/DUT/frac
add wave -noupdate /main/DUT/half
add wave -noupdate /main/DUT/addr0
add wave -noupdate /main/DUT/addr1
add wave -noupdate /main/DUT/tmp
add wave -noupdate /main/DUT/tmp2
add wave -noupdate /main/DUT/sign
add wave -noupdate /main/DUT/lut_in
add wave -noupdate /main/DUT/lut_slope
add wave -noupdate -radix decimal /main/DUT/lut_sample
add wave -noupdate -radix decimal /main/DUT/qv
add wave -noupdate /main/DUT/interp_mul
add wave -noupdate /main/DUT/clk_i
add wave -noupdate /main/DUT/rst_n_i
add wave -noupdate /main/DUT/acc_load_i
add wave -noupdate /main/DUT/tune_load_i
add wave -noupdate /main/DUT/acc_i
add wave -noupdate /main/DUT/tune_i
add wave -noupdate /main/DUT/dreq_i
add wave -noupdate -format Analog-Step -height 100 -max 2048.0 -min -2048.0 /main/DUT/y_o
add wave -noupdate /main/DUT/dither_in
add wave -noupdate /main/DUT/lfsr
add wave -noupdate /main/DUT/lut_addr_o
add wave -noupdate /main/DUT/lut_data_i
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {19833 ps} 0}
configure wave -namecolwidth 150
configure wave -valuecolwidth 100
configure wave -justifyvalue left
configure wave -signalnamewidth 1
configure wave -snapdistance 10
configure wave -datasetprefix 0
configure wave -rowmargin 4
configure wave -childrowmargin 2
configure wave -gridoffset 0
configure wave -gridperiod 1
configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ns
update
WaveRestoreZoom {6845 ps} {33095 ps}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment