4 // After a read operation, the semaphore is always locked
5 // If it was already locked before the read (meaning someone else holds the lock)
6 // then a 1 is returned
7 // If it was not already locked (meaning the reader now holds the lock)
8 // then a 0 is returned
10 // A write operation clears the lock
13 #(parameter count=8, DBUS_WIDTH=32)
16 input [DBUS_WIDTH-1:0] wb_dat_i,
22 output [DBUS_WIDTH-1:0] wb_dat_o);
24 reg [count-1:0] locked;
26 always @(posedge clock)
28 locked <= {count{1'b0}};
31 locked[adr_i] <= 1'b0;
33 locked[adr_i] <= 1'b1;
35 assign wb_dat_o[DBUS_WIDTH-1:1] = {(DBUS_WIDTH-1){1'b0}};
36 assign wb_dat_o[0] = locked[adr_i];
37 assign wb_ack_o = wb_stb_i;
40 endmodule // wb_semaphore