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

相关推荐
通信小呆呆9 小时前
单端口RAM、伪双端口RAM、真双端口RAM:功能详解与应用选型指南
fpga开发
s09071361 天前
【FPGA实战】基于Verilog的MCP2515 CAN控制器SPI驱动详解 | 附完整代码
fpga开发·硬件设计·can通信·mcp2515
szxinmai主板定制专家1 天前
基于 ARM+FPGA 数据机床实时工业控制设计--以雕刻机为例
arm开发·人工智能·嵌入式硬件·fpga开发
XMAIPC_Robot1 天前
基于RK3588 ARM+FPGA电火花数控机床控制系统设计,兼顾ethercat软硬件实时
linux·arm开发·人工智能·嵌入式硬件·fpga开发
XMAIPC_Robot1 天前
基于 ARM+FPGA 数据机床控制系统设计--以雕刻机为例
arm开发·fpga开发
GateWorld1 天前
LCD显示技术完全指南:原理·制造·驱动·FPGA实现之点屏一
fpga开发·lcd显示·fpga点亮屏幕·minilvds·fpga点屏
風清掦2 天前
【STM32学习笔记-14】WDG看门狗 - 14.2 WWDG窗口看门狗
笔记·stm32·单片机·嵌入式硬件·学习·fpga开发
尤老师FPGA2 天前
HDMI数据的接收发送实验(十二)
fpga开发
坏孩子的诺亚方舟2 天前
FPGA神经网络数学基础0
人工智能·神经网络·线性代数·fpga开发
熠速2 天前
PolarBox高性能实时仿真系统
arm开发·fpga开发·嵌入式实时数据库·硬件在环半实物仿真