EDA Playground lets you type in and run HDL code (using a selection of free and commercial simulators and synthesizers).
It's great for learning HDLs, it's great for testing out unfamiliar things and it's great for sharing code.
You can start typing straight away. But to run your code, you'll need to sign or log in. Logging in with a Google account gives you access to all non-commercial simulators and some commercial simulators:
To run commercial simulators, you need to register and log in with a username and password. Registration is free, and only pre-approved email's will have access to the commercial simulators.
203
-- THE EXAMPLES ARE DIRECTLY BELOW
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.NUMERIC_STD.all;
----------------------------------------
-- use clause for generic package instance
use work.small.all;
----------------------------------------
entity testbench is
end entity testbench;
architecture BENCH of testbench is
signal CLK, WR_EN : STD_LOGIC;
signal WR_ADDR, RD_ADDR : addrTp := (others => '0');
signal WR_DATA, RD_DATA : busTp;
signal Stop : BOOLEAN;
begin
ClockGenerator: process
begin
while not Stop loop
CLK <= '0';
wait for 5 NS;
CLK <= '1';
wait for 5 NS;
end loop;
wait;
end process ClockGenerator;
Stim : process
begin
WR_EN <= '1';
WR_DATA <= STD_LOGIC_VECTOR(TO_UNSIGNED(1, dataWidth));
WR_ADDR <= STD_LOGIC_VECTOR(TO_UNSIGNED(1, addressWidth));
wait until RISING_EDGE(CLK);
wait until FALLING_EDGE(CLK);
WR_DATA <= STD_LOGIC_VECTOR(TO_UNSIGNED(2, dataWidth));
WR_ADDR <= STD_LOGIC_VECTOR(TO_UNSIGNED(2, addressWidth));
wait until FALLING_EDGE(CLK);
WR_EN <= '0';
RD_ADDR <= STD_LOGIC_VECTOR(TO_UNSIGNED(1, addressWidth));
wait until FALLING_EDGE(CLK);
RD_ADDR <= STD_LOGIC_VECTOR(TO_UNSIGNED(2, addressWidth));
wait until FALLING_EDGE(CLK);
Stop <= TRUE;
wait;
end process Stim;
DUT: entity work.EX_GENERIC_MAP_PACKAGE_2008(A1)
port map (CLK, WR_EN, WR_ADDR, RD_ADDR, WR_DATA, RD_DATA);
end architecture BENCH;
-- THE EXAMPLES ARE DIRECTLY BELOW
library IEEE;
use IEEE.STD_LOGIC_1164.all;
----------------------------------------
-- generic package mypack
package mypack is
generic (dataWidth, addressWidth : INTEGER);
subtype busTp is STD_LOGIC_VECTOR(dataWidth-1 downto 0);
subtype addrTp is STD_LOGIC_VECTOR(addressWidth-1 downto 0);
type memTp is array (0 to 2**addressWidth-1) of busTp;
end package mypack;
-- Instance of the generic package mypack
package small is new work.mypack
generic map (dataWidth => 16, addressWidth => 4);
----------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
----------------------------------------
-- use clause for generic package instance
use work.small.all;
----------------------------------------
entity EX_GENERIC_MAP_PACKAGE_2008 is
port(CLK, WR_EN : in Std_logic;
WR_ADDR, RD_ADDR : in addrTp;
WR_DATA : in busTp;
RD_DATA : out busTp);
end entity EX_GENERIC_MAP_PACKAGE_2008;
architecture A1 of EX_GENERIC_MAP_PACKAGE_2008 is
signal RAM: memTp;
begin
process( CLK )
begin
if Rising_edge( CLK ) then
if WR_EN = '1' then
RAM(To_integer(Unsigned(WR_ADDR))) <= WR_DATA;
end if;
RD_DATA <= RAM(To_integer(Unsigned(RD_ADDR)));
end if;
end process;
end architecture A1;
Your account is not validated. If you wish to use commercial simulators, you need a validated account.
If you have already registered (or have recently changed your email address), but have not clicked on the link in the email we sent you, please do so. If you cannot find the email, please check your spam/junk folder. Or click here to resend the email.
If you have not already registered for a full account, you can do so by clicking below. You will then need to provide us with some identification information. You may wish to save your code first.
Creating, deleting, and renaming files is not supported during Collaboration. To encourage development of these features for Collaboration, tweet to @EDAPlayground
This playground may have been modified. Please save or copy before starting collaboration.
Your exercise has been submitted.