-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from c-thaler/apb_vc
Apb vc
- Loading branch information
Showing
8 changed files
with
1,238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
-- This Source Code Form is subject to the terms of the Mozilla Public | ||
-- License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
-- You can obtain one at http://mozilla.org/MPL/2.0/. | ||
-- | ||
-- Copyright (c) 2014-2024, Lars Asplund [email protected] | ||
|
||
library ieee; | ||
use ieee.std_logic_1164.all; | ||
use ieee.numeric_std.all; | ||
|
||
library osvvm; | ||
use osvvm.RandomPkg.RandomPType; | ||
|
||
use work.memory_pkg.all; | ||
use work.apb_completer_pkg.all; | ||
use work.logger_pkg.all; | ||
|
||
entity apb_completer is | ||
generic ( | ||
bus_handle : apb_completer_t | ||
); | ||
port ( | ||
clk : in std_logic; | ||
reset : in std_logic; | ||
psel_i : in std_logic; | ||
penable_i : in std_logic; | ||
paddr_i : in std_logic_vector; | ||
pwrite_i : in std_logic; | ||
pwdata_i : in std_logic_vector; | ||
prdata_o : out std_logic_vector; | ||
pready_o : out std_logic | ||
); | ||
end entity; | ||
|
||
architecture a of apb_completer is | ||
|
||
begin | ||
|
||
PROC_MAIN: process | ||
procedure drive_outputs_invalid is | ||
begin | ||
if bus_handle.p_drive_invalid then | ||
prdata_o <= (prdata_o'range => bus_handle.p_drive_invalid_val); | ||
pready_o <= bus_handle.p_drive_invalid_val; | ||
end if; | ||
end procedure; | ||
|
||
variable addr : integer; | ||
variable rnd : RandomPType; | ||
begin | ||
drive_outputs_invalid; | ||
wait until rising_edge(clk); | ||
|
||
loop | ||
-- IDLE/SETUP state | ||
drive_outputs_invalid; | ||
|
||
wait until psel_i = '1' and rising_edge(clk); | ||
-- ACCESS state | ||
|
||
while rnd.Uniform(0.0, 1.0) > bus_handle.p_ready_high_probability loop | ||
pready_o <= '0'; | ||
wait until rising_edge(clk); | ||
end loop; | ||
|
||
pready_o <= '1'; | ||
|
||
addr := to_integer(unsigned(paddr_i)); | ||
|
||
if pwrite_i = '1' then | ||
write_word(bus_handle.p_memory, addr, pwdata_i); | ||
else | ||
prdata_o <= read_word(bus_handle.p_memory, addr, prdata_o'length/8); | ||
end if; | ||
|
||
wait until rising_edge(clk); | ||
|
||
if penable_i = '0' then | ||
failure(bus_handle.p_logger, "penable_i must be active in the ACCESS phase."); | ||
end if; | ||
end loop; | ||
end process; | ||
|
||
end architecture; |
76 changes: 76 additions & 0 deletions
76
vunit/vhdl/verification_components/src/apb_completer_pkg.vhd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
-- This Source Code Form is subject to the terms of the Mozilla Public | ||
-- License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
-- You can obtain one at http://mozilla.org/MPL/2.0/. | ||
-- | ||
-- Copyright (c) 2014-2024, Lars Asplund [email protected] | ||
|
||
library ieee; | ||
use ieee.std_logic_1164.all; | ||
use ieee.numeric_std.all; | ||
|
||
use work.bus_master_pkg.all; | ||
use work.com_pkg.all; | ||
use work.com_types_pkg.all; | ||
use work.logger_pkg.all; | ||
use work.memory_pkg.memory_t; | ||
use work.memory_pkg.to_vc_interface; | ||
|
||
package apb_completer_pkg is | ||
|
||
type apb_completer_t is record | ||
-- Private | ||
p_actor : actor_t; | ||
p_memory : memory_t; | ||
p_logger : logger_t; | ||
p_drive_invalid : boolean; | ||
p_drive_invalid_val : std_logic; | ||
p_ready_high_probability : real range 0.0 to 1.0; | ||
end record; | ||
|
||
constant apb_completer_logger : logger_t := get_logger("vunit_lib:apb_completer_pkg"); | ||
impure function new_apb_completer( | ||
memory : memory_t; | ||
logger : logger_t := null_logger; | ||
actor : actor_t := null_actor; | ||
drive_invalid : boolean := true; | ||
drive_invalid_val : std_logic := 'X'; | ||
ready_high_probability : real := 1.0) | ||
return apb_completer_t; | ||
|
||
constant slave_write_msg : msg_type_t := new_msg_type("apb slave write"); | ||
constant slave_read_msg : msg_type_t := new_msg_type("apb slave read"); | ||
end package; | ||
|
||
package body apb_completer_pkg is | ||
|
||
impure function new_apb_completer( | ||
memory : memory_t; | ||
logger : logger_t := null_logger; | ||
actor : actor_t := null_actor; | ||
drive_invalid : boolean := true; | ||
drive_invalid_val : std_logic := 'X'; | ||
ready_high_probability : real := 1.0) | ||
return apb_completer_t is | ||
variable actor_tmp : actor_t := null_actor; | ||
variable logger_tmp : logger_t := null_logger; | ||
begin | ||
if actor = null_actor then | ||
actor_tmp := new_actor; | ||
else | ||
actor_tmp := actor; | ||
end if; | ||
if logger = null_logger then | ||
logger_tmp := bus_logger; | ||
else | ||
logger_tmp := logger; | ||
end if; | ||
return ( | ||
p_memory => to_vc_interface(memory, logger), | ||
p_logger => logger_tmp, | ||
p_actor => actor_tmp, | ||
p_drive_invalid => drive_invalid, | ||
p_drive_invalid_val => drive_invalid_val, | ||
p_ready_high_probability => ready_high_probability | ||
); | ||
end; | ||
end package body; |
Oops, something went wrong.