[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 (q511:0), and advance by one time step each clock cycle. The load input indicates the state of the system should be loaded with data511:0. Assume the boundaries (q-1 and q512) 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真舒服

相关推荐
神奇元创12 小时前
商用级光路加速卡:大模型推理的极速落地方案
python·神经网络·fpga开发·dsp开发
FPGA小徐1 天前
深度神经网络FPGA设计进展、实现与展望
fpga开发
FPGA小徐1 天前
FPGA数字信号处理(一)数字混频实现详解|NCO/DDS原理、有符号数避坑、直流滤除工程实战
fpga开发
Passionate.Z1 天前
基于FPGA的CLAHE自适应限制对比度直方图均衡算法硬件verilog实现
图像处理·嵌入式硬件·算法·fpga开发·fpga
Szime2 天前
AD9694 国产替代方案:四通道高速 ADC 在通信与雷达项目中的选型参考
单片机·嵌入式硬件·fpga开发
kaizq2 天前
在线MakerChip虚拟FPGA设计动态仿真实践
fpga开发·mulerun·makerchip·virtualfpgalab·在线动态仿真·imacopilot
FPGA小徐2 天前
OV5640 摄像头 DDR3 缓存 HDMI/VGA 显示系统详解与
fpga开发
Monkey of Semi2 天前
ARTIX-7 FPGA 核心板学习之FPGA Xilinx 7 series 命名规则
fpga开发
ALINX技术博客2 天前
【黑金云课堂】FPGA技术教程Vitis开发:TCP以太网通信
网络协议·tcp/ip·fpga开发
FPGA小徐2 天前
FPGA 电赛信号叠加与分离项目 完整工程包
fpga开发