简体   繁体   English

在verilog中进行计数器,Modelsim

[英]making counter in verilog, Modelsim

i'm trying to make round robin counter in verilog 我正在尝试在Verilog中进行循环计数器

module rr_arbiter (
clk, // positive edge trigger
reset,  // negative edge trigger
req0, req1, req2, req3, 
grant0, grant1, grant2, grant3,
priority, priority_req);

input clk, reset;
input req0, req1, req2, req3;
input priority;
input [1:0] priority_req;

output grant0, grant1, grant2, grant3;  

reg x 

always(posedge clk or negedge reset) begin
pirority_req = priority;

if (reset) begin
    grant0 <= 1'b0;
    grant1 <= 1'b0;
    grant2 <= 1'b0;
    grant3 <= 1'b0;
   end
else
begin
    if(priority == 1)
        if (priority req == 2b'00)
            begin
            x=1;
            grant0 <= (grant0*(~x))+(grant1*x);     
            x=0;
            grant0 <= (grant0*(~x))+(grant1*x);
            grant1 <= grant2;
            grant2 <= grant3;
            grant3 <= grant1;
            //  counter 0012300123
            end
        else if (priority req == 2b'01)
            begin
            grant0 <= grant1;
            x=1;
            grant1 <= (grant1*(~x))+(grant2*x);
            x=0;
            grant1 <= (grant1*(~x))+(grant2*x);
            grant2 <= grant3;
            grant3 <= grant1;
            //  counter 0112301123
            end
        else if (priority req == 2b'10)
            begin
            grant0 <= grant1;
            grant1 <= grant2;
            x=1;
            grant2 <= (grant2*(~x))+(grant3*x);
            x=0;
            grant2 <= (grant2*(~x))+(grant3*x);
            grant3 <= grant1;
            //  counter 0122301223
            end
        else if (priority req == 2b'11)
            begin
            grant0 <= grant1;
            grant1 <= grant2;
            grant2 <= grant3;
            x=1;
            grant3 <= (grant3*(~x))+(grant1*x);
            x=0;
            grant3 <= (grant3*(~x))+(grant1*x);
            //  counter 0123301233
            end
    end

    else 
    begin
        grant0 <= ~grant2 * grant3;
        grant1 <= grant0;
        grant2 <= grant1;
        grant3 <= grant2;
        //counter 01230123
    end
end
end

end

endmodule 

as you can see, i'm trying to make round robin counter. 如您所见,我正在尝试进行循环计数器。 each case it's like (grant)01230123.., 0012300123.., 0112301123.., 0122301223.., 0123301233... 每种情况都像(grant)01230123 ..,0012300123 ..,0112301123 ..,0122301223 ..,0123301233 ...

** Error: (vlog-13069) C:/Modeltech_pe_edu_10.4a/examples/rr_arbiter.v(17): near "always": syntax error, unexpected always, expecting ';' **错误:(vlog-13069)C:/Modeltech_pe_edu_10.4a/examples/rr_arbiter.v(17):在“总是”附近:语法错误,总是意外,期望';' or ','. 要么 ','。

** Error: (vlog-13069) C:/Modeltech_pe_edu_10.4a/examples/rr_arbiter.v(22): near "<=": syntax error, unexpected <=. **错误:(vlog-13069)C:/Modeltech_pe_edu_10.4a/examples/rr_arbiter.v(22):在“ <=”附近:语法错误,意外<=。

** Error: C:/Modeltech_pe_edu_10.4a/examples/rr_arbiter.v(22): (vlog-13205) Syntax error found in the scope following 'grant0'. **错误:C:/Modeltech_pe_edu_10.4a/examples/rr_arbiter.v(22):(vlog-13205)在“ grant0”之后的范围中发现语法错误。 Is there a missing '::'? 是否缺少'::'?

The error message for line 17 is self-explanatory. 第17行的错误消息是不言自明的。 It is expecting a ';'. 它期待一个';'。 You are missing a ';' 您缺少“;” on line 15. 在第15行。

If an error message appears to make no sense, always cast your eye up the screen to see whether the problem is with a previous line. 如果错误消息似乎毫无意义,请始终将视线移至屏幕上,查看问题是否出在前一行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM