首页 > 其他 > 详细

HDLbits——Mt2015 lfsr

时间:2021-09-06 03:27:34      阅读:22      评论:0      收藏:0      [点我收藏+]

1.描述电路图里面的一个子模块

技术分享图片


Assume that you want to implement hierarchical Verilog code for this circuit, 
using three instantiations of a submodule that has a flip-flop and multiplexer in it. 
Write a Verilog module (containing one flip-flop and multiplexer) named top_module for this submodule.
module dff(
    input clk,
    input q_in,
    input L,
    input r_in,
    output reg Q
);
    wire data;
    always @(posedge clk) begin
        Q <= data;     
    end 
    assign data = L ? r_in:q_in;

endmodule

技术分享图片

2.例化子模块


Write the Verilog code for this sequential circuit (Submodules are ok, but the top-level must be named top_module). 
Assume that you are going to implement the circuit on the DE1-SoC board. 
Connect the R inputs to the SW switches, connect Clock to KEY[0], and L to KEY[1]. Connect the Q outputs to the red lights LEDR.
```C

//Connect the R inputs to the SW switches, connect Clock to KEY[0], and L to KEY[1]. 
//Connect the Q outputs to the red lights LEDR.
module top_module (
	input [2:0] SW,      // R
	input [1:0] KEY,     // L and clk
	output [2:0] LEDR);  // Q
    wire Q_0;

    mt2015_muxdff mt2015_muxdff_ins0(
        .clk(KEY[0]),
        .L(KEY[1]),
        .q_in(LEDR[2]),
        .r_in(SW[0]),
        .Q(LEDR[0])
    );

    mt2015_muxdff mt2015_muxdff_ins1(
        .clk(KEY[0]),
        .L(KEY[1]),
        .q_in(LEDR[0]),
        .r_in(SW[1]),
        .Q(LEDR[1])
    );

    mt2015_muxdff mt2015_muxdff_ins2(
        .clk(KEY[0]),
        .L(KEY[1]),
        .q_in(LEDR[1]^LEDR[2]),
        .r_in(SW[2]),
        .Q(LEDR[2])
    );
endmodule


module mt2015_muxdff(
    input clk,
    input q_in,
    input L,
    input r_in,
    output reg Q
);
    wire data;
    always @(posedge clk) begin
        Q <= data;     
    end 
    assign data = L ? r_in:q_in;
endmodule

RTL原理图
技术分享图片

HDLbits——Mt2015 lfsr

原文:https://www.cnblogs.com/waqdgstd/p/15227258.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!