fpga助教面试题

第一题

c 复制代码
module sfp_pwm(
input wire clk, //clk is 200M
input wire rst_n,
input wire clk_10M_i,
input wire PPS_i,
output reg pwm
)
reg [6:0] cunt  ;

always @(posedge clk ) begin
    if(!rst_n)
    cunt<=0;
    else if(cunt==19)   //200M是10M的20倍
    cunt<=0;
    else
    cunt<=cunt+1;
    
end
always @(posedge clk_10M_i ) begin
    if(!rst_n)
    pwm<=0;
    else if(PPS_i&&cunt<15)
    pwm<=1;
    else if(PPS_i==0&&cunt<10)
    pwm<=1;
    else
    pwm<=0;
    end
endmodule

第二题 需要用到vivado pll时钟这个ip核

因为1.023这个时钟无法直接产生可以先产生10.23M的时钟 再通过分频产生1.023 M的时钟

c 复制代码
`timescale 1ns / 1ps
module test_two(
    input  wire        clk, //clk is 60M 
    input  wire        rst_n, 
    output wire        clk_1023k_o, 
    output wire        ca
    );
wire clk_out1;
wire resetn  ;
wire locked  ;
reg  [3:0]  cunt    ;
wire        clk_1023;
reg  [11:0] ca_r    ;

assign resetn=(rst_n&&locked)?1:0;
assign clk_1023k_o=(cunt<5)?1:0; //1.023M时钟
assign ca=ca_r[0];
always @(posedge clk_out1 ) begin
    if(!resetn)
    cunt<=0;
    else if(cunt==9)
    cunt<=0;
    else
    cunt<=cunt+1;    
end
always @(posedge clk_1023k_o ) begin
    if(!resetn)
    ca_r<=12'h124;
    else
    ca_r <= {ca_r[10:0], ca_r[11] ^ ca_r[10] ^ ca_r[7] ^ ca_r[5]};
end

  clk_wiz_0 instance_name
   (
    // Clock out ports
    .clk_out1(clk_out1),     // output clk_out1
    // Status and control signals
    .resetn(resetn), // input resetn
    .locked(locked),       // output locked
   // Clock in ports
    .clk_in1(clk));      // input clk_in1

endmodule
相关推荐
通信王667 小时前
ZYNQ架构下的AXI_Lite 总线详解(1)
fpga开发
星夜离尘568 小时前
FPGA 不用浮点开平方:逐位恢复整数平方根、余数与完整握手验证
fpga开发
Enclustra_China8 小时前
FPGA设计的隐藏难题:算力、功耗与散热如何平衡?
fpga开发·fpga·fpga解决方案
好焊孙辉9 小时前
从六代螺柱焊机到AI质检:鸿栢科技的螺柱焊国产化路径
人工智能·python·科技·fpga开发
unicrom_深圳市由你创科技10 小时前
高帧率机器视觉 FPGA 图像板卡及传输开发定制解决方案
fpga开发
幻智星科技1 天前
纯FPGA网络通信实现微秒级确定性延迟
网络协议·fpga开发·硬件架构
泡泡糖的中文规格书1 天前
HDLbits 1.5 学习笔记
fpga开发
幻智星科技1 天前
FPGA不同品牌开发平台约束文件迁移难题解析
fpga开发·架构·硬件架构
幻智星科技1 天前
Karatsuba与CSD优化FPGA大数乘法
c++·fpga开发·密码学
星夜离尘561 天前
FPGA 实战:W1C 中断状态寄存器,事件置位与软件清除撞在同一拍怎么办
fpga开发