[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
相关推荐
fei_sun5 小时前
逻辑设计概念及Vivado基础
fpga开发
发光的沙子7 小时前
FPGA----vitis测试linux程序
fpga开发
初夏正浓12 小时前
一文读懂“JESD204B”之链路建立与xilinx IP仿真
fpga开发·xilinx·jesd204b
FPGA-ADDA1 天前
第一篇:从“软件无线电”到“单芯片无线电”——RFSoC如何重塑无线系统设计
arm开发·信号处理·fpga·通信系统·rfsoc
s09071361 天前
【Zynq 进阶一】深度解析 PetaLinux 存储布局:NAND Flash 分区与 DDR 内存分配全攻略
linux·fpga开发·设备树·zynq·nand flash启动·flash分区
Kong_19941 天前
芯片开发学习笔记·二十——时序报告分析
fpga开发·芯片开发
凌盛羽2 天前
使用python绘图分析电池充电曲线
开发语言·python·stm32·单片机·fpga开发·51单片机
尤老师FPGA2 天前
LVDS系列44:Xilinx Ultrascale系 ADC LVDS接口参考方法(六)
fpga开发
化屾为海2 天前
FPGA之PLL展频
fpga开发
GateWorld2 天前
FPGA内部模块详解之七 FPGA的“灵魂”加载——配置模块(Configuration)深度解析
fpga开发·fpga config