[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真舒服

相关推荐
ALINX技术博客16 小时前
AMD VU FPGA+NVIDIA Thor AI 超高性能异构平台 ALINX HEA13,支撑新一代边缘 AI 系统
人工智能·fpga开发
木心术11 天前
如何使用AI agent基于产品技术手册和标准协议完成FPGA寄存器的自动化配置、代码修改和编译的完整方案
人工智能·fpga开发·自动化
unicrom_深圳市由你创科技1 天前
多通道ADDA系统开发需要哪些技术?
fpga开发
ooo-p1 天前
FPGA相关(包含ZYNQ)基础概念理解
fpga开发
又菜又爱玩的东哥2 天前
【FPGA入门实战:Verilog实现边沿检测电路(附Testbench仿真)】
fpga开发
QYR-分析2 天前
FPGA视觉处理板行业发展现状、机遇与未来趋势分析
fpga开发
XMAIPC_Robot2 天前
180FPS AI相机模组,轻巧大算力, 高性能双目同步摄像模组+搭配RK3588
人工智能·嵌入式硬件·深度学习·数码相机·fpga开发
人设定义中...2 天前
电脑上的图片传输到VGA上显示 (设计作业)
fpga开发
XMAIPC_Robot2 天前
基于RK3588 高算力,小尺寸,轻重量6T算力无人机AI模块,可接两路同步相机模组
运维·人工智能·深度学习·fpga开发·无人机·边缘计算
一口一口吃成大V2 天前
多bit同步的处理
fpga开发