精华内容
下载资源
问答
  • dds模块 stm32

    2015-08-14 08:52:24
    dds模块 stm32
  • DDS模块资料

    2013-08-30 09:20:15
    DDS模块资料,包含AD9851,程序,原理图,PCB,调试经验,心得等。
  • 直接频率合成DDS模块的ise工程
  • 基于MSP430DDS模块

    2013-11-22 21:53:39
    基于MSP430DDS模块程序,用HB12864显示,AD9850
  • dds模块 ad9850 stm32程序代码 测试可调
  • DDS模块控制程序

    2012-02-23 22:27:39
    新版本:V2版本修正了第一版本的BUG。 PC控制DDS模块软件;一个VC的应用程序。完全控制AD9854的内部寄存器,特别是以位的方式设置AD9854的控制位,可以非常直观,和非常容易掌握DDS芯片的应用;
  • DDS模块详细资料

    2018-01-20 13:51:12
    内含:1.串行、并行程序源码. 2.dds详细资料(包括dds调试心得、ad9850/1芯片手册及各种中文资料。 3 ad9850/1模块原理图 4模块说明书)
  • PC控制DDS模块软件 文件包含一个VB的源码程序,和一个VC的应用程序。 完全控制AD9854的内部寄存器,特别是以位的方式设置AD9854的控制位,可以非常直观,和非常容易掌握DDS芯片的应用。最新版本
  • 作业3 DDS模块设计

    千次阅读 2017-02-08 15:51:44
    作业要求在FPGA上设计一个DDS模块,在DE0 开发板上运行,在FPGA芯片内部合成出数字波形即可。不用输出模拟信号,本模块满足以下条件 使用板载晶振的50MHz时钟,合成以下频率的信号 1、500KHz 正弦波信号。 2、1MHz ...

    作业要求

    在FPGA上设计一个DDS模块,在DE0 开发板上运行,在FPGA芯片内部合成出数字波形即可。不用输出模拟信号,本模块满足以下条件

    • 使用板载晶振的50MHz时钟,合成以下频率的信号
    • 1、500KHz 正弦波信号。 2、1MHz 正弦波信号。 3、3MHz 正弦波信号。
    • 频率字字长32位,波表ROM尺寸为 10比特地址,1024个word
    • 波形格式为2补码格式,12比特量化
    • 每个CLK输出一个有效样点。
    • 输入信号为频率字和频率字输入使能信号
    • 使用板载的拨码开关(Switch)控制生成的波形信号的不同频率。

    注意:波表ROM代码是用matlab或C打印生成的。不要手写

    人工绘制的电路结构RTL设计图

    这里写图片描述

    Quartus扫描生成的电路RTL图

    • 顶层RTL图
      这里写图片描述
    • DDS_CORE_ROM RTL图
      这里写图片描述

    SignalTap截图

    • 500KHz输出正弦波的样值波形截图
      这里写图片描述
    • 1MKHz输出正弦波的样值波形截图
      这里写图片描述
    • 3MKHz输出正弦波的样值波形截图
      这里写图片描述

    设计代码

    1. 生成波表ROM的MATLAB代码

    function generate_DDS_rom()
    clc;
    close all;
    disp('##########################################');
    disp('# generate_DDS_rom() RUN');
    disp('##########################################');
    
    %%///
    %   set your rom config here
    rom_word_len = 12;  % rom data word length in bit
    rom_addr_len = 10;  % rom address word length in bit
    rom_file_name = 'DDS_CORE_ROM.v';  % rom file name
    rom_file_dir  = './';  % rom file dir path
    description   = 'DDS CORE ROM FILE' % rom description
    %%///
    
    rom_vec_len = 2^rom_addr_len;
    index = [0:rom_vec_len-1] .';
    rom_data_vec_float = sin(2*pi*index/rom_vec_len);
    figure; plot(rom_data_vec_float);    % for debug
    rom_data_vec_int = fix(rom_data_vec_float * (2^(rom_word_len-1) - 1));
    figure; plot(rom_data_vec_int);    % for debug
    
    rom_cfg.rom_word_len  = rom_word_len   ;
    rom_cfg.rom_file_name = rom_file_name  ;
    rom_cfg.rom_file_dir  = rom_file_dir   ;
    rom_cfg.description   = description    ;
    gen_rom_rtl(rom_cfg, rom_data_vec_int);
    
    
    end % generate_DDS_rom()
    
    % ///////////////////////////////////////////////////////////////////////////////
    % gen_rom_rtl()
    %   generate synthesizable rom  hdl code(need synthesizer support).
    % ///////////////////////////////////////////////////////////////////////////////
    % INPUT: 
    %   data vector, must be integer value
    %   rom word len
    %   rom file dir string
    %   rom file name string
    % OUTPUT:
    %   verilog format rom file, all data in 2's complement code format
    function gen_rom_rtl(rom_cfg, data_vec);
    
      rom_word_len   = rom_cfg.rom_word_len  ;
      rom_file_name  = rom_cfg.rom_file_name ;
      rom_file_dir   = rom_cfg.rom_file_dir  ;
    
      description    = rom_cfg.description   ;
      data_vec_len = length(data_vec);
      addr_word_len  = ceil(log2(data_vec_len));
    
      % check input be integer value
      data_vec_fixed = fix(data_vec);
      diff_sum = sum(data_vec == data_vec_fixed);
      % all integer elements will cause the diff_sum be vector length 
      if(diff_sum < data_vec_len)
        fprintf(1,'# ERROR, gen_rom_rtl(), input data_vec must be integer value\n');
        return;
      end
    
    
      rom_file_dir_name = strcat(rom_file_dir, rom_file_name);
    
      data_vec_fixed_2c =  data_vec_fixed + (2^rom_word_len) .* (data_vec_fixed < 0);
    
    
      romNum        = 2^addr_word_len;
      data_str_cell  = cell(data_vec_len, 1);
    
      for(idx = 1:data_vec_len)
       data_str_cell{idx} = Dec2BinStr(data_vec_fixed_2c(idx), rom_word_len);
      end % for(idx = 1:data_vec_len)
    
      if(romNum > data_vec_len)
        for(idx = data_vec_len+1:romNum)
         data_str_cell{idx} = Dec2BinStr(0, rom_word_len); 
       end
      end
    
      fid_rom_file = fopen(rom_file_dir_name, 'w');
      if(fid_rom_file == -1)
        errMsg = strcat('ERROR, gen_rom_rtl(), create file',rom_file_dir_name, ',failed');
        fprintf(1, '%s\n', errMsg);
        return;
      end
    
      % rom data print 
      % get rom module name
      rom_name = rom_file_name;
      len_rom_file_name = length(rom_file_name);
      if(rom_name(len_rom_file_name-1:len_rom_file_name) == '.v')
        rom_name(len_rom_file_name-1:len_rom_file_name) = [];
      else
        fprintf(1,'#WARNINIG, gen_rom_rtl(), rom_file_name may error, check it!\n');
      end
      fprintf(fid_rom_file,  ...
      '// ************************************************************** //\n');
      fprintf(fid_rom_file,  ...
      '// FILE    : %s \n', rom_file_name);
      fprintf(fid_rom_file,  ...
      '// DSCP    : %s\n', description);
      fprintf(fid_rom_file,  ...
      '// ABOUT   : auto generated rom file by gen_rom_rtl.m\n');
      fprintf(fid_rom_file,  ...
      '// DATE    : %s \n',  datestr(now));
      fprintf(fid_rom_file,  ...
      '// ************************************************************** //\n');
      % generate the crom module
      fprintf(fid_rom_file, ...
      '// module %s()\n', rom_name);
      fprintf(fid_rom_file, ...
      'module %s(\n', rom_name);
      fprintf(fid_rom_file, ...
      '  CLK    ,           // clock\n');
      fprintf(fid_rom_file, ...
      '  RA     ,           // read address\n');
      fprintf(fid_rom_file, ...
      '  RD     );          // read data\n');
    
      fprintf(fid_rom_file, ...
      'input          CLK;\n');
      fprintf(fid_rom_file, ...
      'input  [%-2d :0] RA;\n', addr_word_len-1); 
      fprintf(fid_rom_file, ...
      'output [%-2d :0] RD;\n', rom_word_len-1);
      fprintf(fid_rom_file, ...
      'reg    [%-2d :0] RD;\n', rom_word_len-1);
    
      fprintf(fid_rom_file, ...
      'always @ (posedge CLK)\n'); 
      fprintf(fid_rom_file, ...
      '  case(RA)\n');
    
      for addr = 0:1:data_vec_len-1
        fprintf(fid_rom_file, ... 
      '     %-2d''d %-6d:RD = #1 %-2d''b %s; ', ...
          addr_word_len,addr, rom_word_len, data_str_cell{addr+1});
        fprintf(fid_rom_file, ... 
      '// %6d 0x%s \n', ...
          data_vec_fixed(addr+1), dec2hex(data_vec_fixed_2c(addr+1)));
    
      end
      fprintf(fid_rom_file, ...
      '  default : RD = #1 0;\n');
      fprintf(fid_rom_file, ...
      '  endcase\n');
    
      fprintf(fid_rom_file, ...
      'endmodule \n');
      fclose(fid_rom_file);
      fprintf(1,'# File: %s written\n', rom_file_dir_name);
    
    end % function gen_rom_rtl() 
    % ////////////////////////////////////////////////////////////////////
    function str = Dec2BinStr(data, word_len)
      str = '';
      for(idx = word_len-1:-1:0)
        bit_val = bitand(1, bitshift(data, -idx));
        str = strcat(str, int2str(bit_val));
      end
    end % function Dec2BinStr()

    2. 波表ROM代码

    module DDS_CORE_ROM(
      CLK    ,           // clock
      RA     ,           // read address
      RD     );          // read data
    input          CLK;
    input  [9  :0] RA;
    output [11 :0] RD;
    reg    [11 :0] RD;
    always @ (posedge CLK)
      case(RA)
         10'd 0     :RD = #1 12'b 000000000000; //      0 0x0 
         10'd 1     :RD = #1 12'b 000000001100; //     12 0xC 
         10'd 2     :RD = #1 12'b 000000011001; //     25 0x19 
         10'd 3     :RD = #1 12'b 000000100101; //     37 0x25 
         10'd 4     :RD = #1 12'b 000000110010; //     50 0x32 
         10'd 5     :RD = #1 12'b 000000111110; //     62 0x3E 
         10'd 6     :RD = #1 12'b 000001001011; //     75 0x4B 
         10'd 7     :RD = #1 12'b 000001010111; //     87 0x57 
         10'd 8     :RD = #1 12'b 000001100100; //    100 0x64 
         10'd 9     :RD = #1 12'b 000001110000; //    112 0x70 
         10'd 10    :RD = #1 12'b 000001111101; //    125 0x7D 
         10'd 11    :RD = #1 12'b 000010001010; //    138 0x8A 
         10'd 12    :RD = #1 12'b 000010010110; //    150 0x96 
         10'd 13    :RD = #1 12'b 000010100011; //    163 0xA3 
         10'd 14    :RD = #1 12'b 000010101111; //    175 0xAF 
         10'd 15    :RD = #1 12'b 000010111100; //    188 0xBC 
         10'd 16    :RD = #1 12'b 000011001000; //    200 0xC8 
         10'd 17    :RD = #1 12'b 000011010101; //    213 0xD5 
         10'd 18    :RD = #1 12'b 000011100001; //    225 0xE1 
         10'd 19    :RD = #1 12'b 000011101110; //    238 0xEE 
         10'd 20    :RD = #1 12'b 000011111010; //    250 0xFA 
         10'd 21    :RD = #1 12'b 000100000111; //    263 0x107 
         10'd 22    :RD = #1 12'b 000100010011; //    275 0x113 
         10'd 23    :RD = #1 12'b 000100011111; //    287 0x11F 
         10'd 24    :RD = #1 12'b 000100101100; //    300 0x12C 
         10'd 25    :RD = #1 12'b 000100111000; //    312 0x138 
         10'd 26    :RD = #1 12'b 000101000101; //    325 0x145 
         10'd 27    :RD = #1 12'b 000101010001; //    337 0x151 
         10'd 28    :RD = #1 12'b 000101011101; //    349 0x15D 
         10'd 29    :RD = #1 12'b 000101101010; //    362 0x16A 
         10'd 30    :RD = #1 12'b 000101110110; //    374 0x176 
         10'd 31    :RD = #1 12'b 000110000011; //    387 0x183 
         10'd 32    :RD = #1 12'b 000110001111; //    399 0x18F 
         10'd 33    :RD = #1 12'b 000110011011; //    411 0x19B 
         10'd 34    :RD = #1 12'b 000110100111; //    423 0x1A7 
         10'd 35    :RD = #1 12'b 000110110100; //    436 0x1B4 
         10'd 36    :RD = #1 12'b 000111000000; //    448 0x1C0 
         10'd 37    :RD = #1 12'b 000111001100; //    460 0x1CC 
         10'd 38    :RD = #1 12'b 000111011000; //    472 0x1D8 
         10'd 39    :RD = #1 12'b 000111100101; //    485 0x1E5 
         10'd 40    :RD = #1 12'b 000111110001; //    497 0x1F1 
         10'd 41    :RD = #1 12'b 000111111101; //    509 0x1FD 
         10'd 42    :RD = #1 12'b 001000001001; //    521 0x209 
         10'd 43    :RD = #1 12'b 001000010101; //    533 0x215 
         10'd 44    :RD = #1 12'b 001000100001; //    545 0x221 
         10'd 45    :RD = #1 12'b 001000101110; //    558 0x22E 
         10'd 46    :RD = #1 12'b 001000111010; //    570 0x23A 
         10'd 47    :RD = #1 12'b 001001000110; //    582 0x246 
         10'd 48    :RD = #1 12'b 001001010010; //    594 0x252 
         10'd 49    :RD = #1 12'b 001001011110; //    606 0x25E 
         10'd 50    :RD = #1 12'b 001001101010; //    618 0x26A 
         10'd 51    :RD = #1 12'b 001001110110; //    630 0x276 
         10'd 52    :RD = #1 12'b 001010000010; //    642 0x282 
         10'd 53    :RD = #1 12'b 001010001110; //    654 0x28E 
         10'd 54    :RD = #1 12'b 001010011001; //    665 0x299 
         10'd 55    :RD = #1 12'b 001010100101; //    677 0x2A5 
         10'd 56    :RD = #1 12'b 001010110001; //    689 0x2B1 
         10'd 57    :RD = #1 12'b 001010111101; //    701 0x2BD 
         10'd 58    :RD = #1 12'b 001011001001; //    713 0x2C9 
         10'd 59    :RD = #1 12'b 001011010100; //    724 0x2D4 
         10'd 60    :RD = #1 12'b 001011100000; //    736 0x2E0 
         10'd 61    :RD = #1 12'b 001011101100; //    748 0x2EC 
         10'd 62    :RD = #1 12'b 001011111000; //    760 0x2F8 
         10'd 63    :RD = #1 12'b 001100000011; //    771 0x303 
         10'd 64    :RD = #1 12'b 001100001111; //    783 0x30F 
         10'd 65    :RD = #1 12'b 001100011010; //    794 0x31A 
         10'd 66    :RD = #1 12'b 001100100110; //    806 0x326 
         10'd 67    :RD = #1 12'b 001100110010; //    818 0x332 
         10'd 68    :RD = #1 12'b 001100111101; //    829 0x33D 
         10'd 69    :RD = #1 12'b 001101001000; //    840 0x348 
         10'd 70    :RD = #1 12'b 001101010100; //    852 0x354 
         10'd 71    :RD = #1 12'b 001101011111; //    863 0x35F 
         10'd 72    :RD = #1 12'b 001101101011; //    875 0x36B 
         10'd 73    :RD = #1 12'b 001101110110; //    886 0x376 
         10'd 74    :RD = #1 12'b 001110000001; //    897 0x381 
         10'd 75    :RD = #1 12'b 001110001101; //    909 0x38D 
         10'd 76    :RD = #1 12'b 001110011000; //    920 0x398 
         10'd 77    :RD = #1 12'b 001110100011; //    931 0x3A3 
         10'd 78    :RD = #1 12'b 001110101110; //    942 0x3AE 
         10'd 79    :RD = #1 12'b 001110111001; //    953 0x3B9 
         10'd 80    :RD = #1 12'b 001111000100; //    964 0x3C4 
         10'd 81    :RD = #1 12'b 001111010000; //    976 0x3D0 
         10'd 82    :RD = #1 12'b 001111011011; //    987 0x3DB 
         10'd 83    :RD = #1 12'b 001111100110; //    998 0x3E6 
         10'd 84    :RD = #1 12'b 001111110000; //   1008 0x3F0 
         10'd 85    :RD = #1 12'b 001111111011; //   1019 0x3FB 
         10'd 86    :RD = #1 12'b 010000000110; //   1030 0x406 
         10'd 87    :RD = #1 12'b 010000010001; //   1041 0x411 
         10'd 88    :RD = #1 12'b 010000011100; //   1052 0x41C 
         10'd 89    :RD = #1 12'b 010000100111; //   1063 0x427 
         10'd 90    :RD = #1 12'b 010000110001; //   1073 0x431 
         10'd 91    :RD = #1 12'b 010000111100; //   1084 0x43C 
         10'd 92    :RD = #1 12'b 010001000111; //   1095 0x447 
         10'd 93    :RD = #1 12'b 010001010001; //   1105 0x451 
         10'd 94    :RD = #1 12'b 010001011100; //   1116 0x45C 
         10'd 95    :RD = #1 12'b 010001100110; //   1126 0x466 
         10'd 96    :RD = #1 12'b 010001110001; //   1137 0x471 
         10'd 97    :RD = #1 12'b 010001111011; //   1147 0x47B 
         10'd 98    :RD = #1 12'b 010010000110; //   1158 0x486 
         10'd 99    :RD = #1 12'b 010010010000; //   1168 0x490 
         10'd 100   :RD = #1 12'b 010010011010; //   1178 0x49A 
         10'd 101   :RD = #1 12'b 010010100100; //   1188 0x4A4 
         10'd 102   :RD = #1 12'b 010010101111; //   1199 0x4AF 
         10'd 103   :RD = #1 12'b 010010111001; //   1209 0x4B9 
         10'd 104   :RD = #1 12'b 010011000011; //   1219 0x4C3 
         10'd 105   :RD = #1 12'b 010011001101; //   1229 0x4CD 
         10'd 106   :RD = #1 12'b 010011010111; //   1239 0x4D7 
         10'd 107   :RD = #1 12'b 010011100001; //   1249 0x4E1 
         10'd 108   :RD = #1 12'b 010011101011; //   1259 0x4EB 
         10'd 109   :RD = #1 12'b 010011110101; //   1269 0x4F5 
         10'd 110   :RD = #1 12'b 010011111111; //   1279 0x4FF 
         10'd 111   :RD = #1 12'b 010100001000; //   1288 0x508 
         10'd 112   :RD = #1 12'b 010100010010; //   1298 0x512 
         10'd 113   :RD = #1 12'b 010100011100; //   1308 0x51C 
         10'd 114   :RD = #1 12'b 010100100101; //   1317 0x525 
         10'd 115   :RD = #1 12'b 010100101111; //   1327 0x52F 
         10'd 116   :RD = #1 12'b 010100111001; //   1337 0x539 
         10'd 117   :RD = #1 12'b 010101000010; //   1346 0x542 
         10'd 118   :RD = #1 12'b 010101001011; //   1355 0x54B 
         10'd 119   :RD = #1 12'b 010101010101; //   1365 0x555 
         10'd 120   :RD = #1 12'b 010101011110; //   1374 0x55E 
         10'd 121   :RD = #1 12'b 010101100111; //   1383 0x567 
         10'd 122   :RD = #1 12'b 010101110001; //   1393 0x571 
         10'd 123   :RD = #1 12'b 010101111010; //   1402 0x57A 
         10'd 124   :RD = #1 12'b 010110000011; //   1411 0x583 
         10'd 125   :RD = #1 12'b 010110001100; //   1420 0x58C 
         10'd 126   :RD = #1 12'b 010110010101; //   1429 0x595 
         10'd 127   :RD = #1 12'b 010110011110; //   1438 0x59E 
         10'd 128   :RD = #1 12'b 010110100111; //   1447 0x5A7 
         10'd 129   :RD = #1 12'b 010110110000; //   1456 0x5B0 
         10'd 130   :RD = #1 12'b 010110111001; //   1465 0x5B9 
         10'd 131   :RD = #1 12'b 010111000001; //   1473 0x5C1 
         10'd 132   :RD = #1 12'b 010111001010; //   1482 0x5CA 
         10'd 133   :RD = #1 12'b 010111010011; //   1491 0x5D3 
         10'd 134   :RD = #1 12'b 010111011011; //   1499 0x5DB 
         10'd 135   :RD = #1 12'b 010111100100; //   1508 0x5E4 
         10'd 136   :RD = #1 12'b 010111101100; //   1516 0x5EC 
         10'd 137   :RD = #1 12'b 010111110101; //   1525 0x5F5 
         10'd 138   :RD = #1 12'b 010111111101; //   1533 0x5FD 
         10'd 139   :RD = #1 12'b 011000000101; //   1541 0x605 
         10'd 140   :RD = #1 12'b 011000001110; //   1550 0x60E 
         10'd 141   :RD = #1 12'b 011000010110; //   1558 0x616 
         10'd 142   :RD = #1 12'b 011000011110; //   1566 0x61E 
         10'd 143   :RD = #1 12'b 011000100110; //   1574 0x626 
         10'd 144   :RD = #1 12'b 011000101110; //   1582 0x62E 
         10'd 145   :RD = #1 12'b 011000110110; //   1590 0x636 
         10'd 146   :RD = #1 12'b 011000111110; //   1598 0x63E 
         10'd 147   :RD = #1 12'b 011001000101; //   1605 0x645 
         10'd 148   :RD = #1 12'b 011001001101; //   1613 0x64D 
         10'd 149   :RD = #1 12'b 011001010101; //   1621 0x655 
         10'd 150   :RD = #1 12'b 011001011101; //   1629 0x65D 
         10'd 151   :RD = #1 12'b 011001100100; //   1636 0x664 
         10'd 152   :RD = #1 12'b 011001101100; //   1644 0x66C 
         10'd 153   :RD = #1 12'b 011001110011; //   1651 0x673 
         10'd 154   :RD = #1 12'b 011001111011; //   1659 0x67B 
         10'd 155   :RD = #1 12'b 011010000010; //   1666 0x682 
         10'd 156   :RD = #1 12'b 011010001001; //   1673 0x689 
         10'd 157   :RD = #1 12'b 011010010000; //   1680 0x690 
         10'd 158   :RD = #1 12'b 011010010111; //   1687 0x697 
         10'd 159   :RD = #1 12'b 011010011111; //   1695 0x69F 
         10'd 160   :RD = #1 12'b 011010100110; //   1702 0x6A6 
         10'd 161   :RD = #1 12'b 011010101100; //   1708 0x6AC 
         10'd 162   :RD = #1 12'b 011010110011; //   1715 0x6B3 
         10'd 163   :RD = #1 12'b 011010111010; //   1722 0x6BA 
         10'd 164   :RD = #1 12'b 011011000001; //   1729 0x6C1 
         10'd 165   :RD = #1 12'b 011011001000; //   1736 0x6C8 
         10'd 166   :RD = #1 12'b 011011001110; //   1742 0x6CE 
         10'd 167   :RD = #1 12'b 011011010101; //   1749 0x6D5 
         10'd 168   :RD = #1 12'b 011011011011; //   1755 0x6DB 
         10'd 169   :RD = #1 12'b 011011100010; //   1762 0x6E2 
         10'd 170   :RD = #1 12'b 011011101000; //   1768 0x6E8 
         10'd 171   :RD = #1 12'b 011011101110; //   1774 0x6EE 
         10'd 172   :RD = #1 12'b 011011110101; //   1781 0x6F5 
         10'd 173   :RD = #1 12'b 011011111011; //   1787 0x6FB 
         10'd 174   :RD = #1 12'b 011100000001; //   1793 0x701 
         10'd 175   :RD = #1 12'b 011100000111; //   1799 0x707 
         10'd 176   :RD = #1 12'b 011100001101; //   1805 0x70D 
         10'd 177   :RD = #1 12'b 011100010011; //   1811 0x713 
         10'd 178   :RD = #1 12'b 011100011000; //   1816 0x718 
         10'd 179   :RD = #1 12'b 011100011110; //   1822 0x71E 
         10'd 180   :RD = #1 12'b 011100100100; //   1828 0x724 
         10'd 181   :RD = #1 12'b 011100101010; //   1834 0x72A 
         10'd 182   :RD = #1 12'b 011100101111; //   1839 0x72F 
         10'd 183   :RD = #1 12'b 011100110101; //   1845 0x735 
         10'd 184   :RD = #1 12'b 011100111010; //   1850 0x73A 
         10'd 185   :RD = #1 12'b 011100111111; //   1855 0x73F 
         10'd 186   :RD = #1 12'b 011101000101; //   1861 0x745 
         10'd 187   :RD = #1 12'b 011101001010; //   1866 0x74A 
         10'd 188   :RD = #1 12'b 011101001111; //   1871 0x74F 
         10'd 189   :RD = #1 12'b 011101010100; //   1876 0x754 
         10'd 190   :RD = #1 12'b 011101011001; //   1881 0x759 
         10'd 191   :RD = #1 12'b 011101011110; //   1886 0x75E 
         10'd 192   :RD = #1 12'b 011101100011; //   1891 0x763 
         10'd 193   :RD = #1 12'b 011101100111; //   1895 0x767 
         10'd 194   :RD = #1 12'b 011101101100; //   1900 0x76C 
         10'd 195   :RD = #1 12'b 011101110001; //   1905 0x771 
         10'd 196   :RD = #1 12'b 011101110101; //   1909 0x775 
         10'd 197   :RD = #1 12'b 011101111010; //   1914 0x77A 
         10'd 198   :RD = #1 12'b 011101111110; //   1918 0x77E 
         10'd 199   :RD = #1 12'b 011110000011; //   1923 0x783 
         10'd 200   :RD = #1 12'b 011110000111; //   1927 0x787 
         10'd 201   :RD = #1 12'b 011110001011; //   1931 0x78B 
         10'd 202   :RD = #1 12'b 011110001111; //   1935 0x78F 
         10'd 203   :RD = #1 12'b 011110010011; //   1939 0x793 
         10'd 204   :RD = #1 12'b 011110010111; //   1943 0x797 
         10'd 205   :RD = #1 12'b 011110011011; //   1947 0x79B 
         10'd 206   :RD = #1 12'b 011110011111; //   1951 0x79F 
         10'd 207   :RD = #1 12'b 011110100011; //   1955 0x7A3 
         10'd 208   :RD = #1 12'b 011110100110; //   1958 0x7A6 
         10'd 209   :RD = #1 12'b 011110101010; //   1962 0x7AA 
         10'd 210   :RD = #1 12'b 011110101110; //   1966 0x7AE 
         10'd 211   :RD = #1 12'b 011110110001; //   1969 0x7B1 
         10'd 212   :RD = #1 12'b 011110110100; //   1972 0x7B4 
         10'd 213   :RD = #1 12'b 011110111000; //   1976 0x7B8 
         10'd 214   :RD = #1 12'b 011110111011; //   1979 0x7BB 
         10'd 215   :RD = #1 12'b 011110111110; //   1982 0x7BE 
         10'd 216   :RD = #1 12'b 011111000001; //   1985 0x7C1 
         10'd 217   :RD = #1 12'b 011111000100; //   1988 0x7C4 
         10'd 218   :RD = #1 12'b 011111000111; //   1991 0x7C7 
         10'd 219   :RD = #1 12'b 011111001010; //   1994 0x7CA 
         10'd 220   :RD = #1 12'b 011111001101; //   1997 0x7CD 
         10'd 221   :RD = #1 12'b 011111001111; //   1999 0x7CF 
         10'd 222   :RD = #1 12'b 011111010010; //   2002 0x7D2 
         10'd 223   :RD = #1 12'b 011111010101; //   2005 0x7D5 
         10'd 224   :RD = #1 12'b 011111010111; //   2007 0x7D7 
         10'd 225   :RD = #1 12'b 011111011010; //   2010 0x7DA 
         10'd 226   :RD = #1 12'b 011111011100; //   2012 0x7DC 
         10'd 227   :RD = #1 12'b 011111011110; //   2014 0x7DE 
         10'd 228   :RD = #1 12'b 011111100000; //   2016 0x7E0 
         10'd 229   :RD = #1 12'b 011111100010; //   2018 0x7E2 
         10'd 230   :RD = #1 12'b 011111100101; //   2021 0x7E5 
         10'd 231   :RD = #1 12'b 011111100110; //   2022 0x7E6 
         10'd 232   :RD = #1 12'b 011111101000; //   2024 0x7E8 
         10'd 233   :RD = #1 12'b 011111101010; //   2026 0x7EA 
         10'd 234   :RD = #1 12'b 011111101100; //   2028 0x7EC 
         10'd 235   :RD = #1 12'b 011111101110; //   2030 0x7EE 
         10'd 236   :RD = #1 12'b 011111101111; //   2031 0x7EF 
         10'd 237   :RD = #1 12'b 011111110001; //   2033 0x7F1 
         10'd 238   :RD = #1 12'b 011111110010; //   2034 0x7F2 
         10'd 239   :RD = #1 12'b 011111110011; //   2035 0x7F3 
         10'd 240   :RD = #1 12'b 011111110101; //   2037 0x7F5 
         10'd 241   :RD = #1 12'b 011111110110; //   2038 0x7F6 
         10'd 242   :RD = #1 12'b 011111110111; //   2039 0x7F7 
         10'd 243   :RD = #1 12'b 011111111000; //   2040 0x7F8 
         10'd 244   :RD = #1 12'b 011111111001; //   2041 0x7F9 
         10'd 245   :RD = #1 12'b 011111111010; //   2042 0x7FA 
         10'd 246   :RD = #1 12'b 011111111011; //   2043 0x7FB 
         10'd 247   :RD = #1 12'b 011111111011; //   2043 0x7FB 
         10'd 248   :RD = #1 12'b 011111111100; //   2044 0x7FC 
         10'd 249   :RD = #1 12'b 011111111101; //   2045 0x7FD 
         10'd 250   :RD = #1 12'b 011111111101; //   2045 0x7FD 
         10'd 251   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 252   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 253   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 254   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 255   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 256   :RD = #1 12'b 011111111111; //   2047 0x7FF 
         10'd 257   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 258   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 259   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 260   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 261   :RD = #1 12'b 011111111110; //   2046 0x7FE 
         10'd 262   :RD = #1 12'b 011111111101; //   2045 0x7FD 
         10'd 263   :RD = #1 12'b 011111111101; //   2045 0x7FD 
         10'd 264   :RD = #1 12'b 011111111100; //   2044 0x7FC 
         10'd 265   :RD = #1 12'b 011111111011; //   2043 0x7FB 
         10'd 266   :RD = #1 12'b 011111111011; //   2043 0x7FB 
         10'd 267   :RD = #1 12'b 011111111010; //   2042 0x7FA 
         10'd 268   :RD = #1 12'b 011111111001; //   2041 0x7F9 
         10'd 269   :RD = #1 12'b 011111111000; //   2040 0x7F8 
         10'd 270   :RD = #1 12'b 011111110111; //   2039 0x7F7 
         10'd 271   :RD = #1 12'b 011111110110; //   2038 0x7F6 
         10'd 272   :RD = #1 12'b 011111110101; //   2037 0x7F5 
         10'd 273   :RD = #1 12'b 011111110011; //   2035 0x7F3 
         10'd 274   :RD = #1 12'b 011111110010; //   2034 0x7F2 
         10'd 275   :RD = #1 12'b 011111110001; //   2033 0x7F1 
         10'd 276   :RD = #1 12'b 011111101111; //   2031 0x7EF 
         10'd 277   :RD = #1 12'b 011111101110; //   2030 0x7EE 
         10'd 278   :RD = #1 12'b 011111101100; //   2028 0x7EC 
         10'd 279   :RD = #1 12'b 011111101010; //   2026 0x7EA 
         10'd 280   :RD = #1 12'b 011111101000; //   2024 0x7E8 
         10'd 281   :RD = #1 12'b 011111100110; //   2022 0x7E6 
         10'd 282   :RD = #1 12'b 011111100101; //   2021 0x7E5 
         10'd 283   :RD = #1 12'b 011111100010; //   2018 0x7E2 
         10'd 284   :RD = #1 12'b 011111100000; //   2016 0x7E0 
         10'd 285   :RD = #1 12'b 011111011110; //   2014 0x7DE 
         10'd 286   :RD = #1 12'b 011111011100; //   2012 0x7DC 
         10'd 287   :RD = #1 12'b 011111011010; //   2010 0x7DA 
         10'd 288   :RD = #1 12'b 011111010111; //   2007 0x7D7 
         10'd 289   :RD = #1 12'b 011111010101; //   2005 0x7D5 
         10'd 290   :RD = #1 12'b 011111010010; //   2002 0x7D2 
         10'd 291   :RD = #1 12'b 011111001111; //   1999 0x7CF 
         10'd 292   :RD = #1 12'b 011111001101; //   1997 0x7CD 
         10'd 293   :RD = #1 12'b 011111001010; //   1994 0x7CA 
         10'd 294   :RD = #1 12'b 011111000111; //   1991 0x7C7 
         10'd 295   :RD = #1 12'b 011111000100; //   1988 0x7C4 
         10'd 296   :RD = #1 12'b 011111000001; //   1985 0x7C1 
         10'd 297   :RD = #1 12'b 011110111110; //   1982 0x7BE 
         10'd 298   :RD = #1 12'b 011110111011; //   1979 0x7BB 
         10'd 299   :RD = #1 12'b 011110111000; //   1976 0x7B8 
         10'd 300   :RD = #1 12'b 011110110100; //   1972 0x7B4 
         10'd 301   :RD = #1 12'b 011110110001; //   1969 0x7B1 
         10'd 302   :RD = #1 12'b 011110101110; //   1966 0x7AE 
         10'd 303   :RD = #1 12'b 011110101010; //   1962 0x7AA 
         10'd 304   :RD = #1 12'b 011110100110; //   1958 0x7A6 
         10'd 305   :RD = #1 12'b 011110100011; //   1955 0x7A3 
         10'd 306   :RD = #1 12'b 011110011111; //   1951 0x79F 
         10'd 307   :RD = #1 12'b 011110011011; //   1947 0x79B 
         10'd 308   :RD = #1 12'b 011110010111; //   1943 0x797 
         10'd 309   :RD = #1 12'b 011110010011; //   1939 0x793 
         10'd 310   :RD = #1 12'b 011110001111; //   1935 0x78F 
         10'd 311   :RD = #1 12'b 011110001011; //   1931 0x78B 
         10'd 312   :RD = #1 12'b 011110000111; //   1927 0x787 
         10'd 313   :RD = #1 12'b 011110000011; //   1923 0x783 
         10'd 314   :RD = #1 12'b 011101111110; //   1918 0x77E 
         10'd 315   :RD = #1 12'b 011101111010; //   1914 0x77A 
         10'd 316   :RD = #1 12'b 011101110101; //   1909 0x775 
         10'd 317   :RD = #1 12'b 011101110001; //   1905 0x771 
         10'd 318   :RD = #1 12'b 011101101100; //   1900 0x76C 
         10'd 319   :RD = #1 12'b 011101100111; //   1895 0x767 
         10'd 320   :RD = #1 12'b 011101100011; //   1891 0x763 
         10'd 321   :RD = #1 12'b 011101011110; //   1886 0x75E 
         10'd 322   :RD = #1 12'b 011101011001; //   1881 0x759 
         10'd 323   :RD = #1 12'b 011101010100; //   1876 0x754 
         10'd 324   :RD = #1 12'b 011101001111; //   1871 0x74F 
         10'd 325   :RD = #1 12'b 011101001010; //   1866 0x74A 
         10'd 326   :RD = #1 12'b 011101000101; //   1861 0x745 
         10'd 327   :RD = #1 12'b 011100111111; //   1855 0x73F 
         10'd 328   :RD = #1 12'b 011100111010; //   1850 0x73A 
         10'd 329   :RD = #1 12'b 011100110101; //   1845 0x735 
         10'd 330   :RD = #1 12'b 011100101111; //   1839 0x72F 
         10'd 331   :RD = #1 12'b 011100101010; //   1834 0x72A 
         10'd 332   :RD = #1 12'b 011100100100; //   1828 0x724 
         10'd 333   :RD = #1 12'b 011100011110; //   1822 0x71E 
         10'd 334   :RD = #1 12'b 011100011000; //   1816 0x718 
         10'd 335   :RD = #1 12'b 011100010011; //   1811 0x713 
         10'd 336   :RD = #1 12'b 011100001101; //   1805 0x70D 
         10'd 337   :RD = #1 12'b 011100000111; //   1799 0x707 
         10'd 338   :RD = #1 12'b 011100000001; //   1793 0x701 
         10'd 339   :RD = #1 12'b 011011111011; //   1787 0x6FB 
         10'd 340   :RD = #1 12'b 011011110101; //   1781 0x6F5 
         10'd 341   :RD = #1 12'b 011011101110; //   1774 0x6EE 
         10'd 342   :RD = #1 12'b 011011101000; //   1768 0x6E8 
         10'd 343   :RD = #1 12'b 011011100010; //   1762 0x6E2 
         10'd 344   :RD = #1 12'b 011011011011; //   1755 0x6DB 
         10'd 345   :RD = #1 12'b 011011010101; //   1749 0x6D5 
         10'd 346   :RD = #1 12'b 011011001110; //   1742 0x6CE 
         10'd 347   :RD = #1 12'b 011011001000; //   1736 0x6C8 
         10'd 348   :RD = #1 12'b 011011000001; //   1729 0x6C1 
         10'd 349   :RD = #1 12'b 011010111010; //   1722 0x6BA 
         10'd 350   :RD = #1 12'b 011010110011; //   1715 0x6B3 
         10'd 351   :RD = #1 12'b 011010101100; //   1708 0x6AC 
         10'd 352   :RD = #1 12'b 011010100110; //   1702 0x6A6 
         10'd 353   :RD = #1 12'b 011010011111; //   1695 0x69F 
         10'd 354   :RD = #1 12'b 011010010111; //   1687 0x697 
         10'd 355   :RD = #1 12'b 011010010000; //   1680 0x690 
         10'd 356   :RD = #1 12'b 011010001001; //   1673 0x689 
         10'd 357   :RD = #1 12'b 011010000010; //   1666 0x682 
         10'd 358   :RD = #1 12'b 011001111011; //   1659 0x67B 
         10'd 359   :RD = #1 12'b 011001110011; //   1651 0x673 
         10'd 360   :RD = #1 12'b 011001101100; //   1644 0x66C 
         10'd 361   :RD = #1 12'b 011001100100; //   1636 0x664 
         10'd 362   :RD = #1 12'b 011001011101; //   1629 0x65D 
         10'd 363   :RD = #1 12'b 011001010101; //   1621 0x655 
         10'd 364   :RD = #1 12'b 011001001101; //   1613 0x64D 
         10'd 365   :RD = #1 12'b 011001000101; //   1605 0x645 
         10'd 366   :RD = #1 12'b 011000111110; //   1598 0x63E 
         10'd 367   :RD = #1 12'b 011000110110; //   1590 0x636 
         10'd 368   :RD = #1 12'b 011000101110; //   1582 0x62E 
         10'd 369   :RD = #1 12'b 011000100110; //   1574 0x626 
         10'd 370   :RD = #1 12'b 011000011110; //   1566 0x61E 
         10'd 371   :RD = #1 12'b 011000010110; //   1558 0x616 
         10'd 372   :RD = #1 12'b 011000001110; //   1550 0x60E 
         10'd 373   :RD = #1 12'b 011000000101; //   1541 0x605 
         10'd 374   :RD = #1 12'b 010111111101; //   1533 0x5FD 
         10'd 375   :RD = #1 12'b 010111110101; //   1525 0x5F5 
         10'd 376   :RD = #1 12'b 010111101100; //   1516 0x5EC 
         10'd 377   :RD = #1 12'b 010111100100; //   1508 0x5E4 
         10'd 378   :RD = #1 12'b 010111011011; //   1499 0x5DB 
         10'd 379   :RD = #1 12'b 010111010011; //   1491 0x5D3 
         10'd 380   :RD = #1 12'b 010111001010; //   1482 0x5CA 
         10'd 381   :RD = #1 12'b 010111000001; //   1473 0x5C1 
         10'd 382   :RD = #1 12'b 010110111001; //   1465 0x5B9 
         10'd 383   :RD = #1 12'b 010110110000; //   1456 0x5B0 
         10'd 384   :RD = #1 12'b 010110100111; //   1447 0x5A7 
         10'd 385   :RD = #1 12'b 010110011110; //   1438 0x59E 
         10'd 386   :RD = #1 12'b 010110010101; //   1429 0x595 
         10'd 387   :RD = #1 12'b 010110001100; //   1420 0x58C 
         10'd 388   :RD = #1 12'b 010110000011; //   1411 0x583 
         10'd 389   :RD = #1 12'b 010101111010; //   1402 0x57A 
         10'd 390   :RD = #1 12'b 010101110001; //   1393 0x571 
         10'd 391   :RD = #1 12'b 010101100111; //   1383 0x567 
         10'd 392   :RD = #1 12'b 010101011110; //   1374 0x55E 
         10'd 393   :RD = #1 12'b 010101010101; //   1365 0x555 
         10'd 394   :RD = #1 12'b 010101001011; //   1355 0x54B 
         10'd 395   :RD = #1 12'b 010101000010; //   1346 0x542 
         10'd 396   :RD = #1 12'b 010100111001; //   1337 0x539 
         10'd 397   :RD = #1 12'b 010100101111; //   1327 0x52F 
         10'd 398   :RD = #1 12'b 010100100101; //   1317 0x525 
         10'd 399   :RD = #1 12'b 010100011100; //   1308 0x51C 
         10'd 400   :RD = #1 12'b 010100010010; //   1298 0x512 
         10'd 401   :RD = #1 12'b 010100001000; //   1288 0x508 
         10'd 402   :RD = #1 12'b 010011111111; //   1279 0x4FF 
         10'd 403   :RD = #1 12'b 010011110101; //   1269 0x4F5 
         10'd 404   :RD = #1 12'b 010011101011; //   1259 0x4EB 
         10'd 405   :RD = #1 12'b 010011100001; //   1249 0x4E1 
         10'd 406   :RD = #1 12'b 010011010111; //   1239 0x4D7 
         10'd 407   :RD = #1 12'b 010011001101; //   1229 0x4CD 
         10'd 408   :RD = #1 12'b 010011000011; //   1219 0x4C3 
         10'd 409   :RD = #1 12'b 010010111001; //   1209 0x4B9 
         10'd 410   :RD = #1 12'b 010010101111; //   1199 0x4AF 
         10'd 411   :RD = #1 12'b 010010100100; //   1188 0x4A4 
         10'd 412   :RD = #1 12'b 010010011010; //   1178 0x49A 
         10'd 413   :RD = #1 12'b 010010010000; //   1168 0x490 
         10'd 414   :RD = #1 12'b 010010000110; //   1158 0x486 
         10'd 415   :RD = #1 12'b 010001111011; //   1147 0x47B 
         10'd 416   :RD = #1 12'b 010001110001; //   1137 0x471 
         10'd 417   :RD = #1 12'b 010001100110; //   1126 0x466 
         10'd 418   :RD = #1 12'b 010001011100; //   1116 0x45C 
         10'd 419   :RD = #1 12'b 010001010001; //   1105 0x451 
         10'd 420   :RD = #1 12'b 010001000111; //   1095 0x447 
         10'd 421   :RD = #1 12'b 010000111100; //   1084 0x43C 
         10'd 422   :RD = #1 12'b 010000110001; //   1073 0x431 
         10'd 423   :RD = #1 12'b 010000100111; //   1063 0x427 
         10'd 424   :RD = #1 12'b 010000011100; //   1052 0x41C 
         10'd 425   :RD = #1 12'b 010000010001; //   1041 0x411 
         10'd 426   :RD = #1 12'b 010000000110; //   1030 0x406 
         10'd 427   :RD = #1 12'b 001111111011; //   1019 0x3FB 
         10'd 428   :RD = #1 12'b 001111110000; //   1008 0x3F0 
         10'd 429   :RD = #1 12'b 001111100110; //    998 0x3E6 
         10'd 430   :RD = #1 12'b 001111011011; //    987 0x3DB 
         10'd 431   :RD = #1 12'b 001111010000; //    976 0x3D0 
         10'd 432   :RD = #1 12'b 001111000100; //    964 0x3C4 
         10'd 433   :RD = #1 12'b 001110111001; //    953 0x3B9 
         10'd 434   :RD = #1 12'b 001110101110; //    942 0x3AE 
         10'd 435   :RD = #1 12'b 001110100011; //    931 0x3A3 
         10'd 436   :RD = #1 12'b 001110011000; //    920 0x398 
         10'd 437   :RD = #1 12'b 001110001101; //    909 0x38D 
         10'd 438   :RD = #1 12'b 001110000001; //    897 0x381 
         10'd 439   :RD = #1 12'b 001101110110; //    886 0x376 
         10'd 440   :RD = #1 12'b 001101101011; //    875 0x36B 
         10'd 441   :RD = #1 12'b 001101011111; //    863 0x35F 
         10'd 442   :RD = #1 12'b 001101010100; //    852 0x354 
         10'd 443   :RD = #1 12'b 001101001000; //    840 0x348 
         10'd 444   :RD = #1 12'b 001100111101; //    829 0x33D 
         10'd 445   :RD = #1 12'b 001100110010; //    818 0x332 
         10'd 446   :RD = #1 12'b 001100100110; //    806 0x326 
         10'd 447   :RD = #1 12'b 001100011010; //    794 0x31A 
         10'd 448   :RD = #1 12'b 001100001111; //    783 0x30F 
         10'd 449   :RD = #1 12'b 001100000011; //    771 0x303 
         10'd 450   :RD = #1 12'b 001011111000; //    760 0x2F8 
         10'd 451   :RD = #1 12'b 001011101100; //    748 0x2EC 
         10'd 452   :RD = #1 12'b 001011100000; //    736 0x2E0 
         10'd 453   :RD = #1 12'b 001011010100; //    724 0x2D4 
         10'd 454   :RD = #1 12'b 001011001001; //    713 0x2C9 
         10'd 455   :RD = #1 12'b 001010111101; //    701 0x2BD 
         10'd 456   :RD = #1 12'b 001010110001; //    689 0x2B1 
         10'd 457   :RD = #1 12'b 001010100101; //    677 0x2A5 
         10'd 458   :RD = #1 12'b 001010011001; //    665 0x299 
         10'd 459   :RD = #1 12'b 001010001110; //    654 0x28E 
         10'd 460   :RD = #1 12'b 001010000010; //    642 0x282 
         10'd 461   :RD = #1 12'b 001001110110; //    630 0x276 
         10'd 462   :RD = #1 12'b 001001101010; //    618 0x26A 
         10'd 463   :RD = #1 12'b 001001011110; //    606 0x25E 
         10'd 464   :RD = #1 12'b 001001010010; //    594 0x252 
         10'd 465   :RD = #1 12'b 001001000110; //    582 0x246 
         10'd 466   :RD = #1 12'b 001000111010; //    570 0x23A 
         10'd 467   :RD = #1 12'b 001000101110; //    558 0x22E 
         10'd 468   :RD = #1 12'b 001000100001; //    545 0x221 
         10'd 469   :RD = #1 12'b 001000010101; //    533 0x215 
         10'd 470   :RD = #1 12'b 001000001001; //    521 0x209 
         10'd 471   :RD = #1 12'b 000111111101; //    509 0x1FD 
         10'd 472   :RD = #1 12'b 000111110001; //    497 0x1F1 
         10'd 473   :RD = #1 12'b 000111100101; //    485 0x1E5 
         10'd 474   :RD = #1 12'b 000111011000; //    472 0x1D8 
         10'd 475   :RD = #1 12'b 000111001100; //    460 0x1CC 
         10'd 476   :RD = #1 12'b 000111000000; //    448 0x1C0 
         10'd 477   :RD = #1 12'b 000110110100; //    436 0x1B4 
         10'd 478   :RD = #1 12'b 000110100111; //    423 0x1A7 
         10'd 479   :RD = #1 12'b 000110011011; //    411 0x19B 
         10'd 480   :RD = #1 12'b 000110001111; //    399 0x18F 
         10'd 481   :RD = #1 12'b 000110000011; //    387 0x183 
         10'd 482   :RD = #1 12'b 000101110110; //    374 0x176 
         10'd 483   :RD = #1 12'b 000101101010; //    362 0x16A 
         10'd 484   :RD = #1 12'b 000101011101; //    349 0x15D 
         10'd 485   :RD = #1 12'b 000101010001; //    337 0x151 
         10'd 486   :RD = #1 12'b 000101000101; //    325 0x145 
         10'd 487   :RD = #1 12'b 000100111000; //    312 0x138 
         10'd 488   :RD = #1 12'b 000100101100; //    300 0x12C 
         10'd 489   :RD = #1 12'b 000100011111; //    287 0x11F 
         10'd 490   :RD = #1 12'b 000100010011; //    275 0x113 
         10'd 491   :RD = #1 12'b 000100000111; //    263 0x107 
         10'd 492   :RD = #1 12'b 000011111010; //    250 0xFA 
         10'd 493   :RD = #1 12'b 000011101110; //    238 0xEE 
         10'd 494   :RD = #1 12'b 000011100001; //    225 0xE1 
         10'd 495   :RD = #1 12'b 000011010101; //    213 0xD5 
         10'd 496   :RD = #1 12'b 000011001000; //    200 0xC8 
         10'd 497   :RD = #1 12'b 000010111100; //    188 0xBC 
         10'd 498   :RD = #1 12'b 000010101111; //    175 0xAF 
         10'd 499   :RD = #1 12'b 000010100011; //    163 0xA3 
         10'd 500   :RD = #1 12'b 000010010110; //    150 0x96 
         10'd 501   :RD = #1 12'b 000010001010; //    138 0x8A 
         10'd 502   :RD = #1 12'b 000001111101; //    125 0x7D 
         10'd 503   :RD = #1 12'b 000001110000; //    112 0x70 
         10'd 504   :RD = #1 12'b 000001100100; //    100 0x64 
         10'd 505   :RD = #1 12'b 000001010111; //     87 0x57 
         10'd 506   :RD = #1 12'b 000001001011; //     75 0x4B 
         10'd 507   :RD = #1 12'b 000000111110; //     62 0x3E 
         10'd 508   :RD = #1 12'b 000000110010; //     50 0x32 
         10'd 509   :RD = #1 12'b 000000100101; //     37 0x25 
         10'd 510   :RD = #1 12'b 000000011001; //     25 0x19 
         10'd 511   :RD = #1 12'b 000000001100; //     12 0xC 
         10'd 512   :RD = #1 12'b 000000000000; //      0 0x0 
         10'd 513   :RD = #1 12'b 111111110100; //    -12 0xFF4 
         10'd 514   :RD = #1 12'b 111111100111; //    -25 0xFE7 
         10'd 515   :RD = #1 12'b 111111011011; //    -37 0xFDB 
         10'd 516   :RD = #1 12'b 111111001110; //    -50 0xFCE 
         10'd 517   :RD = #1 12'b 111111000010; //    -62 0xFC2 
         10'd 518   :RD = #1 12'b 111110110101; //    -75 0xFB5 
         10'd 519   :RD = #1 12'b 111110101001; //    -87 0xFA9 
         10'd 520   :RD = #1 12'b 111110011100; //   -100 0xF9C 
         10'd 521   :RD = #1 12'b 111110010000; //   -112 0xF90 
         10'd 522   :RD = #1 12'b 111110000011; //   -125 0xF83 
         10'd 523   :RD = #1 12'b 111101110110; //   -138 0xF76 
         10'd 524   :RD = #1 12'b 111101101010; //   -150 0xF6A 
         10'd 525   :RD = #1 12'b 111101011101; //   -163 0xF5D 
         10'd 526   :RD = #1 12'b 111101010001; //   -175 0xF51 
         10'd 527   :RD = #1 12'b 111101000100; //   -188 0xF44 
         10'd 528   :RD = #1 12'b 111100111000; //   -200 0xF38 
         10'd 529   :RD = #1 12'b 111100101011; //   -213 0xF2B 
         10'd 530   :RD = #1 12'b 111100011111; //   -225 0xF1F 
         10'd 531   :RD = #1 12'b 111100010010; //   -238 0xF12 
         10'd 532   :RD = #1 12'b 111100000110; //   -250 0xF06 
         10'd 533   :RD = #1 12'b 111011111001; //   -263 0xEF9 
         10'd 534   :RD = #1 12'b 111011101101; //   -275 0xEED 
         10'd 535   :RD = #1 12'b 111011100001; //   -287 0xEE1 
         10'd 536   :RD = #1 12'b 111011010100; //   -300 0xED4 
         10'd 537   :RD = #1 12'b 111011001000; //   -312 0xEC8 
         10'd 538   :RD = #1 12'b 111010111011; //   -325 0xEBB 
         10'd 539   :RD = #1 12'b 111010101111; //   -337 0xEAF 
         10'd 540   :RD = #1 12'b 111010100011; //   -349 0xEA3 
         10'd 541   :RD = #1 12'b 111010010110; //   -362 0xE96 
         10'd 542   :RD = #1 12'b 111010001010; //   -374 0xE8A 
         10'd 543   :RD = #1 12'b 111001111101; //   -387 0xE7D 
         10'd 544   :RD = #1 12'b 111001110001; //   -399 0xE71 
         10'd 545   :RD = #1 12'b 111001100101; //   -411 0xE65 
         10'd 546   :RD = #1 12'b 111001011001; //   -423 0xE59 
         10'd 547   :RD = #1 12'b 111001001100; //   -436 0xE4C 
         10'd 548   :RD = #1 12'b 111001000000; //   -448 0xE40 
         10'd 549   :RD = #1 12'b 111000110100; //   -460 0xE34 
         10'd 550   :RD = #1 12'b 111000101000; //   -472 0xE28 
         10'd 551   :RD = #1 12'b 111000011011; //   -485 0xE1B 
         10'd 552   :RD = #1 12'b 111000001111; //   -497 0xE0F 
         10'd 553   :RD = #1 12'b 111000000011; //   -509 0xE03 
         10'd 554   :RD = #1 12'b 110111110111; //   -521 0xDF7 
         10'd 555   :RD = #1 12'b 110111101011; //   -533 0xDEB 
         10'd 556   :RD = #1 12'b 110111011111; //   -545 0xDDF 
         10'd 557   :RD = #1 12'b 110111010010; //   -558 0xDD2 
         10'd 558   :RD = #1 12'b 110111000110; //   -570 0xDC6 
         10'd 559   :RD = #1 12'b 110110111010; //   -582 0xDBA 
         10'd 560   :RD = #1 12'b 110110101110; //   -594 0xDAE 
         10'd 561   :RD = #1 12'b 110110100010; //   -606 0xDA2 
         10'd 562   :RD = #1 12'b 110110010110; //   -618 0xD96 
         10'd 563   :RD = #1 12'b 110110001010; //   -630 0xD8A 
         10'd 564   :RD = #1 12'b 110101111110; //   -642 0xD7E 
         10'd 565   :RD = #1 12'b 110101110010; //   -654 0xD72 
         10'd 566   :RD = #1 12'b 110101100111; //   -665 0xD67 
         10'd 567   :RD = #1 12'b 110101011011; //   -677 0xD5B 
         10'd 568   :RD = #1 12'b 110101001111; //   -689 0xD4F 
         10'd 569   :RD = #1 12'b 110101000011; //   -701 0xD43 
         10'd 570   :RD = #1 12'b 110100110111; //   -713 0xD37 
         10'd 571   :RD = #1 12'b 110100101100; //   -724 0xD2C 
         10'd 572   :RD = #1 12'b 110100100000; //   -736 0xD20 
         10'd 573   :RD = #1 12'b 110100010100; //   -748 0xD14 
         10'd 574   :RD = #1 12'b 110100001000; //   -760 0xD08 
         10'd 575   :RD = #1 12'b 110011111101; //   -771 0xCFD 
         10'd 576   :RD = #1 12'b 110011110001; //   -783 0xCF1 
         10'd 577   :RD = #1 12'b 110011100110; //   -794 0xCE6 
         10'd 578   :RD = #1 12'b 110011011010; //   -806 0xCDA 
         10'd 579   :RD = #1 12'b 110011001110; //   -818 0xCCE 
         10'd 580   :RD = #1 12'b 110011000011; //   -829 0xCC3 
         10'd 581   :RD = #1 12'b 110010111000; //   -840 0xCB8 
         10'd 582   :RD = #1 12'b 110010101100; //   -852 0xCAC 
         10'd 583   :RD = #1 12'b 110010100001; //   -863 0xCA1 
         10'd 584   :RD = #1 12'b 110010010101; //   -875 0xC95 
         10'd 585   :RD = #1 12'b 110010001010; //   -886 0xC8A 
         10'd 586   :RD = #1 12'b 110001111111; //   -897 0xC7F 
         10'd 587   :RD = #1 12'b 110001110011; //   -909 0xC73 
         10'd 588   :RD = #1 12'b 110001101000; //   -920 0xC68 
         10'd 589   :RD = #1 12'b 110001011101; //   -931 0xC5D 
         10'd 590   :RD = #1 12'b 110001010010; //   -942 0xC52 
         10'd 591   :RD = #1 12'b 110001000111; //   -953 0xC47 
         10'd 592   :RD = #1 12'b 110000111100; //   -964 0xC3C 
         10'd 593   :RD = #1 12'b 110000110000; //   -976 0xC30 
         10'd 594   :RD = #1 12'b 110000100101; //   -987 0xC25 
         10'd 595   :RD = #1 12'b 110000011010; //   -998 0xC1A 
         10'd 596   :RD = #1 12'b 110000010000; //  -1008 0xC10 
         10'd 597   :RD = #1 12'b 110000000101; //  -1019 0xC05 
         10'd 598   :RD = #1 12'b 101111111010; //  -1030 0xBFA 
         10'd 599   :RD = #1 12'b 101111101111; //  -1041 0xBEF 
         10'd 600   :RD = #1 12'b 101111100100; //  -1052 0xBE4 
         10'd 601   :RD = #1 12'b 101111011001; //  -1063 0xBD9 
         10'd 602   :RD = #1 12'b 101111001111; //  -1073 0xBCF 
         10'd 603   :RD = #1 12'b 101111000100; //  -1084 0xBC4 
         10'd 604   :RD = #1 12'b 101110111001; //  -1095 0xBB9 
         10'd 605   :RD = #1 12'b 101110101111; //  -1105 0xBAF 
         10'd 606   :RD = #1 12'b 101110100100; //  -1116 0xBA4 
         10'd 607   :RD = #1 12'b 101110011010; //  -1126 0xB9A 
         10'd 608   :RD = #1 12'b 101110001111; //  -1137 0xB8F 
         10'd 609   :RD = #1 12'b 101110000101; //  -1147 0xB85 
         10'd 610   :RD = #1 12'b 101101111010; //  -1158 0xB7A 
         10'd 611   :RD = #1 12'b 101101110000; //  -1168 0xB70 
         10'd 612   :RD = #1 12'b 101101100110; //  -1178 0xB66 
         10'd 613   :RD = #1 12'b 101101011100; //  -1188 0xB5C 
         10'd 614   :RD = #1 12'b 101101010001; //  -1199 0xB51 
         10'd 615   :RD = #1 12'b 101101000111; //  -1209 0xB47 
         10'd 616   :RD = #1 12'b 101100111101; //  -1219 0xB3D 
         10'd 617   :RD = #1 12'b 101100110011; //  -1229 0xB33 
         10'd 618   :RD = #1 12'b 101100101001; //  -1239 0xB29 
         10'd 619   :RD = #1 12'b 101100011111; //  -1249 0xB1F 
         10'd 620   :RD = #1 12'b 101100010101; //  -1259 0xB15 
         10'd 621   :RD = #1 12'b 101100001011; //  -1269 0xB0B 
         10'd 622   :RD = #1 12'b 101100000001; //  -1279 0xB01 
         10'd 623   :RD = #1 12'b 101011111000; //  -1288 0xAF8 
         10'd 624   :RD = #1 12'b 101011101110; //  -1298 0xAEE 
         10'd 625   :RD = #1 12'b 101011100100; //  -1308 0xAE4 
         10'd 626   :RD = #1 12'b 101011011011; //  -1317 0xADB 
         10'd 627   :RD = #1 12'b 101011010001; //  -1327 0xAD1 
         10'd 628   :RD = #1 12'b 101011000111; //  -1337 0xAC7 
         10'd 629   :RD = #1 12'b 101010111110; //  -1346 0xABE 
         10'd 630   :RD = #1 12'b 101010110101; //  -1355 0xAB5 
         10'd 631   :RD = #1 12'b 101010101011; //  -1365 0xAAB 
         10'd 632   :RD = #1 12'b 101010100010; //  -1374 0xAA2 
         10'd 633   :RD = #1 12'b 101010011001; //  -1383 0xA99 
         10'd 634   :RD = #1 12'b 101010001111; //  -1393 0xA8F 
         10'd 635   :RD = #1 12'b 101010000110; //  -1402 0xA86 
         10'd 636   :RD = #1 12'b 101001111101; //  -1411 0xA7D 
         10'd 637   :RD = #1 12'b 101001110100; //  -1420 0xA74 
         10'd 638   :RD = #1 12'b 101001101011; //  -1429 0xA6B 
         10'd 639   :RD = #1 12'b 101001100010; //  -1438 0xA62 
         10'd 640   :RD = #1 12'b 101001011001; //  -1447 0xA59 
         10'd 641   :RD = #1 12'b 101001010000; //  -1456 0xA50 
         10'd 642   :RD = #1 12'b 101001000111; //  -1465 0xA47 
         10'd 643   :RD = #1 12'b 101000111111; //  -1473 0xA3F 
         10'd 644   :RD = #1 12'b 101000110110; //  -1482 0xA36 
         10'd 645   :RD = #1 12'b 101000101101; //  -1491 0xA2D 
         10'd 646   :RD = #1 12'b 101000100101; //  -1499 0xA25 
         10'd 647   :RD = #1 12'b 101000011100; //  -1508 0xA1C 
         10'd 648   :RD = #1 12'b 101000010100; //  -1516 0xA14 
         10'd 649   :RD = #1 12'b 101000001011; //  -1525 0xA0B 
         10'd 650   :RD = #1 12'b 101000000011; //  -1533 0xA03 
         10'd 651   :RD = #1 12'b 100111111011; //  -1541 0x9FB 
         10'd 652   :RD = #1 12'b 100111110010; //  -1550 0x9F2 
         10'd 653   :RD = #1 12'b 100111101010; //  -1558 0x9EA 
         10'd 654   :RD = #1 12'b 100111100010; //  -1566 0x9E2 
         10'd 655   :RD = #1 12'b 100111011010; //  -1574 0x9DA 
         10'd 656   :RD = #1 12'b 100111010010; //  -1582 0x9D2 
         10'd 657   :RD = #1 12'b 100111001010; //  -1590 0x9CA 
         10'd 658   :RD = #1 12'b 100111000010; //  -1598 0x9C2 
         10'd 659   :RD = #1 12'b 100110111011; //  -1605 0x9BB 
         10'd 660   :RD = #1 12'b 100110110011; //  -1613 0x9B3 
         10'd 661   :RD = #1 12'b 100110101011; //  -1621 0x9AB 
         10'd 662   :RD = #1 12'b 100110100011; //  -1629 0x9A3 
         10'd 663   :RD = #1 12'b 100110011100; //  -1636 0x99C 
         10'd 664   :RD = #1 12'b 100110010100; //  -1644 0x994 
         10'd 665   :RD = #1 12'b 100110001101; //  -1651 0x98D 
         10'd 666   :RD = #1 12'b 100110000101; //  -1659 0x985 
         10'd 667   :RD = #1 12'b 100101111110; //  -1666 0x97E 
         10'd 668   :RD = #1 12'b 100101110111; //  -1673 0x977 
         10'd 669   :RD = #1 12'b 100101110000; //  -1680 0x970 
         10'd 670   :RD = #1 12'b 100101101001; //  -1687 0x969 
         10'd 671   :RD = #1 12'b 100101100001; //  -1695 0x961 
         10'd 672   :RD = #1 12'b 100101011010; //  -1702 0x95A 
         10'd 673   :RD = #1 12'b 100101010100; //  -1708 0x954 
         10'd 674   :RD = #1 12'b 100101001101; //  -1715 0x94D 
         10'd 675   :RD = #1 12'b 100101000110; //  -1722 0x946 
         10'd 676   :RD = #1 12'b 100100111111; //  -1729 0x93F 
         10'd 677   :RD = #1 12'b 100100111000; //  -1736 0x938 
         10'd 678   :RD = #1 12'b 100100110010; //  -1742 0x932 
         10'd 679   :RD = #1 12'b 100100101011; //  -1749 0x92B 
         10'd 680   :RD = #1 12'b 100100100101; //  -1755 0x925 
         10'd 681   :RD = #1 12'b 100100011110; //  -1762 0x91E 
         10'd 682   :RD = #1 12'b 100100011000; //  -1768 0x918 
         10'd 683   :RD = #1 12'b 100100010010; //  -1774 0x912 
         10'd 684   :RD = #1 12'b 100100001011; //  -1781 0x90B 
         10'd 685   :RD = #1 12'b 100100000101; //  -1787 0x905 
         10'd 686   :RD = #1 12'b 100011111111; //  -1793 0x8FF 
         10'd 687   :RD = #1 12'b 100011111001; //  -1799 0x8F9 
         10'd 688   :RD = #1 12'b 100011110011; //  -1805 0x8F3 
         10'd 689   :RD = #1 12'b 100011101101; //  -1811 0x8ED 
         10'd 690   :RD = #1 12'b 100011101000; //  -1816 0x8E8 
         10'd 691   :RD = #1 12'b 100011100010; //  -1822 0x8E2 
         10'd 692   :RD = #1 12'b 100011011100; //  -1828 0x8DC 
         10'd 693   :RD = #1 12'b 100011010110; //  -1834 0x8D6 
         10'd 694   :RD = #1 12'b 100011010001; //  -1839 0x8D1 
         10'd 695   :RD = #1 12'b 100011001011; //  -1845 0x8CB 
         10'd 696   :RD = #1 12'b 100011000110; //  -1850 0x8C6 
         10'd 697   :RD = #1 12'b 100011000001; //  -1855 0x8C1 
         10'd 698   :RD = #1 12'b 100010111011; //  -1861 0x8BB 
         10'd 699   :RD = #1 12'b 100010110110; //  -1866 0x8B6 
         10'd 700   :RD = #1 12'b 100010110001; //  -1871 0x8B1 
         10'd 701   :RD = #1 12'b 100010101100; //  -1876 0x8AC 
         10'd 702   :RD = #1 12'b 100010100111; //  -1881 0x8A7 
         10'd 703   :RD = #1 12'b 100010100010; //  -1886 0x8A2 
         10'd 704   :RD = #1 12'b 100010011101; //  -1891 0x89D 
         10'd 705   :RD = #1 12'b 100010011001; //  -1895 0x899 
         10'd 706   :RD = #1 12'b 100010010100; //  -1900 0x894 
         10'd 707   :RD = #1 12'b 100010001111; //  -1905 0x88F 
         10'd 708   :RD = #1 12'b 100010001011; //  -1909 0x88B 
         10'd 709   :RD = #1 12'b 100010000110; //  -1914 0x886 
         10'd 710   :RD = #1 12'b 100010000010; //  -1918 0x882 
         10'd 711   :RD = #1 12'b 100001111101; //  -1923 0x87D 
         10'd 712   :RD = #1 12'b 100001111001; //  -1927 0x879 
         10'd 713   :RD = #1 12'b 100001110101; //  -1931 0x875 
         10'd 714   :RD = #1 12'b 100001110001; //  -1935 0x871 
         10'd 715   :RD = #1 12'b 100001101101; //  -1939 0x86D 
         10'd 716   :RD = #1 12'b 100001101001; //  -1943 0x869 
         10'd 717   :RD = #1 12'b 100001100101; //  -1947 0x865 
         10'd 718   :RD = #1 12'b 100001100001; //  -1951 0x861 
         10'd 719   :RD = #1 12'b 100001011101; //  -1955 0x85D 
         10'd 720   :RD = #1 12'b 100001011010; //  -1958 0x85A 
         10'd 721   :RD = #1 12'b 100001010110; //  -1962 0x856 
         10'd 722   :RD = #1 12'b 100001010010; //  -1966 0x852 
         10'd 723   :RD = #1 12'b 100001001111; //  -1969 0x84F 
         10'd 724   :RD = #1 12'b 100001001100; //  -1972 0x84C 
         10'd 725   :RD = #1 12'b 100001001000; //  -1976 0x848 
         10'd 726   :RD = #1 12'b 100001000101; //  -1979 0x845 
         10'd 727   :RD = #1 12'b 100001000010; //  -1982 0x842 
         10'd 728   :RD = #1 12'b 100000111111; //  -1985 0x83F 
         10'd 729   :RD = #1 12'b 100000111100; //  -1988 0x83C 
         10'd 730   :RD = #1 12'b 100000111001; //  -1991 0x839 
         10'd 731   :RD = #1 12'b 100000110110; //  -1994 0x836 
         10'd 732   :RD = #1 12'b 100000110011; //  -1997 0x833 
         10'd 733   :RD = #1 12'b 100000110001; //  -1999 0x831 
         10'd 734   :RD = #1 12'b 100000101110; //  -2002 0x82E 
         10'd 735   :RD = #1 12'b 100000101011; //  -2005 0x82B 
         10'd 736   :RD = #1 12'b 100000101001; //  -2007 0x829 
         10'd 737   :RD = #1 12'b 100000100110; //  -2010 0x826 
         10'd 738   :RD = #1 12'b 100000100100; //  -2012 0x824 
         10'd 739   :RD = #1 12'b 100000100010; //  -2014 0x822 
         10'd 740   :RD = #1 12'b 100000100000; //  -2016 0x820 
         10'd 741   :RD = #1 12'b 100000011110; //  -2018 0x81E 
         10'd 742   :RD = #1 12'b 100000011011; //  -2021 0x81B 
         10'd 743   :RD = #1 12'b 100000011010; //  -2022 0x81A 
         10'd 744   :RD = #1 12'b 100000011000; //  -2024 0x818 
         10'd 745   :RD = #1 12'b 100000010110; //  -2026 0x816 
         10'd 746   :RD = #1 12'b 100000010100; //  -2028 0x814 
         10'd 747   :RD = #1 12'b 100000010010; //  -2030 0x812 
         10'd 748   :RD = #1 12'b 100000010001; //  -2031 0x811 
         10'd 749   :RD = #1 12'b 100000001111; //  -2033 0x80F 
         10'd 750   :RD = #1 12'b 100000001110; //  -2034 0x80E 
         10'd 751   :RD = #1 12'b 100000001101; //  -2035 0x80D 
         10'd 752   :RD = #1 12'b 100000001011; //  -2037 0x80B 
         10'd 753   :RD = #1 12'b 100000001010; //  -2038 0x80A 
         10'd 754   :RD = #1 12'b 100000001001; //  -2039 0x809 
         10'd 755   :RD = #1 12'b 100000001000; //  -2040 0x808 
         10'd 756   :RD = #1 12'b 100000000111; //  -2041 0x807 
         10'd 757   :RD = #1 12'b 100000000110; //  -2042 0x806 
         10'd 758   :RD = #1 12'b 100000000101; //  -2043 0x805 
         10'd 759   :RD = #1 12'b 100000000101; //  -2043 0x805 
         10'd 760   :RD = #1 12'b 100000000100; //  -2044 0x804 
         10'd 761   :RD = #1 12'b 100000000011; //  -2045 0x803 
         10'd 762   :RD = #1 12'b 100000000011; //  -2045 0x803 
         10'd 763   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 764   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 765   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 766   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 767   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 768   :RD = #1 12'b 100000000001; //  -2047 0x801 
         10'd 769   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 770   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 771   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 772   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 773   :RD = #1 12'b 100000000010; //  -2046 0x802 
         10'd 774   :RD = #1 12'b 100000000011; //  -2045 0x803 
         10'd 775   :RD = #1 12'b 100000000011; //  -2045 0x803 
         10'd 776   :RD = #1 12'b 100000000100; //  -2044 0x804 
         10'd 777   :RD = #1 12'b 100000000101; //  -2043 0x805 
         10'd 778   :RD = #1 12'b 100000000101; //  -2043 0x805 
         10'd 779   :RD = #1 12'b 100000000110; //  -2042 0x806 
         10'd 780   :RD = #1 12'b 100000000111; //  -2041 0x807 
         10'd 781   :RD = #1 12'b 100000001000; //  -2040 0x808 
         10'd 782   :RD = #1 12'b 100000001001; //  -2039 0x809 
         10'd 783   :RD = #1 12'b 100000001010; //  -2038 0x80A 
         10'd 784   :RD = #1 12'b 100000001011; //  -2037 0x80B 
         10'd 785   :RD = #1 12'b 100000001101; //  -2035 0x80D 
         10'd 786   :RD = #1 12'b 100000001110; //  -2034 0x80E 
         10'd 787   :RD = #1 12'b 100000001111; //  -2033 0x80F 
         10'd 788   :RD = #1 12'b 100000010001; //  -2031 0x811 
         10'd 789   :RD = #1 12'b 100000010010; //  -2030 0x812 
         10'd 790   :RD = #1 12'b 100000010100; //  -2028 0x814 
         10'd 791   :RD = #1 12'b 100000010110; //  -2026 0x816 
         10'd 792   :RD = #1 12'b 100000011000; //  -2024 0x818 
         10'd 793   :RD = #1 12'b 100000011010; //  -2022 0x81A 
         10'd 794   :RD = #1 12'b 100000011011; //  -2021 0x81B 
         10'd 795   :RD = #1 12'b 100000011110; //  -2018 0x81E 
         10'd 796   :RD = #1 12'b 100000100000; //  -2016 0x820 
         10'd 797   :RD = #1 12'b 100000100010; //  -2014 0x822 
         10'd 798   :RD = #1 12'b 100000100100; //  -2012 0x824 
         10'd 799   :RD = #1 12'b 100000100110; //  -2010 0x826 
         10'd 800   :RD = #1 12'b 100000101001; //  -2007 0x829 
         10'd 801   :RD = #1 12'b 100000101011; //  -2005 0x82B 
         10'd 802   :RD = #1 12'b 100000101110; //  -2002 0x82E 
         10'd 803   :RD = #1 12'b 100000110001; //  -1999 0x831 
         10'd 804   :RD = #1 12'b 100000110011; //  -1997 0x833 
         10'd 805   :RD = #1 12'b 100000110110; //  -1994 0x836 
         10'd 806   :RD = #1 12'b 100000111001; //  -1991 0x839 
         10'd 807   :RD = #1 12'b 100000111100; //  -1988 0x83C 
         10'd 808   :RD = #1 12'b 100000111111; //  -1985 0x83F 
         10'd 809   :RD = #1 12'b 100001000010; //  -1982 0x842 
         10'd 810   :RD = #1 12'b 100001000101; //  -1979 0x845 
         10'd 811   :RD = #1 12'b 100001001000; //  -1976 0x848 
         10'd 812   :RD = #1 12'b 100001001100; //  -1972 0x84C 
         10'd 813   :RD = #1 12'b 100001001111; //  -1969 0x84F 
         10'd 814   :RD = #1 12'b 100001010010; //  -1966 0x852 
         10'd 815   :RD = #1 12'b 100001010110; //  -1962 0x856 
         10'd 816   :RD = #1 12'b 100001011010; //  -1958 0x85A 
         10'd 817   :RD = #1 12'b 100001011101; //  -1955 0x85D 
         10'd 818   :RD = #1 12'b 100001100001; //  -1951 0x861 
         10'd 819   :RD = #1 12'b 100001100101; //  -1947 0x865 
         10'd 820   :RD = #1 12'b 100001101001; //  -1943 0x869 
         10'd 821   :RD = #1 12'b 100001101101; //  -1939 0x86D 
         10'd 822   :RD = #1 12'b 100001110001; //  -1935 0x871 
         10'd 823   :RD = #1 12'b 100001110101; //  -1931 0x875 
         10'd 824   :RD = #1 12'b 100001111001; //  -1927 0x879 
         10'd 825   :RD = #1 12'b 100001111101; //  -1923 0x87D 
         10'd 826   :RD = #1 12'b 100010000010; //  -1918 0x882 
         10'd 827   :RD = #1 12'b 100010000110; //  -1914 0x886 
         10'd 828   :RD = #1 12'b 100010001011; //  -1909 0x88B 
         10'd 829   :RD = #1 12'b 100010001111; //  -1905 0x88F 
         10'd 830   :RD = #1 12'b 100010010100; //  -1900 0x894 
         10'd 831   :RD = #1 12'b 100010011001; //  -1895 0x899 
         10'd 832   :RD = #1 12'b 100010011101; //  -1891 0x89D 
         10'd 833   :RD = #1 12'b 100010100010; //  -1886 0x8A2 
         10'd 834   :RD = #1 12'b 100010100111; //  -1881 0x8A7 
         10'd 835   :RD = #1 12'b 100010101100; //  -1876 0x8AC 
         10'd 836   :RD = #1 12'b 100010110001; //  -1871 0x8B1 
         10'd 837   :RD = #1 12'b 100010110110; //  -1866 0x8B6 
         10'd 838   :RD = #1 12'b 100010111011; //  -1861 0x8BB 
         10'd 839   :RD = #1 12'b 100011000001; //  -1855 0x8C1 
         10'd 840   :RD = #1 12'b 100011000110; //  -1850 0x8C6 
         10'd 841   :RD = #1 12'b 100011001011; //  -1845 0x8CB 
         10'd 842   :RD = #1 12'b 100011010001; //  -1839 0x8D1 
         10'd 843   :RD = #1 12'b 100011010110; //  -1834 0x8D6 
         10'd 844   :RD = #1 12'b 100011011100; //  -1828 0x8DC 
         10'd 845   :RD = #1 12'b 100011100010; //  -1822 0x8E2 
         10'd 846   :RD = #1 12'b 100011101000; //  -1816 0x8E8 
         10'd 847   :RD = #1 12'b 100011101101; //  -1811 0x8ED 
         10'd 848   :RD = #1 12'b 100011110011; //  -1805 0x8F3 
         10'd 849   :RD = #1 12'b 100011111001; //  -1799 0x8F9 
         10'd 850   :RD = #1 12'b 100011111111; //  -1793 0x8FF 
         10'd 851   :RD = #1 12'b 100100000101; //  -1787 0x905 
         10'd 852   :RD = #1 12'b 100100001011; //  -1781 0x90B 
         10'd 853   :RD = #1 12'b 100100010010; //  -1774 0x912 
         10'd 854   :RD = #1 12'b 100100011000; //  -1768 0x918 
         10'd 855   :RD = #1 12'b 100100011110; //  -1762 0x91E 
         10'd 856   :RD = #1 12'b 100100100101; //  -1755 0x925 
         10'd 857   :RD = #1 12'b 100100101011; //  -1749 0x92B 
         10'd 858   :RD = #1 12'b 100100110010; //  -1742 0x932 
         10'd 859   :RD = #1 12'b 100100111000; //  -1736 0x938 
         10'd 860   :RD = #1 12'b 100100111111; //  -1729 0x93F 
         10'd 861   :RD = #1 12'b 100101000110; //  -1722 0x946 
         10'd 862   :RD = #1 12'b 100101001101; //  -1715 0x94D 
         10'd 863   :RD = #1 12'b 100101010100; //  -1708 0x954 
         10'd 864   :RD = #1 12'b 100101011010; //  -1702 0x95A 
         10'd 865   :RD = #1 12'b 100101100001; //  -1695 0x961 
         10'd 866   :RD = #1 12'b 100101101001; //  -1687 0x969 
         10'd 867   :RD = #1 12'b 100101110000; //  -1680 0x970 
         10'd 868   :RD = #1 12'b 100101110111; //  -1673 0x977 
         10'd 869   :RD = #1 12'b 100101111110; //  -1666 0x97E 
         10'd 870   :RD = #1 12'b 100110000101; //  -1659 0x985 
         10'd 871   :RD = #1 12'b 100110001101; //  -1651 0x98D 
         10'd 872   :RD = #1 12'b 100110010100; //  -1644 0x994 
         10'd 873   :RD = #1 12'b 100110011100; //  -1636 0x99C 
         10'd 874   :RD = #1 12'b 100110100011; //  -1629 0x9A3 
         10'd 875   :RD = #1 12'b 100110101011; //  -1621 0x9AB 
         10'd 876   :RD = #1 12'b 100110110011; //  -1613 0x9B3 
         10'd 877   :RD = #1 12'b 100110111011; //  -1605 0x9BB 
         10'd 878   :RD = #1 12'b 100111000010; //  -1598 0x9C2 
         10'd 879   :RD = #1 12'b 100111001010; //  -1590 0x9CA 
         10'd 880   :RD = #1 12'b 100111010010; //  -1582 0x9D2 
         10'd 881   :RD = #1 12'b 100111011010; //  -1574 0x9DA 
         10'd 882   :RD = #1 12'b 100111100010; //  -1566 0x9E2 
         10'd 883   :RD = #1 12'b 100111101010; //  -1558 0x9EA 
         10'd 884   :RD = #1 12'b 100111110010; //  -1550 0x9F2 
         10'd 885   :RD = #1 12'b 100111111011; //  -1541 0x9FB 
         10'd 886   :RD = #1 12'b 101000000011; //  -1533 0xA03 
         10'd 887   :RD = #1 12'b 101000001011; //  -1525 0xA0B 
         10'd 888   :RD = #1 12'b 101000010100; //  -1516 0xA14 
         10'd 889   :RD = #1 12'b 101000011100; //  -1508 0xA1C 
         10'd 890   :RD = #1 12'b 101000100101; //  -1499 0xA25 
         10'd 891   :RD = #1 12'b 101000101101; //  -1491 0xA2D 
         10'd 892   :RD = #1 12'b 101000110110; //  -1482 0xA36 
         10'd 893   :RD = #1 12'b 101000111111; //  -1473 0xA3F 
         10'd 894   :RD = #1 12'b 101001000111; //  -1465 0xA47 
         10'd 895   :RD = #1 12'b 101001010000; //  -1456 0xA50 
         10'd 896   :RD = #1 12'b 101001011001; //  -1447 0xA59 
         10'd 897   :RD = #1 12'b 101001100010; //  -1438 0xA62 
         10'd 898   :RD = #1 12'b 101001101011; //  -1429 0xA6B 
         10'd 899   :RD = #1 12'b 101001110100; //  -1420 0xA74 
         10'd 900   :RD = #1 12'b 101001111101; //  -1411 0xA7D 
         10'd 901   :RD = #1 12'b 101010000110; //  -1402 0xA86 
         10'd 902   :RD = #1 12'b 101010001111; //  -1393 0xA8F 
         10'd 903   :RD = #1 12'b 101010011001; //  -1383 0xA99 
         10'd 904   :RD = #1 12'b 101010100010; //  -1374 0xAA2 
         10'd 905   :RD = #1 12'b 101010101011; //  -1365 0xAAB 
         10'd 906   :RD = #1 12'b 101010110101; //  -1355 0xAB5 
         10'd 907   :RD = #1 12'b 101010111110; //  -1346 0xABE 
         10'd 908   :RD = #1 12'b 101011000111; //  -1337 0xAC7 
         10'd 909   :RD = #1 12'b 101011010001; //  -1327 0xAD1 
         10'd 910   :RD = #1 12'b 101011011011; //  -1317 0xADB 
         10'd 911   :RD = #1 12'b 101011100100; //  -1308 0xAE4 
         10'd 912   :RD = #1 12'b 101011101110; //  -1298 0xAEE 
         10'd 913   :RD = #1 12'b 101011111000; //  -1288 0xAF8 
         10'd 914   :RD = #1 12'b 101100000001; //  -1279 0xB01 
         10'd 915   :RD = #1 12'b 101100001011; //  -1269 0xB0B 
         10'd 916   :RD = #1 12'b 101100010101; //  -1259 0xB15 
         10'd 917   :RD = #1 12'b 101100011111; //  -1249 0xB1F 
         10'd 918   :RD = #1 12'b 101100101001; //  -1239 0xB29 
         10'd 919   :RD = #1 12'b 101100110011; //  -1229 0xB33 
         10'd 920   :RD = #1 12'b 101100111101; //  -1219 0xB3D 
         10'd 921   :RD = #1 12'b 101101000111; //  -1209 0xB47 
         10'd 922   :RD = #1 12'b 101101010001; //  -1199 0xB51 
         10'd 923   :RD = #1 12'b 101101011100; //  -1188 0xB5C 
         10'd 924   :RD = #1 12'b 101101100110; //  -1178 0xB66 
         10'd 925   :RD = #1 12'b 101101110000; //  -1168 0xB70 
         10'd 926   :RD = #1 12'b 101101111010; //  -1158 0xB7A 
         10'd 927   :RD = #1 12'b 101110000101; //  -1147 0xB85 
         10'd 928   :RD = #1 12'b 101110001111; //  -1137 0xB8F 
         10'd 929   :RD = #1 12'b 101110011010; //  -1126 0xB9A 
         10'd 930   :RD = #1 12'b 101110100100; //  -1116 0xBA4 
         10'd 931   :RD = #1 12'b 101110101111; //  -1105 0xBAF 
         10'd 932   :RD = #1 12'b 101110111001; //  -1095 0xBB9 
         10'd 933   :RD = #1 12'b 101111000100; //  -1084 0xBC4 
         10'd 934   :RD = #1 12'b 101111001111; //  -1073 0xBCF 
         10'd 935   :RD = #1 12'b 101111011001; //  -1063 0xBD9 
         10'd 936   :RD = #1 12'b 101111100100; //  -1052 0xBE4 
         10'd 937   :RD = #1 12'b 101111101111; //  -1041 0xBEF 
         10'd 938   :RD = #1 12'b 101111111010; //  -1030 0xBFA 
         10'd 939   :RD = #1 12'b 110000000101; //  -1019 0xC05 
         10'd 940   :RD = #1 12'b 110000010000; //  -1008 0xC10 
         10'd 941   :RD = #1 12'b 110000011010; //   -998 0xC1A 
         10'd 942   :RD = #1 12'b 110000100101; //   -987 0xC25 
         10'd 943   :RD = #1 12'b 110000110000; //   -976 0xC30 
         10'd 944   :RD = #1 12'b 110000111100; //   -964 0xC3C 
         10'd 945   :RD = #1 12'b 110001000111; //   -953 0xC47 
         10'd 946   :RD = #1 12'b 110001010010; //   -942 0xC52 
         10'd 947   :RD = #1 12'b 110001011101; //   -931 0xC5D 
         10'd 948   :RD = #1 12'b 110001101000; //   -920 0xC68 
         10'd 949   :RD = #1 12'b 110001110011; //   -909 0xC73 
         10'd 950   :RD = #1 12'b 110001111111; //   -897 0xC7F 
         10'd 951   :RD = #1 12'b 110010001010; //   -886 0xC8A 
         10'd 952   :RD = #1 12'b 110010010101; //   -875 0xC95 
         10'd 953   :RD = #1 12'b 110010100001; //   -863 0xCA1 
         10'd 954   :RD = #1 12'b 110010101100; //   -852 0xCAC 
         10'd 955   :RD = #1 12'b 110010111000; //   -840 0xCB8 
         10'd 956   :RD = #1 12'b 110011000011; //   -829 0xCC3 
         10'd 957   :RD = #1 12'b 110011001110; //   -818 0xCCE 
         10'd 958   :RD = #1 12'b 110011011010; //   -806 0xCDA 
         10'd 959   :RD = #1 12'b 110011100110; //   -794 0xCE6 
         10'd 960   :RD = #1 12'b 110011110001; //   -783 0xCF1 
         10'd 961   :RD = #1 12'b 110011111101; //   -771 0xCFD 
         10'd 962   :RD = #1 12'b 110100001000; //   -760 0xD08 
         10'd 963   :RD = #1 12'b 110100010100; //   -748 0xD14 
         10'd 964   :RD = #1 12'b 110100100000; //   -736 0xD20 
         10'd 965   :RD = #1 12'b 110100101100; //   -724 0xD2C 
         10'd 966   :RD = #1 12'b 110100110111; //   -713 0xD37 
         10'd 967   :RD = #1 12'b 110101000011; //   -701 0xD43 
         10'd 968   :RD = #1 12'b 110101001111; //   -689 0xD4F 
         10'd 969   :RD = #1 12'b 110101011011; //   -677 0xD5B 
         10'd 970   :RD = #1 12'b 110101100111; //   -665 0xD67 
         10'd 971   :RD = #1 12'b 110101110010; //   -654 0xD72 
         10'd 972   :RD = #1 12'b 110101111110; //   -642 0xD7E 
         10'd 973   :RD = #1 12'b 110110001010; //   -630 0xD8A 
         10'd 974   :RD = #1 12'b 110110010110; //   -618 0xD96 
         10'd 975   :RD = #1 12'b 110110100010; //   -606 0xDA2 
         10'd 976   :RD = #1 12'b 110110101110; //   -594 0xDAE 
         10'd 977   :RD = #1 12'b 110110111010; //   -582 0xDBA 
         10'd 978   :RD = #1 12'b 110111000110; //   -570 0xDC6 
         10'd 979   :RD = #1 12'b 110111010010; //   -558 0xDD2 
         10'd 980   :RD = #1 12'b 110111011111; //   -545 0xDDF 
         10'd 981   :RD = #1 12'b 110111101011; //   -533 0xDEB 
         10'd 982   :RD = #1 12'b 110111110111; //   -521 0xDF7 
         10'd 983   :RD = #1 12'b 111000000011; //   -509 0xE03 
         10'd 984   :RD = #1 12'b 111000001111; //   -497 0xE0F 
         10'd 985   :RD = #1 12'b 111000011011; //   -485 0xE1B 
         10'd 986   :RD = #1 12'b 111000101000; //   -472 0xE28 
         10'd 987   :RD = #1 12'b 111000110100; //   -460 0xE34 
         10'd 988   :RD = #1 12'b 111001000000; //   -448 0xE40 
         10'd 989   :RD = #1 12'b 111001001100; //   -436 0xE4C 
         10'd 990   :RD = #1 12'b 111001011001; //   -423 0xE59 
         10'd 991   :RD = #1 12'b 111001100101; //   -411 0xE65 
         10'd 992   :RD = #1 12'b 111001110001; //   -399 0xE71 
         10'd 993   :RD = #1 12'b 111001111101; //   -387 0xE7D 
         10'd 994   :RD = #1 12'b 111010001010; //   -374 0xE8A 
         10'd 995   :RD = #1 12'b 111010010110; //   -362 0xE96 
         10'd 996   :RD = #1 12'b 111010100011; //   -349 0xEA3 
         10'd 997   :RD = #1 12'b 111010101111; //   -337 0xEAF 
         10'd 998   :RD = #1 12'b 111010111011; //   -325 0xEBB 
         10'd 999   :RD = #1 12'b 111011001000; //   -312 0xEC8 
         10'd 1000  :RD = #1 12'b 111011010100; //   -300 0xED4 
         10'd 1001  :RD = #1 12'b 111011100001; //   -287 0xEE1 
         10'd 1002  :RD = #1 12'b 111011101101; //   -275 0xEED 
         10'd 1003  :RD = #1 12'b 111011111001; //   -263 0xEF9 
         10'd 1004  :RD = #1 12'b 111100000110; //   -250 0xF06 
         10'd 1005  :RD = #1 12'b 111100010010; //   -238 0xF12 
         10'd 1006  :RD = #1 12'b 111100011111; //   -225 0xF1F 
         10'd 1007  :RD = #1 12'b 111100101011; //   -213 0xF2B 
         10'd 1008  :RD = #1 12'b 111100111000; //   -200 0xF38 
         10'd 1009  :RD = #1 12'b 111101000100; //   -188 0xF44 
         10'd 1010  :RD = #1 12'b 111101010001; //   -175 0xF51 
         10'd 1011  :RD = #1 12'b 111101011101; //   -163 0xF5D 
         10'd 1012  :RD = #1 12'b 111101101010; //   -150 0xF6A 
         10'd 1013  :RD = #1 12'b 111101110110; //   -138 0xF76 
         10'd 1014  :RD = #1 12'b 111110000011; //   -125 0xF83 
         10'd 1015  :RD = #1 12'b 111110010000; //   -112 0xF90 
         10'd 1016  :RD = #1 12'b 111110011100; //   -100 0xF9C 
         10'd 1017  :RD = #1 12'b 111110101001; //    -87 0xFA9 
         10'd 1018  :RD = #1 12'b 111110110101; //    -75 0xFB5 
         10'd 1019  :RD = #1 12'b 111111000010; //    -62 0xFC2 
         10'd 1020  :RD = #1 12'b 111111001110; //    -50 0xFCE 
         10'd 1021  :RD = #1 12'b 111111011011; //    -37 0xFDB 
         10'd 1022  :RD = #1 12'b 111111100111; //    -25 0xFE7 
         10'd 1023  :RD = #1 12'b 111111110100; //    -12 0xFF4 
      default : RD = #1 0;
      endcase
    endmodule 

    3. SW_FR模块

    module SW_FR(
        CLK     ,   //input clock
        SWFR    ,   //input word
        FQWD    ,   // output frequency word
        FWEN    );  // output frequency word update enable
    
    parameter VAL_FREQ_BASE = 32'h051E_B851;  // 50MHz clock, 1MHz out wave freqword value
    
    input CLK,FWEN;       
    input [2:0] SWFR; 
    output reg[31:0] FQWD; 
    
    always @(posedge CLK) begin
        if (FWEN) begin
            case(SWFR)
            3'd1: FQWD <= VAL_FREQ_BASE * 0.5 ;//500KHz
            3'd2: FQWD <= VAL_FREQ_BASE       ;//1MHz
            3'd4: FQWD <= VAL_FREQ_BASE * 3   ;//3MHz
            default: FQWD <= 32'h0            ;//output none
            endcase
        end
        else begin
            FQWD <= FQWD;
        end
    end
    endmodule

    4. DDS_CORE_SINE模块

    module DDS_CORE_SINE(
      CLK   ,   //input clock
      INCR  ,   //counter increase value  
      SINOUT);  //counter value
    
    input CLK;
    input [31:0] INCR;
    output reg[9:0] SINOUT;
    
    always @ (posedge CLK) begin
      SINOUT <= INCR + SINOUT;
    end
    endmodule   
    展开全文
  • 当初在做一个项目的时候,用到了DDS模块,AD9850芯片,在这里整理了我找到的一些资料以及自己当初写的51单片机C程序,希望对学习者有帮助。
  • 使用Arduino,OLED显示屏和AD9833 DDS模块为您的实验室创建有用的波形发生器。 硬件部件: Arduino Nano R3 × 1个 显示SH1106 I2C Oled 128x64像素(4针)× 1个 AD9833 DDS模块× 1个 5V继电器模块(可选)× 1个 ...
  • Data:2019/1/23 author:wangsong 需求:要求能有产生一路1MHZ以上的正弦激励信号,预留外接时钟接口,频率、幅值可调。 方案: 1、PWM波转模拟量(PAC =...2、外接DDS模块,由beaglebone控制DDS模块,从而产生不...

    Data:2019/1/23      author:wangsong

    需求:要求能有产生一路1MHZ以上的正弦激励信号,预留外接时钟接口,频率、幅值可调。

    方案:

    1、PWM波转模拟量(PAC =PWM to Analog Convertor)是一种PWM信号转模拟信号的专用芯片,模块最大频率只够200KHZ。(否决)

    2、外接DDS模块,由beaglebone控制DDS模块,从而产生不同相位频率的正弦波,需要自己写驱动直接控制DDS。(测试)

    3、DDS最基础的AD9833的频率就能达到需求,用集成STM32作为局部控制器,AM335X通过串口发送控制指令。(否决)

     

    遇到问题:采购的AD9833用的是标准三线式串行接口兼容SPI,根据数据手册和电路原理图,则只需要这三个数据口;而beaglebone预留的是4线的SPI,其中对应引脚和设备树中对应如下表,来自于博客:https://blog.csdn.net/wyt2013/article/details/16921573 ,而三线制SPI和四线制的SPI是否只是删除一个单向数据线我没有深究,直接做法是根据AD8933数据手册里提供的时序,使用GPIO口模拟。其中数据手册以及其他参考资料在亚德诺(ADI)半导体官网下载:https://www.analog.com/cn/products/ad9833.html

     

    https://img-blog.csdn.net/20131124171732203

    说明:FSYNC输入是电平触发输入,用作帧同步和芯片使能。仅当FSYNC处于低电平时,才可将数据传输至器件。要开始串行数据传输,应将FSYNC拉低,并注意FSYNC至SCLK下降沿建立时间t 7 的最小值。FSYNC变为低电平后,串行数据即会在16个时钟脉冲的SCLK下降沿移入器件的输入移位寄存器。可在SCLK的第16个下降沿后将FSYNC拉高,并注意SCLK下降沿至FSYNC上升沿时间t 8 的最小值。或者,FSYNC可以在16倍数个SCLK脉冲期间保持低电平,然后在数据传输结束时变为高电平。这样,在FSYNC保持低电平期间,可以连续流形式载入16位字;FSYNC仅在载入最后一个字的第16个SCLK下降沿之后变为高电平。SCLK可以是连续的,也可以在写操作期间置于高电平或低电平空闲状态。无论何种情况,当FSYNC变为低电平(t 11 )时,SCLK都必须处于高电平。

    实施情况:

    参考源码:https://www.analog.com/cn/products/ad9833.html#product-requirement

    参考博客:基于OMAPL138的Linux字符驱动_GPIO驱动AD9833(二)之cdev与read、write

    https://blog.csdn.net/u014281970/article/details/82145664

     

    对作者的源码的说明:

    1. 源码将硬件资源引脚写死,固定的三个引脚,所以不考虑设备树等高级写法。
    2. 源码采用的GPIO口模拟三线式串行通信,根据上面的时序写成。

    调试过程中遇到的问题:

    1. GPIO口的定义,在程序中将GPIO口硬件资源写死指定的对应引脚,按照网上百度到的说明GPIO1_17指的则是32*1+17=49,则引脚号宏定义为49。根据BBB_Header_Table.pdf查得BBB的引脚号。但是调试时候发现不对,不知道是不是因为接了扩展板。

    经过调试,大学霸博客提供的这两个图配上微雪的LCD扩展板可以使用,其中定义的GPIO_XX,驱动程序中写死的引脚号则是XX。但也不是所有的都能用,因为有很多引脚以及被使用,查看微雪扩展板的原理图,看看能使用哪些引脚,最好在beaglebone的、sys/class/gpio中添加下引脚进行测试,看看是否能正常输出高低电平。最终本人使用的引脚是P9header:P11 、P15 、 P22引脚,对应的驱动程序中引脚号是:30、48、49.

    1. 驱动源码中相关函数说明:
    • file_operations结构体详解:

    https://www.cnblogs.com/chen-farsight/p/6181341.html

    • copy_to_user 、copy_from_user函数:

    https://blog.csdn.net/xiaodingqq/article/details/80150347

    • 内核MKDEV(MAJOR, MINOR)宏:

    http://blog.sina.com.cn/s/blog_752fa65f0100osao.html

    https://blog.csdn.net/angle_birds/article/details/7822416?utm_source=blogxgwz4

    • gpio_request()函数:

    https://blog.csdn.net/beyondioi/article/details/6984406

    • Linux字符设备驱动之cdev_init()系列:

    https://blog.csdn.net/tigerjibo/article/details/6412613

    • linux硬件设备操作函数 open(/dev/ietctl, O_RDWR|...)

    https://blog.csdn.net/pkigavin/article/details/8580703

    • IOCTL函数用法详解:

    https://blog.csdn.net/z_hualin/article/details/77892932

     

    • 驱动模块编译时要保证依赖的内核源码和板子上运行的内核一致:

    https://blog.csdn.net/qq_32059343/article/details/86572422

    https://blog.csdn.net/qq_32059343/article/details/86572477

    • 修改调试成功的源码分析:

    https://blog.csdn.net/qq_32059343/article/details/86583353

    实验结果:

    展开全文
  • Arduino库可控制AD9850 DDS模块 -------------代码在起作用------------ 摘自Analog Devices数据表: ( ) “ AD9850是一款高度集成的器件,采用先进的DDS技术以及内部高速,高性能D / A转换器和比较器,构成了...
  • DDS模块使用及DDS模块测试程序,外加测试软件,主要介绍AD9851和AD9850
  • DDS模块(AD9854)控制程序

    热门讨论 2011-03-28 15:24:20
    PC控制DDS模块软件 文件包含一个VB的源码程序,和一个VC的应用程序。 完全控制AD9854的内部寄存器,特别是以位的方式设置AD9854的控制位,可以非常直观,和非常容易掌握DDS芯片的应用。
  • Verilog DDS模块

    2009-07-22 06:42:37
    DDS函数发生器程序模块 快来用用哦 呵呵
  • DDS 模块9851详细资料包括程序,电路图等,DDS 模块方波的产生,与单片机的硬件连接及程序(并行送控制字方式),与单片机的硬件连接及程序(串行送控制字方式)等!
  • 通过430单片机控制ad9850(dds模块)以及用其输出调频波,用于05年电子设计竞赛A题.
  • 资料是DDS正弦信号发生器全套解决方案,照着做就是你自己的模块了,是博主上大学时做的,当时电赛获奖的作品,当时也没少花精力做的。基于AD9832实现,包含了原理图、PCB、驱动程序,相关资料,驱动根据自己的MCU...
  • MSP430驱动DDS模块AD9851

    千次阅读 2011-11-07 15:31:03
    #include "msp430x14x.h" #define ad9581_w_clk P2DIR|=BIT0 //写时钟信号于P2.0口 #define ad9581_w_clk_H P2OUT|=BIT0 //P2.0输出高电平 #define ad9581_w_clk_L P2OUT&=~BIT0 //P2.0输出低电平 ...
    #include "msp430x14x.h"
    
    #define ad9581_w_clk   P2DIR|=BIT0  //写时钟信号于P2.0口
    #define ad9581_w_clk_H P2OUT|=BIT0  //P2.0输出高电平
    #define ad9581_w_clk_L P2OUT&=~BIT0 //P2.0输出低电平
    
    #define ad9851_fq_up   P2DIR|=BIT1  //写频率值于P2.1口
    #define ad9851_fq_up_H P2OUT|=BIT1  //P2.1输出高电平
    #define ad9851_fq_up_L P2OUT&=~BIT1 //P2.1输出低电平
    
    #define ad9851_rest    P2DIR|=BIT2  //写复位信号P2.1口
    #define ad9851_rest_H  P2OUT|=BIT2  //P2.2输出高电平
    #define ad9851_rest_L  P2OUT&=~BIT2 //P2.2输出低电平
    
    #define ad9851_bit_data    P4DIR|=BIT7  //写数据于P4.7口
    #define ad9851_bit_data_H  P4OUT|=BIT7  //P4.7输出高电平
    #define ad9851_bit_data_L  P4OUT&=~BIT7 //P4.7输出低电平
    
    //***************************************************//
    //              ad9851复位(并口模式)                 //
    //---------------------------------------------------//
    void ad9851_reset()
    {
      ad9581_w_clk;
      ad9581_w_clk_L;
      ad9851_fq_up;
      ad9851_fq_up_L;
      //rest信号
      ad9851_rest;
      ad9851_rest_L;
      ad9851_bit_data_H;
      ad9851_bit_data_L;
    }
    //***************************************************//
    //              ad9851复位(并口模式)                 //
    //---------------------------------------------------//
    void ad9851_reset_serial()
    {
      ad9581_w_clk;
      ad9581_w_clk_L;
      ad9851_fq_up;
      ad9851_fq_up_L;
      //rest信号
      ad9851_rest;
      ad9851_rest_L;
      ad9851_bit_data_H;
      ad9851_bit_data_L;
      //w_clk信号
      //ad9581_w_clk;
      ad9581_w_clk_L;
      ad9581_w_clk_H;
      ad9581_w_clk_L;
      //fq_up信号
      //ad9851_fq_up;
      ad9851_fq_up_L;
      ad9851_fq_up_H;
      ad9851_fq_up_L;
    }
    //***************************************************//
    //          向ad9851中写命令与数据(并口)             //
    //---------------------------------------------------//
    void ad9851_wr_parrel(unsigned char w0,double frequence)
    {
      unsigned char w;
      long int y;
      double x;
      //计算频率的HEX值
      x=4294967295/180;//适合180M晶振/180为最终时钟频率(或30M六倍频)
      //如果时钟频率不为180MHZ,修改该处的频率值,单位MHz !!!
      frequence=frequence/1000000;
      frequence=frequence*x;
      y=frequence;
      P4DIR  |= 0xFF;
      //写w0数据
      w=w0;   
      P4OUT  |=w;//w0
      ad9581_w_clk_H;
      ad9581_w_clk_L;
      //写w1数据
      w=(y>>24);
      P4OUT  |=w;//w1
      ad9581_w_clk_H;
      ad9581_w_clk_L;
      //写w2数据
      w=(y>>16);
      P4OUT  |=w;//w2
      ad9581_w_clk_H;
      ad9581_w_clk_L;
      //写w3数据
      w=(y>>8);
      P4OUT  |=w;//w3
      ad9581_w_clk_H;
      ad9581_w_clk_L;
      //写w4数据
      w=(y>>=0);
      P4OUT  |=w;//w4
      ad9581_w_clk_H;
      ad9581_w_clk_L;
      //移入始能
      ad9581_w_clk_H;
      ad9581_w_clk_L;
    }
    //***************************************************//
    //          向ad9851中写命令与数据(串口)             //
    //---------------------------------------------------//
    void ad9851_wr_serial(unsigned char w0,double frequence)
    {
      unsigned char i,w;
      long int y;
      double x;
      ad9851_bit_data;
      //计算频率的HEX值
      x=4294967295/180;//适合180M晶振/180为最终时钟频率(或30M六倍频)
      //如果时钟频率不为180MHZ,修改该处的频率值,单位MHz  !!!
      frequence=frequence/1000000;
      frequence=frequence*x;
      y=frequence;
      //写w4数据
      w=(y>>=0);
      for(i=0;i<8;i++)
      {
        ad9851_bit_data_H|((w>>i)&0x01);
        ad9581_w_clk_H;
        ad9581_w_clk_L;
      }
      //写w3数据
      w=(y>>8);
      for(i=0;i<8;i++)
      {
        ad9851_bit_data_H|((w>>i)&0x01);
        ad9581_w_clk_H;
        ad9581_w_clk_L;
      }
      //写w2数据
      w=(y>>16);
      for(i=0;i<8;i++)
      {
        ad9851_bit_data_H|((w>>i)&0x01);
        ad9581_w_clk_H;
        ad9581_w_clk_L;
      }
      //写w1数据
      w=(y>>24);
      for(i=0;i<8;i++)
      {
        ad9851_bit_data_H|((w>>i)&0x01);
        ad9581_w_clk_H;
        ad9581_w_clk_L;
      }
      //写w0数据
      w=w0;   
      for(i=0;i<8;i++)
      {
        ad9851_bit_data_H|((w>>i)&0x01);
        ad9581_w_clk_H;
        ad9581_w_clk_L;
      }
      //移入始能
      ad9851_fq_up_H;
      ad9851_fq_up_L;
    }
    int main( void )
    {
      // Stop watchdog timer to prevent time out reset
      WDTCTL = WDTPW + WDTHOLD;
      //---------------------------------------------------//
      //并行写1000Hz程序
      ad9851_reset();
      ad9851_wr_serial(0x01,1000);
      //0X01为开六备频
      //ad9851_wr_parrel(0x00,1000);
      //0X00为不开六备频
      //---------------------------------------------------//
      //---------------------------------------------------//
      //串行写1000Hz程序
      //ad9851_reset_serial();
      //ad9851_wr_serial(0x01,1000);
      //0X01为开六备频
      //ad9851_wr_serial(0x00,1000);
      //0X00为不开六备频
      //---------------------------------------------------//
      while(1)
      {
      }
      return 0;
    }
    

    展开全文
  • 参考博客:基于OMAPL138的Linux字符驱动_GPIO驱动AD9833(二)之cdev与read、write ... /*ad9833.c*/ ... * AD9833 of ADI driver code for Beagleboneblack debian9.5 ... dds_frequence_low = dds_frequence_data & ...

    参考博客:基于OMAPL138的Linux字符驱动_GPIO驱动AD9833(二)之cdev与read、write

    https://blog.csdn.net/u014281970/article/details/82145664

    /*ad9833.c*/
    /*
     * AD9833 of ADI driver code for Beagleboneblack  debian9.5  kernel 4.14.79
     *
     * Copyright (C) 2018 Wei Haochen	2019/1/21 modify by wangsong
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * MULTIBEANS, NPU Youyi West Ave, Beilin District, Xi'an, China.
     */
    
    #include <linux/module.h>   /* Every Linux kernel module must include this head */
    #include <linux/init.h>     /* Every Linux kernel module must include this head */
    #include <linux/kernel.h>   /* printk() */
    #include <linux/fs.h>       /* struct fops */
    #include <linux/errno.h>    /* error codes */
    #include <linux/cdev.h>     /* cdev_alloc()  */
    #include <linux/ioport.h>   /* request_mem_region() */
    #include <linux/delay.h>
    #include <linux/moduleparam.h>
    #include <linux/types.h>
    #include <linux/gpio.h>
    #include <linux/device.h>
    #include <linux/types.h>
    
    #include <linux/miscdevice.h>	//必须有
    
    #include <asm/uaccess.h>
    #include <asm/div64.h>
    
    #include <asm/atomic.h>
    #include <asm/unistd.h>
    #include <asm/io.h>
    
    
    #define				DRV_AUTHOR					"Wei haochen Wangsong"
    #define				DRV_DESC					"AD9833 on AM335X beaglebone"
    #define				DRV_NAME					"AD9833-ADI"	//设备名称
    
    
    #define				AD9833_SIZE					0x1000
    #define				MEM_CLEAR					0x1
    #define				AD9833_MAJOR				230			//主设备号
    #define           	AD9833_REG_RESET            0x0100		//根据AD9833寄存器设定的重启
    #define           	AD9833_FREQ0_REG            0
    #define             AD9833_FREQ1_REG            1
    
    //AD9833_MAGIC ioctl命令需要的参数,描述了ioctl命令的类型,8位。每种设备或系统都可以指定自己的一个类型号
    //ioctl用这个类型来表示ioctl命令所属的设备或驱动,一般用ASCII码字符来表示,如‘a’/.
    #define				AD9833_MAGIC				'k'
    #define				CMD_PARA_FREQ				0x10
    #define				CMD_PARA_PHASE				0x11
    #define				CMD_PARA_TYPE				0x12
    
    //_IO(type,nr):无数据传输。幻数(type)\序号(nr)
    #define				CMD_TYPE_SIN				_IO( AD9833_MAGIC, 0)	//命令选择正弦波
    #define				CMD_TYPE_TRI				_IO( AD9833_MAGIC, 1)	//命令选择三角波
    #define				CMD_TYPE_SQE				_IO( AD9833_MAGIC, 2)	//命令选择方波
    
    #define				CMD_FREQ_SET(X)				_IO( CMD_PARA_FREQ, X)
    #define				CMD_PHASE_SET(X)			_IO( CMD_PARA_PHASE, X )
    #define				CMD_TYPE_SET(X)				_IO( CMD_PARA_TYPE,X )
    
    #define				IO_HIGH						1
    #define				IO_LOW						0
    
    //对应的beaglebone这个板子的GPIO
    #define				AD9833_FSY_IO				30   //P9header 11
    #define				AD9833_CLK_IO				48   //P9header 15
    #define				AD9833_DAT_IO				49	 //P9header 23
    
    //下面三个函数都仅仅在模拟SPI时序时候使用
    #define				io_clk(x)					gpio_set_value( AD9833_CLK_IO,x )
    #define				io_fsy(x)					gpio_set_value( AD9833_FSY_IO,x )
    #define				io_dat(x)					gpio_set_value( AD9833_DAT_IO,x )
    
    
    typedef	struct ad9833_t AD9833;
    
    enum ad9833_wavetype_t{
    	SIN,SQU,TRI
    };
    
    struct ad9833_hw_t {
    
    	unsigned int clk;
    	unsigned int sdi;
    	unsigned int fsy;
    };
    
    struct ad9833_t {
    
    	struct ad9833_hw_t hw;
    	struct ad9833_t *self;
    	enum ad9833_wavetype_t wave_type;
    
    	struct	cdev	cdev;
    	unsigned char	mem[ AD9833_SIZE ];
    
    	unsigned int delay;
    
    	void (*write_reg)	( AD9833 *self, unsigned int reg_value);
    	void (*init_device)	( AD9833 *self );
    	void (*set_wave_freq)( AD9833 *self , unsigned long freqs_data);
    	void (*set_wave_type)( AD9833 *self, enum ad9833_wavetype_t wave_type );
    	void (*set_wave_phase)( AD9833 *self, unsigned int phase );
    	void (*set_wave_para)( AD9833 *self, unsigned long freqs_data, unsigned int phase, enum ad9833_wavetype_t wave_type );
    };
    
    static void ad9833_set_wave_type( AD9833 *dev, enum ad9833_wavetype_t wave_type );
    static void ad9833_set_phase( AD9833 *dev, unsigned int phase_value );
    static void ad9833_set_freq( AD9833 *dev, unsigned long freq );
    static void ad9833_set_para( AD9833 *dev, unsigned long freqs_value, unsigned int phase_value, enum ad9833_wavetype_t wave_type );
    static void ad9833_init_device( AD9833 *dev ) ;
    static void ad9833_write_reg( AD9833 *dev, unsigned int reg_value );
    static long ad9833_ioctl(struct file  *file, unsigned int cmd, unsigned long arg );
    
    AD9833 *ad9833;
    static int	ad9833_major	=	AD9833_MAJOR;	//主设备号
    
    module_param( ad9833_major, int, S_IRUGO );
    
    static const short	ad9833_gpios[] = {
    		AD9833_FSY_IO,
    		AD9833_CLK_IO,
    		AD9833_DAT_IO,
    };
    
    AD9833 *ad9833_dev_new(void)
    {
    	AD9833 *dev = (AD9833*)kcalloc(1, sizeof(AD9833), GFP_ATOMIC);
    
    	dev->hw.fsy			  =	  AD9833_FSY_IO;
    	dev->hw.sdi			  =   AD9833_DAT_IO;
    	dev->hw.clk			  =	  AD9833_CLK_IO;
    
    	dev->set_wave_para    =   &ad9833_set_para;
    	dev->init_device      =   &ad9833_init_device;
    	dev->write_reg        =   &ad9833_write_reg;
    	dev->set_wave_freq    =   &ad9833_set_freq;
    	dev->set_wave_phase	  =   &ad9833_set_phase;
    	dev->set_wave_type    =   &ad9833_set_wave_type;
    	dev->init_device( dev );
    
    	return dev;
    }
    
    static long ad9833_ioctl(struct file  *file, unsigned int cmd, unsigned long arg)
    {
    
    	printk(DRV_NAME "\tRecv cmd: %u\n", cmd);
    	printk(DRV_NAME "\tRecv arg: %lu\n", arg);
    	switch( cmd ) {
    	case CMD_TYPE_SIN:
    		ad9833->set_wave_freq(ad9833, 1500);
    		ad9833->set_wave_type(ad9833, SIN);
    		printk( DRV_NAME " set wave is sine wave! arg = %lu\n" , arg );
    
    		break;
    
    	case CMD_TYPE_TRI:
    		ad9833->set_wave_freq(ad9833, 1500);
    		ad9833->set_wave_type(ad9833, TRI);
    		printk( DRV_NAME " set wave is tri wave! arg = %lu\n" , arg );
    		break;
    
    	case CMD_TYPE_SQE:
    		ad9833->set_wave_freq(ad9833, 1500);
    		ad9833->set_wave_type(ad9833, SQU);
    		printk( DRV_NAME " set wave is sw wave! arg = %lu\n" , arg );
    		break;
    
    	}
    	return	0;
    }
    
    //写入数据,模拟的3线SPI写入时序
    static void ad9833_write_reg( AD9833 *dev, unsigned int reg_value )
    {
    	unsigned short i;
    	io_clk(IO_HIGH);	//需要修改为为beaglebone的设置方式
    	io_fsy(IO_HIGH);
    	ndelay(10);
    	io_fsy(IO_LOW);
    
    	for ( i = 0; i < 16; i++ ) {
    
    		if ( reg_value & 0x8000 )
    			io_dat(IO_HIGH);
    		else
    			io_dat(IO_LOW);
    		ndelay(10);
    		io_clk(IO_LOW);
    		ndelay(10);
    		reg_value = reg_value << 1;
    		ndelay(10);
    		io_clk(IO_HIGH);
    	}
    	io_fsy(IO_HIGH);
    	io_dat(IO_HIGH);
    }
     
    //ad9833初始化
    static void ad9833_init_device( AD9833 *dev )
    {
    	dev->write_reg( dev, AD9833_REG_RESET );
    	dev->set_wave_para( dev,1500, 0 ,SIN );
    }
    
    //设置相位
    static void ad9833_set_para( AD9833 *dev, unsigned long freqs_value, unsigned int phase_value, enum ad9833_wavetype_t wave_type )
    {
    	unsigned long dds_frequence_data;
    	unsigned int dds_frequence_low;
    	unsigned int dds_frequence_high;
    	unsigned int phase_data;
    	phase_data      =   phase_value | 0xC000;
    
    	dds_frequence_data      =   freqs_value * 10;
    	dds_frequence_low       =   dds_frequence_data & 0x3FFF;
    	dds_frequence_low       |=  0x4000;
    	dds_frequence_data      =   dds_frequence_data >> 14;
    	dds_frequence_high      =   dds_frequence_data & 0x3FFF;
    	dds_frequence_high      |=  0x4000;
    	// 	reset device
    	dev->write_reg( dev, 0x0110 );
    	dev->write_reg( dev, 0x2100 );
    
    	dev->write_reg( dev,dds_frequence_low );
    	dev->write_reg( dev,dds_frequence_high );
    	dev->write_reg( dev, phase_data );
    
    	if( wave_type == TRI ) {
    		dev->write_reg( dev, 0x2002 );
    	}else if( wave_type == SQU ) {
    		dev->write_reg(  dev, 0x2028);
    	}else {
    		dev->write_reg( dev, 0x2000 );
    	}
    }
    
    //设置频率,寄存器28位,分两次写入
    static void ad9833_set_freq( AD9833 *dev, unsigned long freq )
    {
    	unsigned long dds_frequence_data;
    	unsigned long dds_frequence_low;
    	unsigned long dds_frequence_high;
    
    	dds_frequence_data      =   freq;
    	dds_frequence_low       =   dds_frequence_data & 0x3FFF;
    	dds_frequence_low       |=  0x4000;
    	dds_frequence_data      =   dds_frequence_data >> 14;
    	dds_frequence_high      =   dds_frequence_data & 0x3FFF;
    	dds_frequence_high      |=  0x4000;
    
    	dev->write_reg( dev, dds_frequence_low );
    	dev->write_reg( dev, dds_frequence_high );
    
    }
    
    static void
    ad9833_set_phase( AD9833 *dev, unsigned int phase_value )
    {
    	unsigned int phase_temp;
    	phase_temp = phase_value | 0xC000;
    	dev->write_reg( dev, phase_temp );
    }
    
    
    //选择产生波的类型:TRI三角波;SQU方波;SIN正弦波
    static void ad9833_set_wave_type( AD9833 *dev, enum ad9833_wavetype_t wave_type )
    {
    	if( wave_type == TRI ) {
    		dev->write_reg( dev, 0x2002 );
    	}else if( wave_type == SQU ) {
    		dev->write_reg(  dev, 0x2028);
    	}else {
    		dev->write_reg( dev, 0x2000 );
    	}
    }
    
    static ssize_t ad9833_driver_read( struct file *filp, char __user *buffer, size_t size, loff_t *f_pos )
    {
    	unsigned long 	p		=	*f_pos;
    	unsigned int 	count	=	size;
    	int 			ret		=	0;
    
    	if ( p >= AD9833_SIZE )		//p为读的位置相对稳健开头的偏移
    		return 0;
    	if ( count > AD9833_SIZE - p )
    		count = AD9833_SIZE - p;
    	if ( raw_copy_to_user( buffer, ad9833->mem + p, count) ) { 
    	//从内核空间拷贝数据到用户目录,buffer:目标地址: ad9833->mem + p;count:拷贝的字节数
    	//copy_to_user()成功返回0;失败返回1.
    		ret	=	-EFAULT;
    	}else {
    		*f_pos += count;
    		ret = 	count;
    		printk( DRV_NAME "\tread %u bytes from %lu\n", count, p );
    	}
    	return ret;
    }
    
    
    //从用户目录往内核空间写入数据
    static ssize_t ad9833_driver_write( struct file *filp, const char __user *buffer, size_t size, loff_t *f_pos )
    {
    	unsigned long 	p		=	*f_pos;
    	unsigned int 	count	=	size;
    	int 			ret		=	0;
    	char * endp="str";	
    
    	if ( p >= AD9833_SIZE )
    		return 0;
    	if ( count > AD9833_SIZE - p )
    		count = AD9833_SIZE - p;
    
    	memset( ad9833->mem,0, AD9833_SIZE ); //用于对内存空间的初始化
    	
    	if ( raw_copy_from_user( ad9833->mem + p, buffer, count) ) {
    		ret	=	-EFAULT;
    	}else {
    		*f_pos += count;
    		ret = 	count;
    		printk( DRV_NAME "\twrite %u bytes from %lu\n", count, p );
    		printk( DRV_NAME "\tRecv: %s \n", ad9833->mem + p );
    		printk( DRV_NAME "\tSet freq is: %ld \n", simple_strtol(ad9833->mem + p,&endp,0));
    		//将一个字符串转换成unsigend long long型数据
    		ad9833->set_wave_freq(ad9833, simple_strtol(ad9833->mem + p,&endp,0) );
    	}
    	return ret;
    }
    //用户进程利用在对设备文件进行诸如read/write操作的时候,系统调用通过设备文件的主设备号找
    //到相应的设备驱动程序,然后读取这个数据结构相应的函数指针,接着把控制权交给该函数,这是
    //Linux的设备驱动程序工作的基本原理。
    static struct file_operations ad9833_fops = {
    
    		.owner				=	THIS_MODULE,
    		.read				=  	ad9833_driver_read,
    		.write				=	ad9833_driver_write,
    		.unlocked_ioctl  	=  	ad9833_ioctl,
    };
    
    static struct miscdevice ad9833_miscdev  = {
    
    		.name				=	DRV_NAME,
    		.fops				=	&ad9833_fops,
    };
    
    dev_t	devno;
    static int __init ad9833_dev_init( void )	//入口函数
    {
    	int  i,ret;
    	int  index_minor = 0;		//次设备号
    	int mk_major;
    
    	/*
    	 * cdev alloc and release device code.
    	 * */
    	 //返回值:成功执行返回dev_t类型的设备编号
    	 //ad9833_major:主设备号
    	devno = MKDEV( ad9833_major, index_minor );		//获取设备在设备表中的位置
    	
    	mk_major	=	MKDEV(ad9833_major, 0);
    	if( ad9833_major ) {	
    	//主设备:devno:要分配的设备编号范围的初始值(次设备号常设为0); 
    	//1:连续编号范围. 
    	//DRV_NAME:编号相关联的设备名称. 
    		ret = register_chrdev_region( devno, 1, DRV_NAME );  //注册模块
    	}else {		//如果没有设备号,则动态申请一个设备号
    	//alloc_chrdev_region() 函数用于动态申请设备编号范围
    		ret = alloc_chrdev_region( &devno, 0, 1, DRV_NAME );
    		ad9833_major	=	MAJOR(devno);
    	}
    	if( ret < 0 ) {
    		printk(DRV_NAME "\t cdev alloc space failed.\n");
    		return ret;
    	}
    	/*
    	 * AD9833 new device
    	 * */
    	printk( DRV_NAME "\tApply memory for AD9833.\n" );
    	ad9833 = ad9833_dev_new();
    	if( !ad9833 ) {
    		ret = -ENOMEM;
    		printk(DRV_NAME "\tad9833 new device failed!\n" );
    		goto fail_malloc;
    	}
    
    	/*
    	 * AD9833 init gpios.
    	 * */
    	printk( DRV_NAME "\tInititial GPIO\n" );
    
    	for ( i = 0; i < 3; i ++ ) {
    		//ad9833_gpios[i]:则为你要申请的哪一个管脚;"AD9833 GPIO":为其取一个名字
    		ret	=	gpio_request( ad9833_gpios[i], "AD9833 GPIO" );	//GPIO申请注册
    		//返回值为0表示申请成功
    		if( ret ) {
    			printk("\t%s: request gpio %d for AD9833 failed, ret = %d\n", DRV_NAME,ad9833_gpios[i],ret);
    			return ret;
    		}else {
    			printk("\t%s: request gpio %d for AD9833 set succussful, ret = %d\n", DRV_NAME,ad9833_gpios[i],ret);
    		}
    		gpio_direction_output( ad9833_gpios[i],1 );
    		gpio_set_value( ad9833_gpios[i],0 );
    	}
    
    	/*
    	 * cdev init.
    	 * */
    	cdev_init( &ad9833->cdev, &ad9833_fops );//静态内存定义初始化
    	ad9833->cdev.owner	=	THIS_MODULE;
    	ret = cdev_add( &ad9833->cdev, mk_major,1 );
    	if( ret ) {
    		printk( KERN_NOTICE "Error %d adding ad9833 %d", ret, 1 );
    		return ret;
    	}
    
    	ret = misc_register( &ad9833_miscdev );
    	printk( DRV_NAME "\tinitialized\n" );
    	return 0;
    
    	fail_malloc:
    	unregister_chrdev_region( mk_major,1 );
    	return ret;
    
    }
    
    
    static void __exit ad9833_dev_exit( void )		//出口函数
    {
    	int i;
    	for( i = 0; i < 3; i++) {
    		gpio_free( ad9833_gpios[i] );
    	}
    	misc_deregister( &ad9833_miscdev );
    	unregister_chrdev_region( devno,1 );
    
    }
    
    module_init( ad9833_dev_init );
    module_exit( ad9833_dev_exit );
    
    
    MODULE_AUTHOR( DRV_AUTHOR );
    MODULE_DESCRIPTION(DRV_DESC);
    MODULE_LICENSE("GPL");
    
    
    

    编译模块的Makefile:

    #Makefile for ad9833.c
    ARCH=arm
    CROSS_COMPILE=arm-linux-gnueabihf-
    ifneq ($(KERNELRELEASE),)
    	obj-m := ad9833.o
    else 
    	KERNELDIR ?= /home/ws/4.14/linux-4.14/
    	PWD := $(shell pwd)
    default:
    	make -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules
    
    clean:
    	$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
    	rm -rf modules.order
    
    endif
    

    测试用的源码:

    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/ioctl.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <string.h>
    
    #define				AD9833_MAGIC				'k'
    #define				CMD_TYPE_SIN				_IO( AD9833_MAGIC, 0)
    #define				CMD_TYPE_TRI				_IO( AD9833_MAGIC, 1)
    #define				CMD_TYPE_SQE				_IO( AD9833_MAGIC, 2)
    
    
    const char dev_path[]="/dev/AD9833-ADI";
    
    int main(int argc , char *argv[])
    {
    
        int fd = -1, i = 0;
        
        printf("ad9833 test program run....\n");
    
    
        fd = open(dev_path, O_RDWR|O_NDELAY);  // 打开设备
    
        if (fd < 0) {
            printf("Can't open /dev/AD9833-ADI\n");
            return -1;
        }
    
        printf("open device.\n");
    
        if( strcmp(argv[1],"1") == 0 ) {
    	ioctl(fd, CMD_TYPE_SIN, 5);
    	printf("argc = %d,sine wave = %s \n", CMD_TYPE_SIN, argv[1]);
        }else if(  strcmp(argv[1],"2") == 0 ) {
    	ioctl(fd, CMD_TYPE_TRI, 1);
    	printf("argc = %d,tri wave = %s \n", CMD_TYPE_TRI,argv[1]);
        }else{
     	ioctl(fd, CMD_TYPE_SQE, 1);
    	printf("argc = %d,sqe wave = %s \n", CMD_TYPE_SQE, argv[1]);
        }
        write(fd, argv[2], strlen(argv[2]));
        
        printf("argc = %d\n", argc);
        close(fd);
    
        return 0;
    
    
    }
    
    

    编译测试代码的Makefile:

    CROSS=arm-linux-gnueabihf-
    all: ad9833_test 
    ad9833_test: ad9833_test.c
    	$(CROSS)gcc -o ad9833_test.o ad9833_test.c -static
    clean:
    	@rm -rf ad9833_test *.o
    
    

    在调试原作者源码时遇到的问题:

    1、 error: implicit declaration of function ‘copy_to_user’; did you mean‘raw_copy_to_user’? [-Werror=implicit-function-declaration]
      if ( copy_to_user( buffer, ad9833->mem + p, count) ) {
           ^~~~~~~~~~~~
           raw_copy_to_user
    原因:linux4.14的内核取消了copy_to_user,改为了raw_copy_to_user

    2、/home/ws/beaglebone_ad9833/driver/ad9833.c:149:9: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
     AD9833 *ad9833_dev_new()
             ^~~~~~~~~~~~~~
    原因:函数中传参为空的时候使用void,修改源码*ad9833_dev_new(void)


    3、/home/ws/beaglebone_ad9833/driver/ad9833.c:310:25: warning: passing argument 1 of ‘raw_copy_to_user’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
      if ( raw_copy_to_user( buffer, ad9833->mem + p, count) ) {

    原因:传参的第一个函数将不是const定义
    修改:
    static ssize_t ad9833_driver_read( struct file *filp, const char __user *buffer, size_t size, loff_t *f_pos )

    static ssize_t ad9833_driver_read( struct file *filp, char __user *buffer, size_t size, loff_t *f_pos )

    4、/home/ws/beaglebone_ad9833/driver/ad9833.c:345:74: error: passing argument 2 of ‘simple_strtol’ from incompatible pointer type [-Werror=incompatible-pointer-types]
       printk( DRV_NAME "\tSet freq is: %d \n", simple_strtol(ad9833->mem + p,"str",0));
    In file included from ./include/linux/list.h:9:0,
                     from ./include/linux/module.h:9,
                     from /home/ws/beaglebone_ad9833/driver/ad9833.c:21:
    ./include/linux/kernel.h:438:13: note: expected ‘char **’ but argument is of type ‘char *’
     extern long simple_strtol(const char *,char **,unsigned int);
    原因:
            printk( DRV_NAME "\tSet freq is: %d \n", simple_strtol(ad9833->mem + p,"str",0));
            ad9833->set_wave_freq(ad9833, simple_strtol(ad9833->mem + p,"str",0) );

    修改为:
            char * endp="str";

            printk( DRV_NAME "\tSet freq is: %d \n", simple_strtol(ad9833->mem + p,&endp,0));
            ad9833->set_wave_freq(ad9833, simple_strtol(ad9833->mem + p,&endp,0) );


    5、/home/ws/beaglebone_ad9833/driver/ad9833.c:363:15: error: variable ‘ad9833_miscdev’ has initializer but incomplete type
     static struct miscdevice ad9833_miscdev  = {
    原因:缺少头文件

    #include <linux/miscdevice.h>


    6、/home/ws/beaglebone_ad9833/driver/ad9833.c:362:25: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
       .unlocked_ioctl   =   ad9833_ioctl,
                             ^~~~~~~~~~~~
    原因:内核版本变迁,现在ioctl函数的返回值应该定义为long型。
    修改为:
    static long ad9833_ioctl(struct file  *file, unsigned int cmd, unsigned long arg)

    测试步骤说明:

    1. 将ad9833.c的源码和Makefile拷贝到一个文件夹下,在PC端的终端进入文件夹下,执行make命令,则可以编译成模块,其中Makefile中需要修改依赖的linux编译过得内核路径,也许交叉编译链用的也不一样,也需要修改。
    2. 将编译过的整个文件夹通过TFTP传输到与其相连的Beaglebone中。
    3. 登录到beaglebone上,使用insmod命令挂载模块,lsmod查看挂载状态,rmmod卸载模块。
    4. 接着回到PC端复制测试文件的源码和Makefile,放在一个文件夹下,将文件传输到Beaglebone中,通过串口(minicom)登录到Beaglebone上。在Beaglebone的该文件夹下执行make命令,生成可执行文件。
    5. root权限执行命令。
      sudo ./ad9833 1 2000

      第一个参数表示选择正弦波,第二个参数表示设置频率。

     

    展开全文
  • DDS 信号模块AD9850模块资料, AD9850/AD9851模块是采用ADI应用最广泛的DDS(AD9850和AD9851)制作的模块。ADI的性能就不用多说了。模块主要参考AD9850和AD9851的资料做的。
  • DDS9850模块资料

    2013-12-06 09:38:04
    里面有DDS的一些资料,这是AD9850
  • DDS

    2017-02-16 17:18:33
    作业要求在FPGA上设计一个DDS模块,在DE0 开发板上运行,在FPGA芯片内部合成出数字波形即可。不用输出模拟信号,本模块满足以下条件 使用板载晶振的50MHz时钟,合成以下频率的信号 1、500KHz 正弦波信号。 2、1MHz ...
  • DDS-AD9850模块资料

    2014-01-21 18:59:59
    DDS-AD9850模块芯片的详细资料及应用程序,用它来实现1-40Mmz的正弦波输出,也可实现方波输出,占空比可调。
  • DDS波形发生器

    2018-01-07 15:36:13
    DDS模块可以产生各种波形如正弦波三角波

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 465
精华内容 186
关键字:

dds模块