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

相关推荐
421!36 分钟前
ESP32学习笔记之GPIO
开发语言·笔记·单片机·嵌入式硬件·学习·算法·fpga开发
dMing`2 小时前
基于FPGA的简易数据采集系统
fpga开发·fpga·adc·dac
LCMICRO-133108477465 小时前
长芯微LD9689完全P2P替代AD9689,是一款双通道、14位、2.0 GSPS/2.6 GSPS模数转换器(ADC)
网络·单片机·嵌入式硬件·网络协议·fpga开发·硬件工程·高速adc
萨文 摩尔杰15 小时前
GPS原理学习
学习·fpga开发
Huangichin16 小时前
跟着Gemini学System Verilog
fpga开发
LCMICRO-1331084774618 小时前
长芯微LDC90810完全P2P替代ADC128D818,是一款八通道系统监控器,专为监控复杂系统状态而设计。
stm32·单片机·嵌入式硬件·fpga开发·硬件工程·模数转换芯片adc
迎风打盹儿20 小时前
FPGA中if-else和case的理解:综合出来的电路真的会有优先级吗?
fpga·优先级·综合·case·if-else
s090713621 小时前
保姆级教程十二:USB摄像头接入!ZYNQ+OpenCV+FPGA硬件加速图像处理实战(视觉终极篇)
图像处理·opencv·fpga开发·zynq·硬件加速
CoderIsArt1 天前
FPGA-based 量子电路仿真
fpga开发
碎碎思1 天前
升级版流水灯:用FPGA控制上千颗RGB LED
fpga开发