2022-12-05 16:55:23 +00:00
|
|
|
module ahb_gpio_checker
|
2022-12-12 16:16:17 +00:00
|
|
|
( input wire HCLK
|
|
|
|
, input wire HRESETn
|
|
|
|
, input wire [31:0] HADDR
|
|
|
|
, input wire [ 1:0] HTRANS
|
|
|
|
, input wire [31:0] HWDATA
|
|
|
|
, input wire HWRITE
|
|
|
|
, input wire HSEL
|
|
|
|
, input wire HREADY
|
|
|
|
, input wire [16:0] GPIOIN
|
2022-12-05 16:55:23 +00:00
|
|
|
, input wire HREADYOUT
|
|
|
|
, input wire [31:0] HRDATA
|
|
|
|
, input wire [16:0] GPIOOUT
|
|
|
|
, input wire PARITYERR
|
2022-12-16 20:19:07 +00:00
|
|
|
, input wire PARITYSEL
|
2022-12-05 16:55:23 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
logic gpio_cmd = HSEL && HREADY && HTRANS[1];
|
|
|
|
logic gpio_dir;
|
|
|
|
localparam [7:0] gpio_data_addr = 8'h00;
|
|
|
|
localparam [7:0] gpio_dir_addr = 8'h04;
|
|
|
|
|
|
|
|
// defined properties
|
|
|
|
|
|
|
|
property gpio_write;
|
|
|
|
@(posedge HCLK) disable iff (!HRESETn)
|
|
|
|
(HADDR[7:0] == gpio_data_addr) && gpio_cmd
|
|
|
|
##1
|
2022-12-12 16:16:17 +00:00
|
|
|
(gpio_dir=='1) |->
|
2022-12-05 16:55:23 +00:00
|
|
|
##1
|
2022-12-16 20:19:07 +00:00
|
|
|
(GPIOOUT[15:0] == $past(HWDATA[15:0],1)) && (^GPIOOUT == $past(PARITYSEL, 1));
|
2022-12-05 16:55:23 +00:00
|
|
|
endproperty
|
|
|
|
|
|
|
|
property gpio_read;
|
|
|
|
@(posedge HCLK) disable iff (!HRESETn)
|
|
|
|
(HADDR[7:0] == gpio_data_addr) && gpio_cmd
|
2022-12-12 16:16:17 +00:00
|
|
|
&& (gpio_dir=='0) |->
|
2022-12-05 16:55:23 +00:00
|
|
|
##1
|
2022-12-16 20:19:07 +00:00
|
|
|
((HRDATA[15:0]==$past(GPIOIN[15:0],1)) && HREADYOUT && !PARITYERR);
|
2022-12-05 16:55:23 +00:00
|
|
|
endproperty
|
|
|
|
|
|
|
|
always_ff @(posedge HCLK)
|
|
|
|
begin
|
|
|
|
if(!HRESETn)
|
|
|
|
begin
|
|
|
|
gpio_dir <= '0;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if($past((gpio_cmd && (HADDR == gpio_dir_addr)),1))
|
|
|
|
begin
|
|
|
|
gpio_dir <= HWDATA;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
// check behaviour
|
|
|
|
|
|
|
|
assert_gpio_write: assert property (gpio_write);
|
|
|
|
assert_gpio_read: assert property (gpio_read);
|
|
|
|
|
|
|
|
endmodule
|