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 天前
【数字集成电路与系统设计】Chisel/Scala简介与Verilog介绍
scala·verilog·chisel
小桶qa2 天前
音频左右声道数据传输_2024年9月6日
音频·verilog
吉孟雷5 天前
ZYNQ FPGA自学笔记
fpga开发·verilog·led·仿真·vivado·zynq
热爱学习地派大星10 天前
BRAM IP Native模式使用
fpga开发·ip·verilog·fpga·存储器·bram
FPGA狂飙12 天前
1分钟 快速掌握 双向信号(inout信号)
fpga开发·verilog·fpga·xilinx
米联客(milianke)13 天前
[米联客-XILINX-H3_CZ08_7100] FPGA程序设计基础实验连载-24 TPG图像测试数据发生器设计
fpga开发·verilog
米联客(milianke)14 天前
[米联客-XILINX-H3_CZ08_7100] FPGA程序设计基础实验连载-26浅谈XILINX FIFO的基本使用
fpga开发·verilog
亦安的数字小站15 天前
ARM V2微架构
verilog
FPGA狂飙17 天前
【FPGA数字信号处理】并行FIR滤波器
fpga开发·信号处理·verilog·fpga·xilinx
Mr.Cssust18 天前
基于FPGA实现SD卡的数据读写(SD NAND FLASH)
嵌入式·verilog·fpga·芯片·sd·存储·flash