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

相关推荐
阳排2 小时前
FT2232芯片通过JTAG连接Xilinx FPGA
fpga开发
szxinmai主板定制专家3 小时前
基于ZYNQ MPSOC ARM+FPGA的超高清实时图像采集与压缩系统设计
linux·运维·服务器·arm开发·人工智能·嵌入式硬件·fpga开发
GateWorld3 小时前
LCD显示技术完全指南:原理·制造·驱动·FPGA实现之驱动三
fpga开发·lcd显示·fpga点亮屏幕·minilvds
FPGA的花路1 天前
基于脚本的ModelSim自动化仿真(Xilinx FPGA篇)
fpga开发·xilinx·自动化脚本·modelsim仿真
汽车仪器仪表相关领域2 天前
Kvaser Hybrid Pro 2xCAN/LIN 双通道可编程CAN/LIN通讯接口:一机双模可编程,汽车车身混合总线测试专用设备
人工智能·功能测试·安全·fpga开发·汽车·压力测试
szxinmai主板定制专家2 天前
电力设备RK3568/RK3576+FPGA,多系统混合部署Linux+RTOS RT-THREAD,强实时性
linux·运维·服务器·人工智能·嵌入式硬件·fpga开发
ALINX技术博客2 天前
【黑金云课堂】FPGA技术教程Vitis开发:PS端DP接口解析
fpga开发·fpga
FakeOccupational2 天前
fpga系列 HDL:跨时钟域同步 shift register同步(CDC)毛刺滤除&解码前去抖动滤波模块
fpga开发
小眼睛FPGA2 天前
【紫光HiYou开源入门轻量级PCIE开发板PG2L25G】实验例程6-基于UDP 的以太网传输实验例程
fpga开发
高速上的乌龟2 天前
Lattice LFCPNX-100 HSB+Fpga开发详解: MAC+PCS以太网SFP光口传输
单片机·嵌入式硬件·fpga开发