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

相关推荐
zjxtxdy9 小时前
STM32开发
stm32·单片机·fpga开发
博览鸿蒙10 小时前
从入门到工程师路径,快速建立FPGA认知
fpga开发
LCMICRO-1331084774612 小时前
长芯微LD7940完全P2P替代AD7940,是一款14位、逐次逼近型模数转换器(ADC)
单片机·嵌入式硬件·fpga开发·硬件工程·dsp开发·模数转换器adc
lf28248143113 小时前
06 AD9361 LVDS接口实现和仿真
fpga开发
逻辑诗篇19 小时前
FMC122高速数据采集卡:雷达与SDR领域的高性能解决方案
fpga开发
寒秋花开曾相惜1 天前
(学习笔记)4.2 逻辑设计和硬件控制语言HCL(4.2.1 逻辑门&4.2.2 组合电路和HCL布尔表达式)
linux·网络·数据结构·笔记·学习·fpga开发
何如呢2 天前
tx_addheader(加前导)
fpga开发
北京青翼科技2 天前
青翼科技基于XCVU13P FPGA的4路FMC接口高性能信号处理平台丨嵌入式智能平台 · 通用嵌入式平台丨FPGA信号处理板
fpga开发·信号处理·信号处理板·图形处理板卡·pcie数据处理板·fpga板卡
HIZYUAN3 天前
FPGA/CPLD漫谈:2K LUT的功能定位与典型方案(一)
stm32·单片机·嵌入式硬件·fpga开发·国产mcu+fpga
FPGA_Linuxer3 天前
FPGA开发板 KU5P开发板 图像处理,硬件加速 PCIE3.0 100G光口
fpga开发