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
相关推荐
szxinmai主板定制专家2 小时前
驱控一体新范式:RK3576+FPGA+CODESYS工业实时AI控制架构全解
人工智能·嵌入式硬件·计算机视觉·fpga开发·架构·工业ai·驱控一体
国科安芯3 小时前
ASC0101S自动双向电平转换原理深剖
单片机·嵌入式硬件·fpga开发·云计算·信息与通信
落chen4 小时前
7 Series FPGAs Clocking Resources
fpga开发
落chen1 天前
基于FPGA的IIC协议通信-强化篇
fpga开发
梦开始的地方 �1 天前
实例化和句柄
fpga开发
lf2824814311 天前
11 FM调制与解调的仿真
fpga开发
蓝悦无人机1 天前
Altium Designer 2024 PCB高级功能:不同Pitch的BGA设计要求
fpga开发·pcb·硬件设计·ad2024
ALINX技术博客2 天前
【黑金云课堂】FPGA技术教程Linux开发:系统定制
linux·运维·fpga开发
塔能物联运维2 天前
**塔能两相液冷:量化交易场景下的硬核验证,±1.5℃控温如何转化为真金白银**
人工智能·fpga开发·两相液冷
西安景驰电子3 天前
PCIe 授时卡原理及应用
运维·服务器·windows·单片机·嵌入式硬件·fpga开发