Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Shared resource access

Status
Not open for further replies.

Artlav

Full Member level 2
Joined
Nov 26, 2010
Messages
144
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
2,723
Hello.

I'm trying to figure out how to orchestrate an asynchronous shared access of two independent blocks to a single resource, and describe it in Verilog.

Case in question:
Code:
//----------------------------------------------------------------------------//
`include "arbiter.v"
//----------------------------------------------------------------------------//
module testchip(reset,clock,x);
input  reset,clock;
output [31:0] x;
//----------------------------------------------------------------------------//
reg req_0,req_1,skip_0,skip_1;
wire grant_0,grant_1;
wire clk_2;
//----------------------------------------------------------------------------//
always @(posedge clock)clk_2<=!clk_2; 
//----------------------------------------------------------------------------//
//Arbiter, see http://www.asic-world.com/examples/verilog/arbiter.html
arbiter xa(.clk(clock),.rst(reset),.req0(req_0),.req1(req_1),.gnt0(grant_0),.gnt1(grant_1));
//----------------------------------------------------------------------------//
//Actions
always @(posedge grant_0 or posedge grant_1)
begin
 if(grant_0)begin
  //Do first
  x=x+1;
  req_0=0;
  skip_0=1;
 end else begin
  //Do second
  x=0;
  req_1=0;
  skip_1=1;
 end
end
//----------------------------------------------------------------------------//
//Request first
always @(posedge clock)
begin
 if(skip_0)skip_0=0;else req_0=1;
end
//----------------------------------------------------------------------------//
//Request second
always @(posedge clk_2)
begin
 if(skip_1)skip_1=0;else req_1=1;
end
//----------------------------------------------------------------------------//
//Init
initial
begin
 skip_0=0;
 skip_1=0;
 req_0=0;
 req_1=0;
end
//----------------------------------------------------------------------------//
endmodule
//----------------------------------------------------------------------------//
Each of the blocks set the request variable, indicating to arbiter that it wants to get access, once the grant is signalled it does the access and clears the request.

The problem is that i'm getting "Can't resolve multiple constant drivers for net" errors while trying to synthesise it.

Apparently, only one always block can set a reg/signal.

Thus, the question is - how can i organize this without multiple blocks setting some shared register?
How to implement a simple mutex/semaphore?

More generally, how to implement the shared access like that properly?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top