[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
相关推荐
czhaii34 分钟前
STC32G144K246,高速PWM@240Mhz 运行测试
stm32·单片机·fpga开发
Moonnnn.2 小时前
【FPGA】设计流程——Verilog输入
fpga开发
国科安芯3 小时前
AS32S601ZIT2抗辐照MCU在商业卫星飞轮系统中的可靠性分析
服务器·网络·人工智能·单片机·嵌入式硬件·fpga开发·1024程序员节
promising-w5 小时前
【FPGA】三八译码器verilog实现
fpga开发
风已经起了6 小时前
FPGA学习笔记——用Vitis IDE生成工程(串口发送)
笔记·学习·fpga开发·fpga·1024程序员节
竹一阁10 小时前
数字阵列雷达系统(一)——概念及组成
fpga开发·信号处理
Moonnnn.14 小时前
【FPGA】设计流程——仿真验证
fpga开发
千歌叹尽执夏17 小时前
Quartus25.3:Agilex5A EMIF学习调用(DDR5)
fpga开发·1024程序员节·ddr5·agilex5·emif
LCMICRO-1331084774621 小时前
长芯微LDUM3160完全P2P替代ADUM3160,LDUM3160是一款采用ADI公司iCoupler® 技术的USB端口隔离器
网络·stm32·单片机·嵌入式硬件·网络协议·fpga开发·硬件工程
奋斗的牛马21 小时前
FPGA—ZYNQ学习GPIO-EMIO(三)
学习·fpga开发