-
Notifications
You must be signed in to change notification settings - Fork 3
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 #40 from DylanVanAssche/feature/ISSUE-39
Total testbench fixed #39
- Loading branch information
Showing
30 changed files
with
1,108 additions
and
451 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
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,72 @@ | ||
--*********************************************** | ||
--* TITLE: Edgedetector FSM (transmitter) * | ||
--* TYPE: Component * | ||
--* AUTHOR: Dylan Van Assche * | ||
--* DATE: 05/10/2017 * | ||
--*********************************************** | ||
--*************** | ||
--* DESCRIPTION * | ||
--*************** | ||
--1)Purpose: | ||
-- Check if a signal goes from LOW to HIGH | ||
--2)Principle: | ||
-- Moore FSM | ||
--3)Inputs: | ||
-- data, clk, clk_en, rst | ||
--4)Outputs: | ||
-- puls | ||
--********************** | ||
--* LIBRARIES & ENTITY * | ||
--********************** | ||
LIBRARY ieee; | ||
USE ieee.std_logic_1164.ALL; | ||
USE ieee.std_logic_unsigned.ALL; | ||
ENTITY edgedetector IS | ||
PORT | ||
( | ||
data : IN std_logic; | ||
clk : IN std_logic; | ||
clk_en : IN std_logic; | ||
rst : IN std_logic; | ||
puls : OUT std_logic | ||
); | ||
END edgedetector; | ||
--********************************************* | ||
--* ARCHITECTURE, SIGNALS, TYPES & COMPONENTS * | ||
--********************************************* | ||
ARCHITECTURE behavior OF edgedetector IS | ||
TYPE state IS (s0, s1, s2); | ||
SIGNAL present_state, next_state : state; | ||
BEGIN | ||
-- 2-Process: synchronous part | ||
sync_moore : PROCESS (clk) | ||
BEGIN | ||
IF (rising_edge(clk) AND clk_en = '1') THEN | ||
IF (rst = '1') THEN -- reset line high, go to initial state | ||
present_state <= s0; | ||
ELSE -- normal operation | ||
present_state <= next_state; | ||
END IF; | ||
END IF; | ||
END PROCESS sync_moore; | ||
-- 2-Process: combinatoric part | ||
comb_moore : PROCESS (present_state, data) | ||
BEGIN | ||
CASE present_state IS | ||
WHEN s0 => puls <= '0'; -- Initial state | ||
IF (data = '1') THEN -- data high, send puls | ||
next_state <= s1; | ||
ELSE | ||
next_state <= s0; | ||
END IF; | ||
WHEN s1 => puls <= '1'; -- Send puls out (high) | ||
next_state <= s2; | ||
WHEN s2 => puls <= '0'; -- After 1 CLK cycle, puls low | ||
IF (data = '0') THEN -- data low, go to initial state | ||
next_state <= s0; | ||
ELSE | ||
next_state <= s2; | ||
END IF; | ||
END CASE; | ||
END PROCESS comb_moore; | ||
END behavior; |
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,95 @@ | ||
--******************************************************* | ||
--* TITLE: Edgedetector FSM TESTBENCH (transmitter) * | ||
--* TYPE: Component * | ||
--* AUTHOR: Dylan Van Assche * | ||
--* DATE: 05/10/2017 * | ||
--******************************************************* | ||
--*************** | ||
--* DESCRIPTION * | ||
--*************** | ||
--1)Purpose: | ||
-- Check if a signal goes from LOW to HIGH | ||
--2)Principle: | ||
-- Moore FSM | ||
--3)Inputs: | ||
-- data, clk, clk_en, rst | ||
--4)Outputs: | ||
-- puls | ||
--********************** | ||
--* LIBRARIES & ENTITY * | ||
--********************** | ||
LIBRARY ieee; | ||
USE ieee.std_logic_1164.ALL; | ||
USE ieee.std_logic_unsigned.ALL; | ||
ENTITY edgedetector_test IS | ||
END edgedetector_test; | ||
--********************************************* | ||
--* ARCHITECTURE, SIGNALS, TYPES & COMPONENTS * | ||
--********************************************* | ||
ARCHITECTURE structural OF edgedetector_test IS | ||
--initialize signals & constants | ||
CONSTANT period : TIME := 100 ns; | ||
CONSTANT delay : TIME := 10 ns; | ||
SIGNAL end_of_sim : BOOLEAN := false; | ||
SIGNAL data : std_logic; | ||
SIGNAL clk : std_logic; | ||
SIGNAL clk_en : std_logic := '1'; | ||
SIGNAL rst : std_logic; | ||
SIGNAL puls : std_logic; | ||
BEGIN | ||
--*********** | ||
--* MAPPING * | ||
--*********** | ||
-- Connect ports to signals (PORT => SIGNAL) | ||
uut : ENTITY work.edgedetector(behavior) | ||
PORT MAP | ||
( | ||
data => data, | ||
puls => puls, | ||
clk => clk, | ||
clk_en => clk_en, | ||
rst => rst | ||
); | ||
|
||
-- Only for synchronous components | ||
clock : PROCESS | ||
BEGIN | ||
clk <= '0'; | ||
WAIT FOR period/2; | ||
LOOP | ||
clk <= '0'; | ||
WAIT FOR period/2; | ||
clk <= '1'; | ||
WAIT FOR period/2; | ||
EXIT WHEN end_of_sim; | ||
END LOOP; | ||
WAIT; | ||
END PROCESS clock; | ||
-- Testbench | ||
PROCESS | ||
-- Reset procedure to initialize the component | ||
PROCEDURE reset IS | ||
BEGIN | ||
rst <= '1'; | ||
WAIT FOR period * 2; | ||
rst <= '0'; | ||
WAIT FOR period; | ||
END reset; | ||
-- Test data procedure | ||
PROCEDURE test (CONSTANT testdata : IN std_logic) IS | ||
BEGIN | ||
data <= testdata; | ||
WAIT FOR period * 4; | ||
END test; | ||
BEGIN | ||
-- Reset at startup | ||
reset; | ||
-- Test data | ||
test('0'); | ||
test('1'); | ||
test('0'); | ||
test('1'); | ||
end_of_sim <= true; | ||
WAIT; | ||
END PROCESS; | ||
END structural; |
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
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,66 @@ | ||
--*************************************** | ||
--* TITLE: NCO (receiver) * | ||
--* TYPE: Component * | ||
--* AUTHOR: Dylan Van Assche * | ||
--* DATE: 13/12/2017 * | ||
--*************************************** | ||
--*************** | ||
--* DESCRIPTION * | ||
--*************** | ||
--1)Purpose: | ||
-- NCO to divide the 100 Mhz clock of the Virtex II Pro. | ||
--2)Principle: | ||
-- When counting down, send a clk_en signal out and restart. | ||
--3)Ingangen: | ||
-- rst, clk | ||
--4)Uitgangen: | ||
-- clk_en | ||
--********************** | ||
--* LIBRARIES & ENTITY * | ||
--********************** | ||
LIBRARY ieee; | ||
USE ieee.std_logic_1164.ALL; | ||
USE ieee.std_logic_unsigned.ALL; | ||
ENTITY nco_rx IS | ||
PORT | ||
( | ||
clk : IN std_logic; | ||
rst : IN std_logic; | ||
clk_en : OUT std_logic | ||
); | ||
END; | ||
--********************************************* | ||
--* ARCHITECTURE, SIGNALS, TYPES & COMPONENTS * | ||
--********************************************* | ||
ARCHITECTURE behavior OF nco_rx IS | ||
SIGNAL n_count : std_logic_vector(1 DOWNTO 0); | ||
SIGNAL p_count : std_logic_vector(1 DOWNTO 0); | ||
SIGNAL enable : std_logic := '1'; -- allow for reset | ||
SIGNAL enable_next : std_logic := '0'; | ||
CONSTANT TRIGGER : std_logic_vector(1 DOWNTO 0) := (OTHERS => '0'); | ||
BEGIN | ||
clk_en <= enable; | ||
-- 2-Process: synchronous part | ||
count_sync : PROCESS (clk) | ||
BEGIN | ||
IF (rising_edge(clk)) THEN | ||
IF (rst = '1') THEN -- rst line high, go to initial state | ||
p_count <= (OTHERS => '0'); | ||
enable <= '1'; | ||
ELSE -- normal operation | ||
p_count <= n_count; | ||
enable <= enable_next; | ||
END IF; | ||
END IF; | ||
END PROCESS count_sync; | ||
-- 2-Process: combinatoric part | ||
count_comb : PROCESS (p_count, enable) | ||
BEGIN | ||
n_count <= p_count + 1; | ||
IF (n_count = TRIGGER) THEN -- clk_en signal | ||
enable_next <= '1'; | ||
ELSE | ||
enable_next <= '0'; | ||
END IF; | ||
END PROCESS count_comb; | ||
END behavior; |
Oops, something went wrong.