[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
相关推荐
风_峰2 天前
Ubuntu Linux SD卡分区操作
嵌入式硬件·ubuntu·fpga开发
FPGA_Linuxer2 天前
FPGA 40 DAC线缆和光模块带光纤实现40G UDP差异
网络协议·fpga开发·udp
风_峰2 天前
Petalinux相关配置——ZYNQ通过eMMC启动
嵌入式硬件·ubuntu·fpga开发
风_峰2 天前
【ZYNQ开发篇】Petalinux和电脑端的静态ip地址配置
网络·嵌入式硬件·tcp/ip·ubuntu·fpga开发
碎碎思2 天前
一块板子,玩转 HDMI、USB、FPGA ——聊聊开源项目 HDMI2USB-Numato-Opsis
fpga开发
ooo-p2 天前
FPGA学习篇——Verilog学习Led灯的实现
学习·fpga开发
嵌入式-老费2 天前
Zynq开发实践(FPGA之选择开发板)
fpga开发
风_峰3 天前
PuTTY软件访问ZYNQ板卡的Linux系统
linux·服务器·嵌入式硬件·fpga开发
电子凉冰3 天前
FPGA入门-状态机
fpga开发
Aczone283 天前
硬件(十)IMX6ULL 中断与时钟配置
arm开发·单片机·嵌入式硬件·fpga开发