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

相关推荐
聊询QQ:688238866 小时前
DENSO机器人二次开发:用C#读取和写入数据
fpga开发
s09071366 小时前
ZYNQ7000关于JTAG电路设计注意事项
fpga开发·zynq·硬件设计设计
ARM+FPGA+AI工业主板定制专家7 小时前
基于JETSON/RK3588+FPGA+AI农业机器人视觉感知方案
人工智能·计算机视觉·fpga开发·机器人
ARM+FPGA+AI工业主板定制专家9 小时前
基于JETSON/RK3588+FPGA+AI商用自动割草机器人方案
人工智能·目标检测·计算机视觉·fpga开发·机器人
我爱C编程9 小时前
【硬件片内测试】基于FPGA的完整16QAM软解调测试,含频偏锁定,帧同步,定时点,Viterbi译码,信道,误码统计
fpga开发·16qam·软解调·帧同步·viterbi译码·频偏锁定·定时点
ARM+FPGA+AI工业主板定制专家9 小时前
基于JETSON ORIN+FPGA+GMSL+AI的高带宽低延迟机器视觉方案
网络·人工智能·目标检测·计算机视觉·fpga开发·自动驾驶
XINVRY-FPGA9 小时前
EP1C6T144I7N Altera Cyclone FPGA
嵌入式硬件·fpga开发·硬件工程·dsp开发·fpga
szxinmai主板定制专家11 小时前
JETSON orin+FPGA+GMSL+AI协作机器人视觉感知
网络·arm开发·人工智能·嵌入式硬件·fpga开发·机器人
li星野13 小时前
打工人日报#20251208
fpga开发
s090713613 小时前
ZYNQ几种boot模式下sdk文件区别
fpga开发·sdk·zynq