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

相关推荐
FPGA-ADDA5 小时前
第一篇:从“软件无线电”到“单芯片无线电”——RFSoC如何重塑无线系统设计
arm开发·信号处理·fpga·通信系统·rfsoc
s09071366 小时前
【Zynq 进阶一】深度解析 PetaLinux 存储布局:NAND Flash 分区与 DDR 内存分配全攻略
linux·fpga开发·设备树·zynq·nand flash启动·flash分区
Kong_19947 小时前
芯片开发学习笔记·二十——时序报告分析
fpga开发·芯片开发
凌盛羽12 小时前
使用python绘图分析电池充电曲线
开发语言·python·stm32·单片机·fpga开发·51单片机
尤老师FPGA12 小时前
LVDS系列44:Xilinx Ultrascale系 ADC LVDS接口参考方法(六)
fpga开发
化屾为海12 小时前
FPGA之PLL展频
fpga开发
GateWorld14 小时前
FPGA内部模块详解之七 FPGA的“灵魂”加载——配置模块(Configuration)深度解析
fpga开发·fpga config
星华云15 小时前
[FPGA]Spartan6 Uart可变波特率读写JY901P惯导模块
fpga开发·verilog·jy901p·spartan6·惯导
碎碎思15 小时前
基于 Gowin FPGA 的 SDR 开源方案:从硬件到射频全栈打通
fpga开发
S&Z34631 天前
[SZ901]高级功能:远程调试
fpga开发