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

相关推荐
Coder-hong9 小时前
TopJTAG Probe连接zynq
fpga开发
Aaron158815 小时前
RFSOC+VU13P/VU9P+GPU多通道同步一体化解决方案
人工智能·嵌入式硬件·算法·matlab·fpga开发·硬件架构·基带工程
ALINX技术博客15 小时前
【黑金云课堂】FPGA技术教程Linux开发:串行通信接口与实时时钟模块
linux·fpga开发
Felven17 小时前
国产ZYNQ multiboot功能介绍与实现
linux·fpga开发·multiboot·国产zynq
cjie2211 天前
DDR3速率分档
fpga开发
坏孩子的诺亚方舟2 天前
open_prj22_IIC读写EEPROM、AD/DA、PLSYSMON
fpga开发·mpsoc
cjie2212 天前
仿真xilinx库加glbl()的作用
fpga开发
禾刀围玉2 天前
基于FPGA的卷积神经网络实现-方案构想
人工智能·fpga开发·cnn
Aaron15882 天前
全频段 SDR干扰源模块解决方案(星链干扰、LORA无人机干扰)
人工智能·算法·fpga开发·硬件架构·硬件工程·无人机·信息与通信
Kent Gu2 天前
FPGA JTAG确认
fpga开发