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].

    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

相关推荐
啄缘之间1 天前
4.6 学习UVM中的“report_phase“,将其应用到具体案例分为几步?
学习·verilog·uvm·sv
RunningCamel6 天前
[Vivado报错] [Runs 36-527] DCP does not exist
verilog·fpga·vivado报错
小妖11606 天前
verilog程序设计及SystemVerilog验证
verilog
bitlogic7 天前
理解 SystemVerilog 中的循环与并发线程
verilog·systemverilog·scope·verification·fpga & design·lifetime·并发线程
啄缘之间7 天前
3.9 学习UVM中的uvm_env类分为几步?
学习·verilog·uvm·sv
啄缘之间8 天前
3.3 学习UVM中的uvm_driver 类分为几步?
学习·测试用例·verilog·uvm
晓晓暮雨潇潇12 天前
FPGA开发技能(10)热电偶测温ADS1118方案
fpga开发·verilog·热电偶·ads1118·温度测试方案
啄缘之间13 天前
verilog练习:i2c slave 模块设计
学习·fpga开发·verilog·uvm
啄缘之间14 天前
verilog练习:8bit移位寄存器
开发语言·学习·fpga开发·verilog·uvm
啄缘之间14 天前
3. 学习UVM的核心组件
学习·verilog·uvm·sv