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

相关推荐
微小冷9 天前
OV5640 相机开发流程
fpga开发·verilog·ov5640·双目相机·相机开发
ChipCamp12 天前
ChipCamp探索系列 -- 1. Soft-Core RISC-V on FPGA
fpga开发·verilog·risc-v
FPGA小迷弟21 天前
京微齐力系列FPGA---- Debugware IP核使用教程!!!
物联网·fpga开发·硬件架构·verilog·fpga
月光技术杂谈1 个月前
上海RISC-V峰会-香山开源RISC-V CPU随想随记
verilog·risc-v·chisel·vhdl·香山·开源cpu·xiangshan
可编程芯片开发1 个月前
基于FPGA的多级流水线加法器verilog实现,包含testbench测试文件
fpga开发·verilog·加法器·多级流水线
进击的奶龙1 个月前
02VCS_使用教程
verilog·仿真·eda
热爱学习地派大星2 个月前
Xilinx FPGA功耗评估
fpga开发·verilog·vivado·fpga功耗·xpe
进击的奶龙2 个月前
21verilog函数
verilog·基础语法
tiantianuser2 个月前
RDMA简介7之RoCE v2可靠传输
服务器·fpga开发·verilog·xilinx·rdma·可编程逻辑
9527华安2 个月前
国产安路FPGA纯verilog图像缩放,工程项目解决方案,提供5套TD工程源码和技术支持
fpga开发·verilog·图像缩放·双线性插值·安路fpga