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

相关推荐
tiantianuser3 天前
RDMA简介5之RoCE v2队列
fpga开发·verilog·fpga·rdma·高速传输·rocev2
迎风打盹儿3 天前
FPGA仿真中阻塞赋值(=)和非阻塞赋值(<=)区别
verilog·fpga·阻塞赋值·非阻塞赋值·testbench仿真
tiantianuser4 天前
RDMA简介3之四种子协议对比
verilog·fpga·vivado·rdma·高速传输
可编程芯片开发12 天前
基于FPGA的DES加解密系统verilog实现,包含testbench和开发板硬件测试
fpga开发·des·verilog·加解密
可编程芯片开发1 个月前
基于FPGA的PID控制器verilog实现,包含simulink对比模型
fpga开发·verilog·simulink·pid控制器
__pop_1 个月前
SV 仿真的常识
verilog
nanxl11 个月前
FPGA-DDS信号发生器
fpga开发·verilog·vivado
nanxl11 个月前
FPGA-数字时钟
fpga开发·verilog·vivado
__pop_2 个月前
system verilog 语句 耗时规则
verilog
0基础学习者2 个月前
按键消抖(用状态机实现)
前端·笔记·fpga开发·verilog·fpga