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

相关推荐
做一个快乐的小傻瓜1 小时前
XCKU5P引脚约束
fpga开发
水云桐程序员8 小时前
FPGA开发需要的环境配置
fpga开发
LCMICRO-133108477469 小时前
长芯微LPS6288完全P2P替代TPS61288,是一款具有 15A 开关电流的全集成同步升压转换器
stm32·单片机·嵌入式硬件·fpga开发·硬件工程·同步升压转换器
Soari12 小时前
FPGA开发:Vivado 打开工程的两种方式详解(.xpr vs Tcl)
fpga开发
星华云13 小时前
[FPGA] ISE DDS IP核简单记录使用
fpga开发
Kong_199414 小时前
芯片开发学习笔记·二十五——UCIe
fpga开发·芯片开发
发发就是发16 小时前
I2C适配器与算法:从一次诡异的时序问题说起
服务器·驱动开发·单片机·嵌入式硬件·算法·fpga开发
ALINX技术博客1 天前
【黑金云课堂】FPGA技术教程FPGA基础:流水灯实验
fpga开发·fpga
化屾为海1 天前
FPGA制造与测试全流程
fpga开发·制造
Aaron15881 天前
RFSOC+VU13P+RK3588的核心优势与应用场景分析
嵌入式硬件·算法·matlab·fpga开发·信息与通信·信号处理·基带工程