实验四

  • 格式:docx
  • 大小:89.79 KB
  • 文档页数:7

班级信工131 学号201306030127 姓名任春霖实验组别实验四
实验日期室温报告日期成绩
报告内容:(目的和要求、原理、步骤、数据、计算、小结等)
一、实验名称:频率计设计(实验四)
二、实验目的:用Verilog描述设计4位频率计,(测频范围0~9999Hz,分辨率1Hz)
三、实验环境:quartus||平台下的设计开发。

四、实验原理:
通过最基本的的VHDL语言及原理图设计的方法设计测频器。

module fp50M_9996Hz(clk,fp_out);
input clk;
output fp_out;
reg fp_out;
reg [12:0] Qtmp;
parameter N = 5002; // 50MHz/5002=9996Hz
always @ (posedge clk)
if ( Qtmp < N/2-1)
Qtmp <= Qtmp + 1'b1;
else
begin
Qtmp <= 1'b0;
fp_out<= ~fp_out;
end
endmodule
module fp50M_8Hz(clk,fp_out);
input clk;
output fp_out;
reg fp_out;
reg [22:0] Qtmp;
parameter N = 6250000; // 50MHz/625000=8Hz
if ( Qtmp < N/2-1)
Qtmp <= Qtmp + 1'b1;
else
begin
Qtmp <= 1'b0;
fp_out<= ~fp_out;
end
endmodule
module fp256 (CLK, // Clock,9996Hz
sel, // addr of mux8to1
fpout // Output
);
input CLK;
input [2:0] sel;
output fpout; // 1 Bit
reg fpout;
reg [7:0] q;
begin
q<=q+1'b1;
end
always @(sel,q)
begin
case (sel)
3'b000: fpout<=CLK; // 9996Hz
3'b001: fpout<=q[0]; // 4998Hz
3'b010: fpout<=q[1]; // 2499Hz
3'b011: fpout<=q[2]; // 1249.5Hz
3'b100: fpout<=q[3]; // 624.75Hz
3'b101: fpout<=q[4]; // 312.375Hz
3'b110: fpout<=q[5]; // 156.1875Hz
3'b111: fpout<=q[6]; // 78.09375Hz
default: fpout<=q[7];
endcase
end
endmodule
module cd4511x(LE_n,D,SEG7_n);
input LE_n; // latch enable,low active input [0:3] D; //a_b_c_d
output reg [6:0] SEG7_n; //g_f_e_d_c_b_a
always @(posedge LE_n)
// if (LE_n) //LE_n=1,not latch
case (D) // low active; hign active
4'b0000: SEG7_n<=7'b1000000; //0111111 // display 0
4'b1000: SEG7_n<=7'b1111001; //0000110 // display 1
4'b0100: SEG7_n<=7'b0100100; //1011011; // display 2
4'b1100: SEG7_n<=7'b0110000; //1001111; // display 3
4'b0010: SEG7_n<=7'b0011001; //1100110; // display 4
4'b1010: SEG7_n<=7'b0010010; //1101101; // display 5
4'b0110: SEG7_n<=7'b0000010; //1111100; // display 6
4'b1110: SEG7_n<=7'b1111000; //0001111; // display 7
4'b0001: SEG7_n<=7'b0000000; //1111111; // display 8
4'b1001: SEG7_n<=7'b0010000; //b1100111; // display 9
default: SEG7_n<=7'b1111111; //0000000;
endcase
endmodule。