Skip to content

Instantly share code, notes, and snippets.

@kusano
Created July 18, 2016 15:19
Show Gist options
  • Save kusano/f2204a352341ed51872971cb3e5399b5 to your computer and use it in GitHub Desktop.
Save kusano/f2204a352341ed51872971cb3e5399b5 to your computer and use it in GitHub Desktop.
parameter N = 4;
reg [31:0] n [0:N-1];
reg [31:0] count;
reg [31:0] max;
integer i;
always @(negedge rst or posedge clk) begin
if (rst==1'd0) begin
n[0] <= 32'd123;
n[1] <= 32'd456;
n[2] <= 32'd789;
n[3] <= 32'd123;
count <= 32'd0;
max <= 32'd0;
end else begin
if (n[count] > max)
max <= n[count];
if (count != N-1)
count <= count+1;
else
count <= 32'd0;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment