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
相关推荐
Terasic友晶科技10 小时前
第29篇 基于ARM A9处理器用C语言实现中断<五>
c语言·fpga开发·定时器中断
9527华安13 小时前
FPGA实现GTY光口视频转USB3.0传输,基于FT601+Aurora 8b/10b编解码架构,提供2套工程源码和技术支持
fpga开发·音视频·aurora·gty·usb3.0·ft601
博览鸿蒙15 小时前
FPGA开发要学些什么?如何快速入门?
fpga开发
@晓凡18 小时前
FPGA中利用fifo时钟域转换---慢时钟域转快时钟域
fpga开发
Hcoco_me1 天前
HDLBits ——> Building Larger Circuits
fpga开发
碎碎思2 天前
FPGA DSP:Vivado 中带有 DDS 的 FIR 滤波器
fpga开发
电子阿板4 天前
ZYNQ TCP Server PS端千兆网口速率低问题,要修改BSP中LWIP配置参数
嵌入式硬件·tcp/ip·fpga开发·tcp
9527华安4 天前
FPGA实现SDI视频解码转GTY光口传输,基于GS2971+Aurora 8b/10b编解码架构,提供工程源码和技术支持
fpga开发·架构·音视频·8b/10b·sdi·gty·gs2971
cjie2214 天前
国产FPGA开发板选择
fpga开发