module median_five(out1,a[0],a[1],a[2],a[3],a[4],en,clka);
input [7:0] a[0:4];
output out1;
endmodule
Run Code Online (Sandbox Code Playgroud)
**这是错误的.
module median_five(out1,a,b,c,d,e,en,clka);
input [7:0] a,b,c,d,e;
output out1;
endmodule
Run Code Online (Sandbox Code Playgroud)
**这是正确的.
但我想在数组中输入a,b,c,d,e,如:
array[0]<=a;
array[1]<=b;
array[2]<=c;
array[3]<=d;
array[4]<=e;
Run Code Online (Sandbox Code Playgroud) module do2(rst,clk,cout);
input rst,clk;
output [7:0]cout;
reg [2:0]D;
reg [19:0]count;
assign cout=out(D);
always@(posedge clk) begin
count = count+20'd1;
if(rst) begin
D<=3'b0;
end
else if(count==20'd100000)begin
D[0] <=D[1];
D[1] <=D[2];
D[2] <= D[0] ^D[2];
end
end
function [7:0]out;
input [2:0]in;
begin
case(in)
3'b000 : out =8'b11111100 ;
3'b001 : out =8'b01100000 ;
3'b010: out =8'b11011010 ;
3'b011 : out =8'b11110010 ;
3'b100 : out =8'b01100110 ;
3'b101 : out =8'b10110110 ;
3'b110 : out =8'b00111110 ;
3'b111 : out =8'b11100100 ;
endcase …Run Code Online (Sandbox Code Playgroud)