在ewlance_ff @中交换2个参数
我的代码有问题。
如果语句为true,我正在尝试以同一时钟之间的时钟交换Xspeed和Yspeed。
我会遇到错误:
无法解析净的多个恒定驱动器
,
module_name的常数驱动程序
如果语句显示相同的错误,则
int Xspeed, topLeftX_FixedPoint; // local parameters
int Yspeed, topLeftY_FixedPoint;
//////////--------------------------------------------------------------------------------------------------------------=
// calculation 0f Y Axis speed using gravity or colision
always_ff@(posedge clk or negedge resetN)
begin
if(!resetN) begin
Yspeed <= INITIAL_Y_SPEED;
topLeftY_FixedPoint <= INITIAL_Y * FIXED_POINT_MULTIPLIER;
end
else begin
// colision Calcultaion
//hit bit map has one bit per edge: Left-Top-Right-Bottom
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[1]==1)) begin // hit top border of brick
if (Yspeed < 0 && Xspeed > 0) begin // while moving up and moving right
Yspeed <= Xspeed ;
Xspeed <= Yspeed ; // negative move left
end
end
。完整的代码:
// (c) Technion IIT, Department of Electrical Engineering 2021
//-- Alex Grinshpun Apr 2017
//-- Dudy Nov 13 2017
// SystemVerilog version Alex Grinshpun May 2018
// coding convention dudy December 2018
// updaed Eyal Lev Feb 2021
module pokadoor_moveCollision (
input logic clk,
input logic resetN,
input logic startOfFrame, // short pulse every start of frame 30Hz
input logic Y_direction, //change the direction in Y to up
input logic toggleX, //toggle the X direction
input logic collision, //collision if smiley hits an object
input logic [3:0] HitEdgeCode, //one bit per edge
output logic signed [10:0] topLeftX, // output the top left corner
output logic signed [10:0] topLeftY // can be negative , if the object is partliy outside
);
// a module used to generate the ball trajectory.
parameter int INITIAL_X = 320;
parameter int INITIAL_Y = 240;
parameter int INITIAL_X_SPEED = 60;
parameter int INITIAL_Y_SPEED = 150;
parameter int MAX_Y_SPEED = 230;
const int Y_ACCEL = -1;
const int FIXED_POINT_MULTIPLIER = 64;
// FIXED_POINT_MULTIPLIER is used to enable working with integers in high resolution so that
// we do all calculations with topLeftX_FixedPoint to get a resolution of 1/64 pixel in calcuatuions,
// we devide at the end by FIXED_POINT_MULTIPLIER which must be 2^n, to return to the initial proportions
const int x_FRAME_SIZE = 639 * FIXED_POINT_MULTIPLIER; // note it must be 2^n
const int y_FRAME_SIZE = 479 * FIXED_POINT_MULTIPLIER;
const int bracketOffset = 30;
const int OBJECT_WIDTH_X = 64;
int Xspeed, topLeftX_FixedPoint; // local parameters
int temp;
int Yspeed, topLeftY_FixedPoint;
//////////--------------------------------------------------------------------------------------------------------------=
// calculation 0f Y Axis speed using gravity or colision
always_ff@(posedge clk or negedge resetN)
begin
if(!resetN) begin
Yspeed <= INITIAL_Y_SPEED;
topLeftY_FixedPoint <= INITIAL_Y * FIXED_POINT_MULTIPLIER;
end
else begin
// colision Calcultaion
//hit bit map has one bit per edge: Left-Top-Right-Bottom
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[1]==1)) begin // hit top border of brick
if (Yspeed < 0 && Xspeed > 0) begin // while moving up and moving right
Yspeed <= Xspeed ;
Xspeed <= Yspeed ; // negative move left
end
end
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[3]==1)) begin // hit top border of brick
if (Yspeed < 0 && Xspeed < 0) begin // while moving up and moving left
Yspeed <= -Xspeed ;
Xspeed <= -Yspeed ; // negative move left
end
end
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[3]==0 && HitEdgeCode[1]==0)) begin // hit top border of brick
if (Yspeed < 0) begin// while moving up
Yspeed <= -Yspeed ;
end
end
////
if ((collision && HitEdgeCode [0] == 1 && HitEdgeCode[1]==1)) begin// || (collision && HitEdgeCode [1] == 1 )) hit bottom border of brick
if (Yspeed > 0 && Xspeed > 0) begin// while moving down and moving right
Yspeed <= -Xspeed ;
Xspeed <= -Yspeed ;
end
end
if ((collision && HitEdgeCode [0] == 1 && HitEdgeCode[3]==1)) begin// || (collision && HitEdgeCode [1] == 1 )) hit bottom border of brick
if (Yspeed > 0 && Xspeed < 0) begin// while moving down and moving left
Yspeed <= Xspeed ;
Xspeed <= Yspeed ;
end
end
if ((collision && HitEdgeCode [0] == 1 && HitEdgeCode[3]==0 && HitEdgeCode[1]==0 )) begin// || (collision && HitEdgeCode [1] == 1 )) hit bottom border of brick
if (Yspeed > 0 ) begin// while moving down
Yspeed <= -Yspeed ;
end
end
// perform position and speed integral only 30 times per second
if (startOfFrame == 1'b1) begin
topLeftY_FixedPoint <= topLeftY_FixedPoint + Yspeed; // position interpolation
if (Yspeed < MAX_Y_SPEED ) // limit the spped while going down
Yspeed <= Yspeed - Y_ACCEL ; // deAccelerate : slow the speed down every clock tick
if (Y_direction) begin // button was pushed to go upwards
if (Yspeed > 0 ) // while moving down
Yspeed <= -Yspeed ; // change speed to go up
end ;
end
end
end
//////////--------------------------------------------------------------------------------------------------------------=
// calculation of X Axis speed using and position calculate regarding X_direction key or colision
always_ff@(posedge clk or negedge resetN)
begin
if(!resetN)
begin
Xspeed <= INITIAL_X_SPEED;
topLeftX_FixedPoint <= INITIAL_X * FIXED_POINT_MULTIPLIER;
end
else begin
// an edge input is tested here as it is a very short instance
//if (toggleX)
//Xspeed <= -Xspeed;
// collisions with the sides
if (collision && HitEdgeCode [3] == 1 && HitEdgeCode[0] ==0 && HitEdgeCode[2]==0) begin
if (Xspeed < 0 ) // while moving left
Xspeed <= -Xspeed ; // positive move right
end
if (collision && HitEdgeCode [1] == 1 && HitEdgeCode[0] ==0 && HitEdgeCode[2]==0 ) begin // hit right border of brick
if (Xspeed > 0 ) // while moving right
Xspeed <= -Xspeed ; // negative move left
end
if (startOfFrame == 1'b1 )//&& Yspeed != 0)
topLeftX_FixedPoint <= topLeftX_FixedPoint + Xspeed;
end
end
//get a better (64 times) resolution using integer
assign topLeftX = topLeftX_FixedPoint / FIXED_POINT_MULTIPLIER ; // note it must be 2^n
assign topLeftY = topLeftY_FixedPoint / FIXED_POINT_MULTIPLIER ;
endmodule
错误:
错误(10028):无法解决网络的多个常数驱动程序 “ xspeed [31]” at pokadoor_movecollision.sv(139)错误(10029):常数 驱动程序pokadoor_movecollision.sv(62)错误(10028):无法解决 网络“ Xspeed [30]”的多个恒定驱动程序 pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [29]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [28]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [27]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络“ Xspeed [26]”的恒定驱动程序 pokadoor_movecollision.sv(139)错误(10028):无法解析多个 净驱动程序的净驱动程序“ Xspeed [25]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [24]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络“ Xspeed [23]”的恒定驱动程序 pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [22]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [21]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 净驱动程序的净驱动程序“ Xspeed [20]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 净驱动程序的净驱动程序“ Xspeed [19]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 净驱动程序的净驱动程序“ Xspeed [18]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [17]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络“ Xspeed [16]”的恒定驱动程序 pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [15]” pokadoor_movecollision.sv(139)错误(10028):无法解析多个 网络的恒定驱动程序“ Xspeed [14]” pokadoor_movecollision.sv(139)错误(12152):无法详细用户 层次结构“ pokadoor_block_bdf:inst14 | pokadoor_movecollision:inst” 错误:Quartus Prime Analysis&amp;阐述不成功。 20 错误,15个警告错误:峰值虚拟内存:4797兆字节 错误:处理结束:THU APR 14 14:26:35 2022错误:过去 时间:00:00:07错误:总CPU时间(在所有处理器上):00:00:16
I have an issue with my code.
I'm trying to swap between Xspeed and Yspeed at the same clock while the if
statement is true.
I'm getting the errors:
cant resolve multiple constant drivers for net
and
constant drivers at module_name
Several if
statements show the same errors.
int Xspeed, topLeftX_FixedPoint; // local parameters
int Yspeed, topLeftY_FixedPoint;
//////////--------------------------------------------------------------------------------------------------------------=
// calculation 0f Y Axis speed using gravity or colision
always_ff@(posedge clk or negedge resetN)
begin
if(!resetN) begin
Yspeed <= INITIAL_Y_SPEED;
topLeftY_FixedPoint <= INITIAL_Y * FIXED_POINT_MULTIPLIER;
end
else begin
// colision Calcultaion
//hit bit map has one bit per edge: Left-Top-Right-Bottom
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[1]==1)) begin // hit top border of brick
if (Yspeed < 0 && Xspeed > 0) begin // while moving up and moving right
Yspeed <= Xspeed ;
Xspeed <= Yspeed ; // negative move left
end
end
The full the code:
// (c) Technion IIT, Department of Electrical Engineering 2021
//-- Alex Grinshpun Apr 2017
//-- Dudy Nov 13 2017
// SystemVerilog version Alex Grinshpun May 2018
// coding convention dudy December 2018
// updaed Eyal Lev Feb 2021
module pokadoor_moveCollision (
input logic clk,
input logic resetN,
input logic startOfFrame, // short pulse every start of frame 30Hz
input logic Y_direction, //change the direction in Y to up
input logic toggleX, //toggle the X direction
input logic collision, //collision if smiley hits an object
input logic [3:0] HitEdgeCode, //one bit per edge
output logic signed [10:0] topLeftX, // output the top left corner
output logic signed [10:0] topLeftY // can be negative , if the object is partliy outside
);
// a module used to generate the ball trajectory.
parameter int INITIAL_X = 320;
parameter int INITIAL_Y = 240;
parameter int INITIAL_X_SPEED = 60;
parameter int INITIAL_Y_SPEED = 150;
parameter int MAX_Y_SPEED = 230;
const int Y_ACCEL = -1;
const int FIXED_POINT_MULTIPLIER = 64;
// FIXED_POINT_MULTIPLIER is used to enable working with integers in high resolution so that
// we do all calculations with topLeftX_FixedPoint to get a resolution of 1/64 pixel in calcuatuions,
// we devide at the end by FIXED_POINT_MULTIPLIER which must be 2^n, to return to the initial proportions
const int x_FRAME_SIZE = 639 * FIXED_POINT_MULTIPLIER; // note it must be 2^n
const int y_FRAME_SIZE = 479 * FIXED_POINT_MULTIPLIER;
const int bracketOffset = 30;
const int OBJECT_WIDTH_X = 64;
int Xspeed, topLeftX_FixedPoint; // local parameters
int temp;
int Yspeed, topLeftY_FixedPoint;
//////////--------------------------------------------------------------------------------------------------------------=
// calculation 0f Y Axis speed using gravity or colision
always_ff@(posedge clk or negedge resetN)
begin
if(!resetN) begin
Yspeed <= INITIAL_Y_SPEED;
topLeftY_FixedPoint <= INITIAL_Y * FIXED_POINT_MULTIPLIER;
end
else begin
// colision Calcultaion
//hit bit map has one bit per edge: Left-Top-Right-Bottom
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[1]==1)) begin // hit top border of brick
if (Yspeed < 0 && Xspeed > 0) begin // while moving up and moving right
Yspeed <= Xspeed ;
Xspeed <= Yspeed ; // negative move left
end
end
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[3]==1)) begin // hit top border of brick
if (Yspeed < 0 && Xspeed < 0) begin // while moving up and moving left
Yspeed <= -Xspeed ;
Xspeed <= -Yspeed ; // negative move left
end
end
if ((collision && HitEdgeCode [2] == 1 && HitEdgeCode[3]==0 && HitEdgeCode[1]==0)) begin // hit top border of brick
if (Yspeed < 0) begin// while moving up
Yspeed <= -Yspeed ;
end
end
////
if ((collision && HitEdgeCode [0] == 1 && HitEdgeCode[1]==1)) begin// || (collision && HitEdgeCode [1] == 1 )) hit bottom border of brick
if (Yspeed > 0 && Xspeed > 0) begin// while moving down and moving right
Yspeed <= -Xspeed ;
Xspeed <= -Yspeed ;
end
end
if ((collision && HitEdgeCode [0] == 1 && HitEdgeCode[3]==1)) begin// || (collision && HitEdgeCode [1] == 1 )) hit bottom border of brick
if (Yspeed > 0 && Xspeed < 0) begin// while moving down and moving left
Yspeed <= Xspeed ;
Xspeed <= Yspeed ;
end
end
if ((collision && HitEdgeCode [0] == 1 && HitEdgeCode[3]==0 && HitEdgeCode[1]==0 )) begin// || (collision && HitEdgeCode [1] == 1 )) hit bottom border of brick
if (Yspeed > 0 ) begin// while moving down
Yspeed <= -Yspeed ;
end
end
// perform position and speed integral only 30 times per second
if (startOfFrame == 1'b1) begin
topLeftY_FixedPoint <= topLeftY_FixedPoint + Yspeed; // position interpolation
if (Yspeed < MAX_Y_SPEED ) // limit the spped while going down
Yspeed <= Yspeed - Y_ACCEL ; // deAccelerate : slow the speed down every clock tick
if (Y_direction) begin // button was pushed to go upwards
if (Yspeed > 0 ) // while moving down
Yspeed <= -Yspeed ; // change speed to go up
end ;
end
end
end
//////////--------------------------------------------------------------------------------------------------------------=
// calculation of X Axis speed using and position calculate regarding X_direction key or colision
always_ff@(posedge clk or negedge resetN)
begin
if(!resetN)
begin
Xspeed <= INITIAL_X_SPEED;
topLeftX_FixedPoint <= INITIAL_X * FIXED_POINT_MULTIPLIER;
end
else begin
// an edge input is tested here as it is a very short instance
//if (toggleX)
//Xspeed <= -Xspeed;
// collisions with the sides
if (collision && HitEdgeCode [3] == 1 && HitEdgeCode[0] ==0 && HitEdgeCode[2]==0) begin
if (Xspeed < 0 ) // while moving left
Xspeed <= -Xspeed ; // positive move right
end
if (collision && HitEdgeCode [1] == 1 && HitEdgeCode[0] ==0 && HitEdgeCode[2]==0 ) begin // hit right border of brick
if (Xspeed > 0 ) // while moving right
Xspeed <= -Xspeed ; // negative move left
end
if (startOfFrame == 1'b1 )//&& Yspeed != 0)
topLeftX_FixedPoint <= topLeftX_FixedPoint + Xspeed;
end
end
//get a better (64 times) resolution using integer
assign topLeftX = topLeftX_FixedPoint / FIXED_POINT_MULTIPLIER ; // note it must be 2^n
assign topLeftY = topLeftY_FixedPoint / FIXED_POINT_MULTIPLIER ;
endmodule
The error:
Error (10028): Can't resolve multiple constant drivers for net
"Xspeed[31]" at pokadoor_moveCollision.sv(139) Error (10029): Constant
driver at pokadoor_moveCollision.sv(62) Error (10028): Can't resolve
multiple constant drivers for net "Xspeed[30]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[29]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[28]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[27]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[26]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[25]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[24]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[23]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[22]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[21]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[20]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[19]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[18]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[17]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[16]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[15]" at
pokadoor_moveCollision.sv(139) Error (10028): Can't resolve multiple
constant drivers for net "Xspeed[14]" at
pokadoor_moveCollision.sv(139) Error (12152): Can't elaborate user
hierarchy "Pokadoor_Block_bdf:inst14|pokadoor_moveCollision:inst"
Error: Quartus Prime Analysis & Elaboration was unsuccessful. 20
errors, 15 warnings Error: Peak virtual memory: 4797 megabytes
Error: Processing ended: Thu Apr 14 14:26:35 2022 Error: Elapsed
time: 00:00:07 Error: Total CPU time (on all processors): 00:00:16
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些错误消息不是很具体。您可以从其他模拟器中获取更多有用的消息,例如 edaplayground上的消息(Cadence和Synopsys)。
问题在于,您不得从不同的
ewansey_ff
块分配给相同的信号。例如,您的代码从两个ewansewance_ff
块中分配给xspeed
。请参阅IEEE STD 1800-2017,第9.2.2.4节顺序逻辑始终_FF过程:
您必须重组代码,以便在
xspeed
的所有分配中都在相同的ewndery_ff
block中完成。Those error messages are not very specific. You can get more helpful messages from other simulators, such as the ones on edaplayground (Cadence and Synopsys).
The problem is that you must not assign to the same signal from different
always_ff
blocks. For example, your code assigns toXspeed
from bothalways_ff
blocks.Refer to IEEE Std 1800-2017, section 9.2.2.4 Sequential logic always_ff procedure:
You must restructure your code such that all assignments to
Xspeed
are done in the samealways_ff
block.