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

相关推荐
Lee_yayayayaya10 分钟前
锁相环技术及FPGA实现
fpga开发
Js_cold5 小时前
Verilog局部参数localparam
开发语言·fpga开发·verilog
promising-w5 小时前
【FPGA】使用移位实现LED流水灯
fpga开发
爱吃汽的小橘6 小时前
ZYNQ介绍
fpga开发
ThreeYear_s16 小时前
电力电子技术学习路径与FPGA/DSP技术结合方向(gemini生成)
学习·fpga开发
奋斗的牛马20 小时前
FPGA—ZYNQ学习spi(六)
单片机·嵌入式硬件·学习·fpga开发·信息与通信
GateWorld1 天前
FPGA核心约束类型与语法
fpga开发
SKYDROID云卓小助手1 天前
无人设备遥控器之数字图传技术
运维·服务器·单片机·嵌入式硬件·fpga开发
Topplyz1 天前
在FPGA中实现频率计方案详解(等精度测量)
fpga开发·fpga·频率计
whik11941 天前
如何测量FPGA管脚的好坏
fpga开发