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 KEY0,

  • E to KEY1,

  • L to KEY2, and

  • w to KEY3.

  • Connect the outputs to the red lights LEDR3:0.

    module top_module (
    input [3:0] SW,
    input [3:0] KEY,
    output [3:0] LEDR
    ); //

    复制代码
      MUXDFF MUX_3(
          .clk	(KEY[0]),
          .e		(KEY[1]),
          .l		(KEY[2]),
          .r		(SW[3]),
          .w		(KEY[3]),
      
          .Q     (LEDR[3])

    );

    复制代码
      MUXDFF MUX_2(
          .clk	(KEY[0]),
          .e		(KEY[1]),
          .l		(KEY[2]),
          .r		(SW[2]),
          .w		(LEDR[3]),
      
          .Q     (LEDR[2])

    );

    复制代码
      MUXDFF MUX_1(
          .clk	(KEY[0]),
          .e		(KEY[1]),
          .l		(KEY[2]),
          .r		(SW[1]),
          .w		(LEDR[2]),
      
          .Q     (LEDR[1])

    );

    复制代码
      MUXDFF MUX_0(
          .clk	(KEY[0]),
          .e		(KEY[1]),
          .l		(KEY[2]),
          .r		(SW[0]),
          .w		(LEDR[1]),
      
          .Q     (LEDR[0])

    );

    endmodule

    module MUXDFF (
    input clk,
    input e,
    input l,
    input r,
    input w,

    复制代码
      output Q

    );
    wire temp0;
    wire temp1;
    assign temp0 = e? w : Q;
    assign temp1 = l? r : temp0;

    复制代码
      always@(posedge clk)
          begin 
              Q <= temp1;
          end

    endmodule

相关推荐
星夜离尘561 天前
FPGA实现CRC-8/SMBUS:从参数和位序核对到1041次自检
fpga开发·verilog·fpga·crc
星夜离尘561 天前
FPGA正交编码器非法跳变检测:把16种状态转移和采样边界测清楚
verilog·fpga·编码器
星夜离尘562 天前
I²C总线卡死:先分清SCL拉低、SDA拉低,再谈9个时钟恢复
fpga开发·verilog·i2c
星夜离尘563 天前
Testbench不只看波形:用scoreboard抓住丢包、重复和乱序
fpga开发·verilog·testbench·scoreboard
星夜离尘563 天前
FIFO深度怎么定?用突发流量和背压算清缓存预算
缓存·fpga开发·verilog·fifo·背压
ChipCamp4 天前
零门槛上手的RISC-V项目:picorv32
ubuntu·verilog·verilator·iverilog·gtkwave·riscv64-unknown
m0_5474866616 天前
《数字电路与逻辑设计:基于Verilog HDL和Quartus Prime》全套PPT课件2026
verilog·数字电路·数字逻辑电路
学习FPGA的电气小兴兴17 天前
基于FPGA的CORDIC旋转模式实现sin和cos运算_采用EGo1板卡上板验证【FPGA数字信号处理第5讲】
fpga开发·信号处理·数字信号处理·verilog·cordic·ego1·fpga设计入门与提高
啄缘之间24 天前
1.【SVA】什么是SVA?
经验分享·学习·测试用例·verilog·sva
SDAU200525 天前
verilog计数器中增减操作之资源占用
verilog