[HDLBits] Mt2015 lfsr

Taken from 2015 midterm question 5. See also the first part of this question: mt2015_muxdff

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.

module top_module (
	input [2:0] SW,      // R
	input [1:0] KEY,     // L and clk
	output [2:0] LEDR);  // Q
	wire result;
    parts part1(KEY[0],KEY[1],SW[0],LEDR[2],LEDR[0]);
    parts part2(KEY[0],KEY[1],SW[1],LEDR[0],LEDR[1]);
    assign result=LEDR[2]^LEDR[1];
    parts part3(KEY[0],KEY[1],SW[2],result,LEDR[2]);
endmodule
        
        
module parts(
	input clk,
	input l,
	input r,
    input q1,
    output Q);
    wire d;
    assign d=l?r:q1;
    always@(posedge clk) begin
        Q<=d;
    end
endmodule
相关推荐
XiaoChaoZhiNeng11 小时前
基于Zynq SDIO WiFi移植二(支持2.4/5G)
5g·fpga·zynq·sdio
apple_ttt13 小时前
从零开始讲PCIe(6)——PCI-X概述
fpga开发·fpga·pcie
水饺编程15 小时前
【英特尔IA-32架构软件开发者开发手册第3卷:系统编程指南】2001年版翻译,1-2
linux·嵌入式硬件·fpga开发
apple_ttt15 小时前
从零开始讲PCIe(5)——66MHZ的PCI总线与其限制
fpga开发·fpga·pcie
最好有梦想~17 小时前
FPGA时序分析和约束学习笔记(2、FPGA时序传输模型)
fpga开发
IM_DALLA18 小时前
【Verilog学习日常】—牛客网刷题—Verilog企业真题—VL76
学习·fpga开发
诚实可靠小郎君95271 天前
FPGA IO延迟的约束与脚本
fpga开发·fpga·数字电路
日晨难再1 天前
AMBA:APB的历史(从APB1到APB5)
arm开发·arm·硬件工程·fpga·数字ic
GGGLF2 天前
FPGA-UART串口接收模块的理解
fpga开发
北京太速科技股份有限公司2 天前
太速科技-495-定制化仪器户外便携式手提触摸一体机
fpga开发