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

相关推荐
XINVRY-FPGA7 小时前
XCZU47DR-2FFVE1156I XilinxFPGA Zynq UltraScale+ RFSoC
嵌入式硬件·fpga开发·云计算·硬件工程·射频工程·fpga
hfut02888 小时前
systemverilog interface总结
fpga开发
tiantianuser8 小时前
RDMA设计33:RoCE v2 接收模块
fpga开发·rdma·高速传输·cmac·roce v2
博览鸿蒙1 天前
FPGA 开发软件学习笔记分享(内含安装与环境配置)
笔记·学习·fpga开发
希言自然也1 天前
赛灵思KU系列FPGA的ICAPE3原语和MultiBoot功能
fpga开发
Flamingˢ1 天前
FPGA实战:基于Verilog的数码管动态扫描驱动设计与仿真验证
fpga开发
GateWorld1 天前
跨时钟域同步(CDC)握手协议
fpga开发·cdc·asic·跨时钟域同步·握手协议
Flamingˢ1 天前
Verilog中reg与wire的区别:从语法到实战
学习·fpga开发·硬件工程
数字芯片实验室1 天前
边界值测试:一个”==”引发的芯片bug
fpga开发·bug
9527华安1 天前
FPGA实现Aurora8B10B视频转UVC传输,基于GTP高速收发器+FT602芯片架构,提供4套工程源码和技术支持
fpga开发·gtp·uvc·aurora8b10b·ft602