集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1973|回复: 2

分享等精度测频源程序

[复制链接]
老怪甲 该用户已被删除
老怪甲 发表于 2010-5-20 10:31:55 | 显示全部楼层 |阅读模式
分享等精度测频源程序

本人是初学者,刚接触VHDL不久,仿照书上实例编了频率计程序,下载到MAX7128CPLD后能很好实现

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?我要注册

x
yezhutou 发表于 2010-8-7 22:38:16 | 显示全部楼层
module pwm (clk, write_data, cs, write_n, addr, clr_n, read_data, pwm_out);
input clk;
input [310] write_data;

input cs;
input write_n;
input addr;
input clr_n;
output [310] read_data;
output pwm_out;
定义period和pulse_width寄存器的内容
reg [310] period;
reg [310] pulse_width;
reg [310] counter;
reg off;
reg [310] read_data;
wire period_en, pulse_width_en; 写使能


always @(posedge clk or negedge clr_n)
begin
  if (clr_n==0)
  begin
    period=32'h 00000000;
    pulse_width=32'h 00000000;
  end
  else begin
    if (period_en) period=write_data[310];
    else period=period;
    if (pulse_width_en) pulse_width=write_data[310];
    else pulse_width=pulse_width;
  end
end
period和pulse_width寄存器的读访问
always @(addr or period or pulse_width)
if (addr == 0) read_data=period;
else read_data=pulse_width;

always @(posedge clk or negedge clr_n)
begin
  if (clr_n==0) counter=0;
  else if (counter=period-1) counter=0;
  else counter=counter+1;
end

always @(posedge clk or negedge clr_n)
begin
  if (clr_n==0) off=0;  
  else if (counter=pulse_width) off = 1;
  else if (counter==0)   off=0;
  else off=off;
end

assign period_en = cs & !write_n & !addr;
assign pulse_width_en = cs & !write_n & addr;

endmodule
fpga_feixiang 发表于 2021-10-5 12:59:59 | 显示全部楼层
666666666666666
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-17 13:03 , Processed in 0.120385 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表