[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
相关推荐
碎碎思5 小时前
“邪修“FPGA[~秘笈]
fpga开发
不会留有遗憾7 小时前
【FPGA】VGA显示-贪吃蛇
fpga开发
FPGA IP1 天前
基于LZO的无损数据压缩IP,高性能压缩速率32Gbps,压缩率50%,适用FPGA&ASIC
ip·fpga·无损压缩·lzo
9527华安1 天前
FPGA实现Aurora 64B66B数据回环传输,基于GTY高速收发器,提供4套工程源码和技术支持
fpga开发·aurora·高速收发器·gty·64b66b
嵌入式-老费1 天前
Zynq开发实践(FPGA之verilog仿真)
fpga开发
希言自然也3 天前
FPGA 时序分析(一)
fpga开发
I'm a winner3 天前
基于FPGA的情绪感知系统设计方案:心理健康监测应用(一)
fpga开发·前沿研究
嵌入式-老费3 天前
Zynq开发实践(Verilog、仿真、FPGA和芯片设计)
fpga开发
hahaha60164 天前
pcie实现虚拟串口
stm32·单片机·fpga开发
9527华安4 天前
FPGA高端项目:图像采集+Aurora 8B10B+UDP图传架构,基于GTH高速收发器的光口转网口,提供工程源码和技术支持
fpga开发·架构·udp·aurora·gth·高速收发器·aurora 8b10b