module MAC #() (
clk, rst, a, b, prev_f, f
);
parameter ELEM_IN_SIZE = 8;
parameter ELEM_OUT_SIZE = 16; //ELEM_IN_SIZE*2
input clk, rst;
input signed [ELEM_IN_SIZE-1:0] a, b;
input signed [ELEM_OUT_SIZE-1:0] prev_f;
output signed [ELEM_OUT_SIZE-1:0] f;
logic [ELEM_IN_SIZE-1:0] l1,l2;
logic [ELEM_OUT_SIZE-1:0] mul,add,f1;
always_ff @(posedge clk or posedge rst) begin
if(rst) begin
l1 <= 0;
l2 <= 0;
f1 <= 0;
end
else begin
l1 <= a;
l2 <= b;
f1 <= prev_f;
end
end
always_ff @(posedge clk or posedge rst) begin
if (rst) begin
f <=0;
end
else begin
f<=add;
end
end
always_comb begin
mul = l1 * l2;
add = mul + f1;
end
endmodule : MAC
and every time i try to i get this error:
Error-[SE] Syntax error
Following verilog source has syntax error :
“MAC.sv”, 20: token is ‘[’
logic [ELEM_IN_SIZE-1:0] l1,l2;
You need time machine to go back to the late 1980’s.
These are also known as ANSI-C style ports, added by Verilog-2001. See section 23.2.1 Module header definition in the IEEE 1800 LRM. Their main advantage is having to mention a port name in a declaration only once, instead of up to three times (for order, direction, and type).