[HDLBits] Rule90

Rule 90 is a one-dimensional cellular automaton with interesting properties.

The rules are simple. There is a one-dimensional array of cells (on or off). At each time step, the next state of each cell is the XOR of the cell's two current neighbours. A more verbose way of expressing this rule is the following table, where a cell's next state is a function of itself and its two neighbours:

Left Center Right Center's next state
1 1 1 0
1 1 0 1
1 0 1 0
1 0 0 1
0 1 1 1
0 1 0 0
0 0 1 1
0 0 0 0

(The name "Rule 90" comes from reading the "next state" column: 01011010 is decimal 90.)

In this circuit, create a 512-cell system (q[511:0]), and advance by one time step each clock cycle. The load input indicates the state of the system should be loaded with data[511:0]. Assume the boundaries (q[-1] and q[512]) are both zero (off).

复制代码
module top_module(
    input clk,
    input load,
    input [511:0] data,
    output [511:0] q ); 
    always@(posedge clk) begin
        if(load)
            q<=data;
        else
            q<={1'b0,q[511:1]}^{q[510:0],1'b0};
        //verilog最好的地方就是支持整个数组批量运算
    end
endmodule

verilog真舒服

相关推荐
FPGA小c鸡12 小时前
异步FIFO设计与验证完全指南:从格雷码到CDC同步的深度解析(附SystemVerilog实战代码)
fpga开发
春风细雨无声15 小时前
基于FPGA实现PAL视频接口(附代码)
图像处理·fpga开发·视频
算法笑匠15 小时前
FPGA驱动AD9226实现65MSPS高速数据采集
fpga·adc·高速数据采集·ad9226
国科安芯16 小时前
多相交错并联系统的时钟同步精度与输入纹波抵消效应研究
网络·单片机·嵌入式硬件·fpga开发·性能优化
科恒盛远1 天前
KH919-基于FPGA实现的线性调频卡
fpga开发
FPGA小c鸡2 天前
PCIe接口详解:从协议原理到FPGA实现的完整指南
fpga开发
良许Linux2 天前
FPGA原理和应用
stm32·单片机·fpga开发·程序员·嵌入式·编程
Hello.Reader3 天前
Flink External Resource Framework让作业“原生”申请 GPU/FPGA 等外部资源
大数据·fpga开发·flink
嵌入式-老费3 天前
Linux Camera驱动开发(fpga vs soc)
驱动开发·fpga开发
太空1号3 天前
SystemVerilog小白入门3,UVM的uvm_object初体验
fpga开发