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

相关推荐
北方孤寂的灵魂3 天前
systemverilog中随机std::randomize的用法
verilog·systemverilog·sv·数字验证
FPGA_小田老师5 天前
FPGA例程(4):按键消抖实验
fpga开发·verilog·fpga demo·fpga例程
FPGA小迷弟11 天前
京微齐力FPGA联合modelsim仿真操作
fpga开发·ic·verilog·fpga·仿真
FPGA_小田老师12 天前
FPGA例程(3):按键检测实验
fpga开发·verilog·vivado·led灯·按键测试
FPGA小迷弟15 天前
modelsim使用教程,仿真技巧,精华帖
fpga开发·verilog·fpga·modelsim
才鲸嵌入式23 天前
香山CPU(国产开源)的 SoC SDK底层程序编写,以及其它开源SoC芯片介绍
c语言·单片机·嵌入式·arm·cpu·verilog·fpga
莫问前程_满城风雨25 天前
verilog 可变范围的bit选择
运维·服务器·verilog
啄缘之间1 个月前
10.基于 MARCH C+ 算法的SRAM BIST
经验分享·笔记·学习·verilog
s09071361 个月前
FPGA中同步与异步复位
fpga开发·verilog·xilinx·zynq
民乐团扒谱机1 个月前
十字路口交通信号灯控制器设计(Multisim 电路 + Vivado 仿真)
单片机·fpga开发·verilog·状态机·仿真·时序逻辑·multism