1、b. (3)中经数字滤波的信号,在转换成十进制并做七段译码后,百位经端口d00,十位经端口d10,个位经端口d01送出;c. (3)中经数字滤波的信号,在经过压缩后通过端口ap送出。 5.2: 数字滤波器数字滤波器的转移函数为:滤波器的系数B0,B1,.,B6均由微处理器给出。微处理器可以根据需要修改这些系数。 5.2:系统模块说明和代码说明:根据功能分析,将整个系统分为8个模块。各个模块对应的源文件和功能描述如下表所示。模块名称对应源文件功能说明decoderdecoder.v将四位二进制译码为LED显示。输入4bit,输出为7bit直接驱动显示装置,为组合逻辑。H2DH2D.v进行16进制
2、到十进制的转换。输入为8bit无符号数,输出为百,十,个位数字(其中每个数字4bit位宽),同样为组合逻辑decoder_4X164-16译码器,主要是将经过y=sqrt(x)压缩后的数据送至显示设备。输入4bit,输出16bit,组合逻辑。sqrt_lutsqrt_lut.v主要实现y=sqrt(x)的运算。主要是通过比较和查找表方式实现。输入8bit,输出4bit。时序逻辑,一个时钟周期。mul8b_shiftadd_fsmmul8b_shiftadd_fsm.v乘法器设计。通过移位加的方式实现。内部通过状态机实现。完成一次乘法需要8个时钟周期timer_clktimer_clk.v时间时
3、钟模块,主要是根据系统时钟计算秒。通过计数器级联的方式实现。filterfilter.v这是整个系统比较核心的部分。主要实现滤波器的设计和与微处理器的接口时序设计。接口需要三态控制,并且要注意读写信号的控制,滤波器采用并行设计,用面积换取速度。TH99CHLSTH99CHLS.v顶层元件例化。主要是将上述各个模块进行组合。 整个功能框图如下:6:代码功能测试下面是测试用的模块介绍,模拟TH99CHLS外围的单片机、控制信号和数据输入等:对应的源文件osc_rstosc_rst.v产生时钟频率和复位信号fir_tbfir_tb.v滤波器数据的输入wr_rdwr_rd.v单片机WR,RD信号的模拟
4、mcumcu.v主要是模拟单片机对TH99CHLS芯片的控制,包括寄存器的读入与读出等一系列操作top_testtop_test.v顶层测试文件,主要是进行元件例化ModelSimSE功能仿真结果波形图如下:第一张图为前0-7us,第二张图为7us-15us.详细图形见source中的1.bmp和2.bmp.也可以查看其下的vsim.wlf(需要安装modelsim)。此图为对TH99CHLS芯片内部b0-b6(滤波器系数)寄存器的操作和对mini,hour寄存器初始化的操作仿真结果。7:综合结果及分析Synplify综合结果如下:DC综合结果如下:8:所占用的资源和数据通道分析该系统所占用的
5、资源如下:在滤波器设计中,并没有采用乘法器的复用,而是采用了多个乘法器的复制,牺牲面积来换取速读的提高。综合后的频率能够达到50MHz。滤波器的数据通道如下:(用多个乘法器)9:Verilog HDL代码/timescale 1ns/10psmodule top_test(); wire clk,rst_n; wire 7:0 abus; wire ale,rbar_n,wbar_n,cs_n; wire pebar_n;0 fir_in; wire 7:0 dbus_xio; wire 13:0 hour,mini; wire 20:0 fir_out; wire 15:0 fir_out_
6、sqrt; wire send_data_en; fir_tb Ufir_tb(send_data_en,pebar_n,fir_in); osc_rst Uost_rst(clk,rst_n); TH99CHLS UTH99( dbus_xio, abus, rbar_n, wbar_n, ale, pebar_n, fir_in, cs_n, rst_n, clk, /output ports fir_out, fir_out_sqrt, hour, mini ); mcu Umcu( .dbus_xio(dbus_xio), .abus(abus), .rbar_n(rbar_n), .
7、wbar_n(wbar_n), .ale(ale), .cs_n(cs_n), .send_data_en(send_data_en) );endmodule/module decoder( /input hex, /output led ); input 3:0 hex; output reg 6:0 led; always (hex) begin case(hex) 4b0000:led=7b011_1111; /0b0001:b001_1000; /1b0010:b111_0110; /2b0011:b111_1100; /3b0100:b101_1001; /4b0101:b110_1
8、101; /5b0110:b110_1111; /6b0111:b011_1000; /7b1000:b111_1111; /8b1001:b111_1101; /9 default :b000_0000; /null endcase end/module TH99CHLS( /input input clk,rst_n; input 7: input ale,rbar_n,wbar_n,cs_n; input pebar_n; inout 7: output 13: output 20: output 15: wire 15:0 fir_out_Hex; wire 7:0 hour_Hex,
9、mini_Hex; wire 3:0 fir_sqt_Hex;0 hud_Hex,ten_Hex,num_Hex; filter Ufilter(.dbus_xio(dbus_xio),.abus(abus),.rbar_n(rbar_n), .wbar_n(wbar_n),.ale(ale),.pebar_n(pebar_n), .fir_in(fir_in),.cs_n(cs_n),.rst_n(rst_n),.clk(clk), .fir_out(fir_out_Hex),.hour(hour_Hex),.mini(mini_Hex); sqrt_lut Usqt(.result(fir
10、_sqt_Hex),.in(fir_out_Hex7:0),.clk(clk),.rst_n(rst_n); decoder_4X16 Ude4X16(.out(fir_out_sqrt),.in(fir_sqt_Hex); H2D UH2d1(.hex(fir_out_Hex7:0), .hud(hud_Hex),.ten(ten_Hex),.num(num_Hex); decoder Udecoder1(.hex(hud_Hex),.led(fir_out20:14); decoder Udecoder2(.hex(ten_Hex),.led(fir_out13:7); decoder U
11、decoder3(.hex(num_Hex),.led(fir_out6:0); decoder Udecoder4(.hex(hour_Hex7:4),.led(hour13: decoder Udecoder5(.hex(hour_Hex3:0),.led(hour6: decoder Udecoder6(.hex(mini_Hex7:4),.led(mini13: decoder Udecoder7(.hex(mini_Hex3:0),.led(mini6:/timescale 1ns/10psmodule wr_rd( dbus_xio, abus, rbar_n, wbar_n, a
12、le); parameter MCU_CLK=40;/25MHz parameter LL_DELAY=15; output reg 7: output reg ale,rbar_n,wbar_n; inout 7: reg ctrl; reg 7:0 abus_low; assign dbus_xio=ctrl?abus_low:8hzz; /if ctrl=1 output then hiz integer i; initial begin rbar_n=1b1; wbar_n=1 task write_register; input 7:0 write_addr;0 write_data
13、; /write movx begin ale=1b0;/config b0 #MCU_CLK; ctrl=1 #LL_DELAY; abus_low=write_addr; abus=8h0; ale=0; /float abus_low=write_data; #1; wbar_n=1 for(i=0;i8;i=i+1) endtask /end movx task read_register;0 read_addr; output 7:0 read_data; /read movx abus_low=read_addr; rbar_n=1 read_data=dbus_xio;7; en
14、dtask /module decoder_4X16( / output out, /16 bit width high voltag effect /input in /four bit width );0 in; output 15:0 out; assign out15= in3 & in2 & in1 & in0; /1111 15 assign out14= in3 &(in0); /1110 14 assign out13= in3 &(in1)& /1101 13 assign out12= in3 & /1100 12 assign out11= in3 &(in2)& /10
15、11 11 assign out10= in3 & /1010 10 assign out9 = in3 & /1001 9 assign out8 = in3 & /1000 8 assign out7=(in3)& /0111 7 assign out6=(in3)& /0110 6 assign out5=(in3)& /0101 5 assign out4=(in3)& /0100 4 assign out3=(in3)& /0011 3 assign out2=(in3)& /0010 2 assign out1=(in3)& /0001 1 assign out0=(in3)& /
16、0000 0 endmodulemodule filter( / input ports mini, inout wire 7: /data bus connect to p0 complex of data and addr /output reg 7:0 dbus; input 7: /addr bus connect to p2 input rbar_n,wbar_n; /rd and wr signal connect to rd,we of mcu input ale,cs_n; input pebar_n; input clk,rst_n; output reg 15: output 7: /*/ /about config0 B0,B1,B2,B3,B4,B5,B6;0 mcu_num;
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2