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

相关推荐
dadaobusi9 小时前
verilog重音符号
fpga开发
s090713610 小时前
Xilinx FPGA ISERDES 使用详细介绍
fpga开发·xilinx·ddr·iserdes
虹科智能自动化12 小时前
虹科分享 | SocTek IP Cores:FPGA高端网络与时间同步解决方案
fpga开发·ip核·tsn时间敏感网络
秋风战士12 小时前
无线通信算法之340:信道均衡除法定标讨论
算法·fpga开发·信息与通信
FPGA小迷弟13 小时前
基于FPGA实现HDMI接口,选型/核心技术
学习·fpga开发·verilog·fpga·modelsim
szxinmai主板定制专家1 天前
基于 PC 的控制技术+ethercat+linux实时系统,助力追踪标签规模化生产,支持国产化
arm开发·人工智能·嵌入式硬件·yolo·fpga开发
坏孩子的诺亚方舟1 天前
modelsim基础2_modelsim仿真分析
fpga·modelsim·仿真分析
tiger1191 天前
FPGA 在大模型推理中的应用
人工智能·llm·fpga·大模型推理
博览鸿蒙1 天前
如何为春招的金三银四做好准备
fpga开发
FPGA小迷弟2 天前
FPGA处理图像需要用到的主流接口详解
学习·fpga开发·verilog·fpga·modelsim