FPGA-江苏省集成电路技能大赛(2024)样卷2

一、题目

(二) 子任务2(20分)
利用给定的 FPGA 芯片内部资源,根据任务要求编写硬件描述语言源程序,完成仿真并下载至 FPGA 应用系统板上进行功能验证。

任务要求
完成图 1 所示交通灯电路的设计、仿真,并下载到 FPGA应用系统板上进行功能验证。

在这里插入图片描述

设南北方向为主干道,东西方向为支干道。
输入时钟为板载100MHz晶振产生的时钟,经过分频器后得到1Hz时钟。
交通灯由6个LED灯和4位数码管组成,各由3个LED灯表示东西方向和南北方向的交通灯红、黄、绿三种颜色,2位数码管表示东西方向和南北方向的交通灯当前状态下所剩时间。在绿灯状态下,时间在最后3秒时刻,LED灯要以0.5秒间隔闪烁。
2. 操作过程
1)FPGA 程序设计与下载验证
针对图 1 所示的流水灯功能框图,使用相关软件和硬件描述语言(VHDL或者Verilog HDL二选一,不得使用原理图,也不得调用IP),完成电路设计和功能仿真验证。
2) FPGA 应用系统板开发
根据比赛所提供的物料,完成 FPGA 应用系统板的开发。
3)FPGA 程序设计与下载验证
将设计好的流水灯程序下载到 FPGA 应用系统板上,利用系统板上相关的资源进行验证,确保该单元功能完整。

二、源代码

1、顶层模块

module top_module(clk,rst,seg1,seg2,com,led);
input clk,rst;
output [7:0]seg1,seg2;
output [3:0]com;
output [5:0]led;

wire [3:0]nb1,nb2,dx1,dx2;

ztj_module u1(.clk(clk),
              .rst(rst),
              .nb1(nb1),
              .nb2(nb2),
              .dx1(dx1),
              .dx2(dx2),
              .led(led)
              );

seg_module  u2(.clk(clk),
               .rst(rst),
               .nb1(nb1),
               .nb2(nb2),
               .dx1(dx1),
               .dx2(dx2),
               .seg1(seg1),
               .seg2(seg2),
               .com(com)
               );

endmodule

2、交通灯执行模块

module ztj_module
#(parameter u1s_max = 27'd99_999_999,
  parameter u500ms_max = 26'd49_999_999
  )
(clk,rst,nb1,nb2,dx1,dx2,led);
input clk,rst;
output [3:0]nb1,nb2,dx1,dx2;
output [5:0]led;

reg [3:0]nb1=2,nb2=7,dx1=3,dx2=0;
reg [5:0]led;
reg [26:0]u1s;
reg [5:0]cnt;
reg [25:0]u500ms;

always @(posedge clk or negedge rst)
  begin
    if(!rst)
      u500ms <= 0;
    else if(u500ms == u500ms_max)
      u500ms <= 0;
    else
      u500ms <= u500ms + 1;
  end

always @(posedge clk or negedge rst)
  begin
    if(!rst)
      u1s <= 0;
    else if(u1s == u1s_max)
      u1s <= 0;
    else
      u1s <= u1s + 1;
  end
  
always @(posedge clk or negedge rst)
  begin
    if(!rst) 
      cnt <= 0;
    else if((u1s == u1s_max) && (cnt == 49))
      cnt <= 0;
    else if(u1s == u1s_max)
      cnt <= cnt + 1;
    else
      cnt 
  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值