[HDLBits] Exams/2014 q4b

Consider the n-bit shift register circuit shown below:

Write a top-level Verilog module (named top_module) for the shift register, assuming that n = 4. Instantiate four copies of your MUXDFF subcircuit in your top-level module. Assume that you are going to implement the circuit on the DE2 board.

  • Connect the R inputs to the SW switches,
  • clk to KEY[0],
  • E to KEY[1],
  • L to KEY[2], and
  • w to KEY[3].
  • Connect the outputs to the red lights LEDR[3:0].

(Reuse your MUXDFF from exams/2014_q4a.)

复制代码
module top_module (
    input [3:0] SW,
    input [3:0] KEY,
    output [3:0] LEDR
); //
    MUXDFF d3(SW[3],KEY[3],KEY[1],KEY[2],KEY[0],LEDR[3]);
    MUXDFF d2(SW[2],LEDR[3],KEY[1],KEY[2],KEY[0],LEDR[2]);
    MUXDFF d1(SW[1],LEDR[2],KEY[1],KEY[2],KEY[0],LEDR[1]);
    MUXDFF d0(SW[0],LEDR[1],KEY[1],KEY[2],KEY[0],LEDR[0]);
endmodule

module MUXDFF (
	input r,w,e,l,
    input clk,
    output q);
	wire d;
    assign d=(l?r:(e?w:q));
    always@(posedge clk) begin
        q<=d;
    end
endmodule
相关推荐
gaoxcv13 小时前
TDC相关的一些方法
fpga开发
我爱C编程13 小时前
【3.4】双口RAM模块的FPGA实现
fpga开发·fpga·fft·双口ram
三万棵雪松13 小时前
【嵌入式刷题硬件设计基础(一)】
fpga开发·嵌入式·硬件基础
扣脑壳的FPGAer13 小时前
Xilinx远程更新之watchdog Timer1/ Timer2
fpga开发
ALINX技术博客14 小时前
【黑金云课堂】FPGA技术教程Linux开发:Petalinux安装
linux·运维·fpga开发
豆包公子1 天前
虚拟机配置共享文件&烧录FPGA bit文件
fpga开发
c-u-r-ry301 天前
pll/mmcm输入时钟配置页面警告
经验分享·fpga开发
逻辑诗篇1 天前
硬核算力集结!TMS320C6678、XC7K690T等、匠行科技SBC819模拟信号采集处理板,解锁高端测控新标杆
科技·fpga开发
狂奔蜗牛(bradley)1 天前
FPGA基础知识:深度剖析异步复位同步释放
fpga开发
发发就是发2 天前
USB系统架构概述:从一次诡异的枚举失败说起
驱动开发·单片机·嵌入式硬件·算法·fpga开发